You are not logged in.
Jul 15 2012 Added some gimmicks.
March 30 2013 Added compiling advice.
Just for fun I will put a little how-to on using mplayer/mplayer2 for the first timer. But we will stay minimal, no GUI, just the command line.
I guess the app is already familiar to you, maybe you use it already with a graphical frontend like SMplayer or Gnome MPlayer etc. to watch movies.
But we will be more interested how to use this little player just from our best friend, the CLI.
As the options are unlimited it seems, I will just focus on the most obvious and important.
So, why you would like to run mplayer and especially from the command line. Easy to answer, we love minimalism and Rhowaldt loves the terminal! It is fast, lightweight and you can control it completely from the keyboard. It looks sexy on Openbox and is made to run perfectly on all kind of light Window Managers, particularly on tilers. Of course you can use it on any other environment, even on your Mac or Windows machine.
VLC is just too bloated for us, if you like that one, this how-to is not for you.
1. Installation
We have two choices, the original Mplayer or the fork Mplayer2. Both just do the same. I won't speak here about the differences.
Personally I use mplayer2 just by accident and many things I will say here comes from that perspective but also should be applicable to mplayer. They share anyway most of the functions and keyboard controls.
Both apps can be found in the Debian repos, though, if you are on Statler/Squeeze, you have to use backports to install mplayer2.
The original mplayer offers a nasty GUI, do not install it, stay in touch with Rhowaldt's philosophy.
apt-get install mplayer
or
apt-get install mplayer2
2. Configuration
Out of the box mplayer should be able to play whatever you want, movies, music from all kind of types. It comes with all the needed codecs as far as I can tell.
For some extra codecs, specially non-free stuff, you would need the Debian Multimedia repo and take mplayer from there. On a default CrunchBang install that would not be necessary.
Ok, we want to make some personal adjustments. Therefore we will put our changes into:
~/.mplayer/config
for Mplayer or into:
~/.mplayer2/config
for Mplayer2. For this one the first option is also possible as it is/should be fully compatible.
You can put whatever you want in there when you know what you need. I will just show my simple and personal configuration.
# Write your default config options here!
# use alsa for audio output
ao=alsa # {obviously for your audio output, I use Alsa, if you use Pulse, change it}
# use X11 for video output
vo=xv # {obviously for your video output, I use just this, you can change it of course}
# Disable screensaver # {if the screensaver is interfering, this option should disable it while running}
heartbeat-cmd="xscreensaver-command -deactivate &" # stop xscreensaver
stop-xscreensaver="yes"
# Set subtitle file encoding # {I use many languages and need accents/umlauts, therefore you need this option}
unicode=yes
utf8=yes
# Extras
idx=yes # {means you can seek in a file that is still downloading}
softvol=1 # {activate softvol and softvol-max if you need more volume in general, between 10 and 10000}
softvol-max=600
That should be all. I won't go into more details. If you are interested in more options look at the documentaion from both projects or just:
man mplayer
As I said, even without a specific conf file mplayer is usable.
3. Usage
Now let us play some files. It is really easy. You have just to type:
mplayer /path/to/file
Of course most of the times the path will be just too long to type. Better is to use cd to go into a specific directory.
For example:
cd ~/Videos/mymovie.avi
will bring you exactly to your movie file. ~/ refers to your home folder. To play:
mplayer mymovie.avi
Or
cd ~/Videos/My Movies/scarymovie.avi
If you cannot find the movie because it is categorized under more subdirectories you can use the command ls to find your file:
~/Videos/My Movies/Scary Movie$ ls
will show you what is inside this directory, e.g.:
scarymovie.avi
Now you can play the file again with:
~/Videos/My Movies/Scary Movie$ mplayer scarymovie.avi
You can of course use bash completion with Tab because of the spaces and long names of the video files. That makes it faster and you do not have to type everything.
Even more simple is just a right click from your file manager and 'Open terminal here' (Thunar) from the directory of your choice, then ls from the CLI and again:
mplayer scarymovie.avi
That should be all regarding the usage from the terminal window.
If you want to understand bash a bit more, Rhowaldt is the man, also from him and more detailed: Command line basics.
4. Keyboard control
As you know, we will control mplayer just with the keyboard. You can even change the default keybindings but I think they are out of the box usable. Just memorize them.
Some of the most important ones:
Esc - stop playback
Space/p - pause playback
Left - seek backward 10 seconds
Right - seek forward 10 seconds
Down - seek backward 1 minute
Up - seek forward 1 minute
Page down - seek backward 10 minutes
Page up - seek forward 10 minutes
9 - volume down
0 - volume up
m - mute audio
f - fullscreen
# - change available audio tracks (audio languages)
v - enable/disable subtitles
j - change available subtitles
o - toggle OSD
That should make you comfortable enough with mplayer.
Ok, I only talked about the basics. You can of course play radio with it and streams but that is another story. I mostly use mplayer to watch movies.
Feel free to add suggestions of important things I did not mention yet and I will add it to the how-to.
5. Extras
We love fancy terminal outputs. If you want to have some color in your terminal while playing a video file just open the file with:
mplayer -msgcolor -msgmodule /path/to/file
You can of course make an alias for it in your ~/.bashrc:
Mine:
alias play='mplayer -msgcolor -msgmodule'
To avoid the message "Failed to open LIRC support" with the colors enabled, add this to your config:
nolirc=yes
or play the file with this option:
mplayer -msgcolor -msgmodule -nolirc /path/to/file
Therefore change your bash alias.
Sometimes you will have a wrong aspect ratio or you prefer another one, open the video file like this if you want 16:9:
mplayer -aspect 16:9 /path/to/file
For other aspect ratios, just use e.g. 16:10 etc.
If you find all the default terminal output too much, just add this to your conf file:
really-quiet="1"
If you want to watch some nice TV streams etc, Machinebacon made a nice how-to. Apply it for mplayer.
If you prefer to watch Youtube videos from the console using mplayer and without bothering with Flash, go to this thread from Johnraff
For basic embedded subtitle support, add this to your config:
ass=yes
embeddedfonts=yes
#fontconfig=yes
Thanks to Gutterslob.
An annoying thing with mplayer by default is that you have to use the exact name for subtitles matching the movie file. To avoid this behavior you have three options if you add sub-fuziness to your config, some examples:
0 exact match
1 load all subs containing movie name
2 load all subs in the current directory
I added this one:
sub-fuziness=2
If you want to change the default font, you have to change of course your config, I use Liberation Sans, therefore I added this line:
font=/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf
You can also just copy the font into your mplayer directory.
If you are watching .mkv files and prefer another default subtitle language, apply the next changes to your config, as an example, I prefer English subtitles, if not there will be used as fallback if available in this order, Spanish, German, Serbian:
slang=en,es,de,sr
Change it to your liking.
The same happens with the audio language:
alang=en
I prefer English as the first language. Naturally you can add more as your preferred and fallback languages.
I want to start mplayer always in fullscreen when opening a movie file, I use an alias with that option enabled:
mplayer -fs
If you hate mouse support, disable it:
mplayer -nomouseinput
Especially useful when watching internet streams because mouse support will likely break your experience if seeking.
You already see, you can always add options to mplayer, either invoking them from the commandline, loading them from the config or from an alias in your ~/.bashrc.
6. Compiling mplayer from source
TLDR, look here the great advice from Unia.
And specially for mplayer2 from Aeqel.
7. Reference
Mplayer
Mplayer2
Wikepedia article
Arch Wiki article
On the mplayer page they have listed all possible graphical frontends if you want to use one with it in addition.
Also please share your own mplayer configuration file if of interest or you use some special settings.
Have fun!
Last edited by ivanovnegro (2013-03-30 22:57:20)
Offline
Huh? I thought everyone knew how to use mplayer!!
Nice basic config. Seems like a good start for first-time users, so props to ya, Blackheart!!
There's a heck of a lot more out there, though. We haven't even touched mencoder configuration (~/.mplayer/mencoder.conf) or profiles yet. Mplayer's a beast!!
Do you get that annoying "Failed to open LIRC support" message with msgmodule output? Hah, you should've compiled mplayer without LIRC support in the first place. Since it's too late now, you can add ....
nolirc=yes
....to your config file. Should work for mplayer2 also.
Or you can just add that to your command or alias, like so;
alias play='mplayer -msgcolor -msgmodule -nolirc'
Basic embedded subtitle support;
For those of you that watch artsy "foreign" films or cartoons with embryo-faced characters in container formats (mostly .mkv) that have softsubs (SSA/ASS), you can add these lines to your config as well. That way mplayer will default to the fonts that came in the file instead of relying on standard sans or whatever. This is particularly useful for shows that use multiple styles of fonts (to differentiate between spoken dialogue, narration and thoughts, for example);
ass=yes
embeddedfonts=yes
#fontconfig=yes
The last fontconfig line enables your system's fontconfig managed fonts. Uncomment if you want that.
There are also options to control subtitle placement and even font hinting. Best to check the man page under the "OSD/SUBTITLE OPTIONS" section. Actually, it's better you just read the whole damn man page, like you should have in the first place.
Last edited by gutterslob (2012-06-08 15:32:08)
Point & Squirt
Offline
A couple of things....
1. Mplayer won't play a file that has spaces in the filename (or things like exclamation marks !!) from the command line. However, if I open the file in thunar with the custom command mplayer %f then it plays ok. Is there a way around this?
2. This is more of a request than anything else:
I use vlc mainly because I can drag & drop files into a playlist to set my evening's entertainment.
What about the possibility of an Openbox menu item which adds selected files to a playlist playable with mplayer?
Or, alternatively, use thunar custom actions to create a playlist...
Last edited by Kino (2012-06-08 08:49:29)
Offline
Here's two aliases I use to have mplayer play a CD or show my webcam:
alias playcd='mplayer cdda://'
alias cam='mplayer tv://'
Also, the Arch Wiki has a good and extensive article on Mplayer that's worth a read: https://wiki.archlinux.org/index.php/Mplayer
That only leaves me to say: nice guide!
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
I am a #! forum moderator. Feel free to send me a PM with any question you have!
Offline
A couple of things....
1. Mplayer won't play a file that has spaces in the filename
mplayer \firstletter and hit Tab.
Offline
Offline
OK,
I figured out how to create a playlist using thunar custom actions (and it handles filenames with spaces!):
1. Create a custom action.
Edit - Configure custom actions
make a new action e.g. Add to playlist with the following command:
echo %f >> /home/kino/playlist.txt
(edit as required)
and select video files from the Appearance Conditions
Select any video file in thunar and right-click to add that file to the playlist.
2. Select playlist in mplayer
mplayer -playlist playlist.txt
Note: I have not yet figured out how to delete selections from the playlist!
Last edited by Kino (2012-06-08 11:19:25)
Offline
@Slob: Thanks. As I said, just for fun and the beginner has not to read the whole and long man page. Mplayer just has too many awesome options and you already provided some nice additions for the config file. And many thanks for the LIRC support thing!
Mplayer is indeed a beast, because of that I left the stuff out about mencoder, not my territory either.
@others: Keep it coming!
Offline
Thank you - starting this was a good idea!
Out of the box mplayer should be able to play whatever you want, movies, music from all kind of types. It comes with all the needed codecs as far as I can tell.
For some extra codecs, specially non-free stuff, you would need the Debian Multimedia repo and take mplayer from there.
A lot of the non-free codecs you need are in the w32codecs package. I think that comes with #! by default anyway though.
John
--------------------
( a boring Japan blog , Japan Links, idle twitterings and GitStuff )
#! forum moderator BunsenLabs
Offline
So does anybody know of a good stream for Euro 2012 and mplayer?
Offline
So does anybody know of a good stream for Euro 2012 and mplayer?
You don't have a tv?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
I am a #! forum moderator. Feel free to send me a PM with any question you have!
Offline
Thanks ivanov, will try, bookmarked.
Time to move on!#
Offline
You don't have a tv?
no sir.
Offline
Unia wrote:You don't have a tv?
no sir.
Really? Why not?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
I am a #! forum moderator. Feel free to send me a PM with any question you have!
Offline
el_koraco wrote:Unia wrote:You don't have a tv?
no sir.
Really? Why not?
Turn it on. Watch a while. Answer it for yourself.
/
Offline
I haven't had a need to watch it in two years or something. Plus, it just takes up space.
Offline
Well here's a reason to get one Although... Poland vs Greece was not that good of a match. Just wait till Saturday
Last edited by Unia (2012-06-08 18:00:59)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
I am a #! forum moderator. Feel free to send me a PM with any question you have!
Offline
I think that comes with #! by default anyway though.
On #! true but for default Debian not, therefore I mentioned it. Will review the how-to anyway.
Unia wrote:You don't have a tv?
no sir.
Me neither.
But machinebacon's sript is for use. I mentioned it in the how-to. I used it just now to watch the first game instead of going outside or to hunt bad quality Flash driven internet streams.
Poland vs Greece was not that good of a match. Just wait till Saturday
Maybe Russia vs. Czech Republic will be better.
Last edited by ivanovnegro (2012-06-08 18:16:17)
Offline
Unia wrote:Poland vs Greece was not that good of a match. Just wait till Saturday
Maybe Russia vs. Czech Republic will be better.
Maybe, it's on now. Is there a thread on this yet?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
I am a #! forum moderator. Feel free to send me a PM with any question you have!
Offline
^ As I was watching football with my Russian invasion I had here, no idea about a thread but this game was great and the atmosphere here was superb.
на здоровье!
Offline
^ Thanks!
Offline
If your computer can handle it I would recommend these -vo settings.
-vo gl:yuv=3:swapinterval=1:lscale=1:cscale=1
For me the quality is better than -vo xv.
I set some optional settings to increase video quality so it probably uses more power.
The output is vsynced if your OpenGL drivers support vsync.
There's a heck of a lot more out there, though. We haven't even touched mencoder configuration (~/.mplayer/mencoder.conf) or profiles yet. Mplayer's a beast!!
Since mplayer2 was mentioned in the first post you should know that mencoder is not part of mplayer2.
There is also a fork of SMPlayer called SMPlayer2 that has some improvements for use with mplayer2.
My favorite is that it has a dbus interface for now playing information so you can have a mplayer progress bar in conky.
Offline
@ivanov: nice how-to! very basic, very good. and also some very basic stuff about ~ being $HOME and using 'ls' and whatnot. almost makes me wanna do a 'the most basic of basic terminal commands' thread...
and thanks for the mention!
Do you get that annoying "Failed to open LIRC support" message with msgmodule output? Hah, you should've compiled mplayer without LIRC support in the first place. Since it's too late now, you can add ....
Offline
If your computer can handle it I would recommend these -vo settings.
-vo gl:yuv=3:swapinterval=1:lscale=1:cscale=1
For me the quality is better than -vo xv.
I set some optional settings to increase video quality so it probably uses more power.
The output is vsynced if your OpenGL drivers support vsync.
I second this. Only problem with openGL rendering is that it can't decode Hi10p video yet.... in my experience, at least.
Since mplayer2 was mentioned in the first post you should know that mencoder is not part of mplayer2.
Thanks for the clarification. Didn't realize that since I only use Mplayer1.
There is also a fork of SMPlayer called SMPlayer2 that has some improvements for use with mplayer2.
SMplayer has been a very decent player the few times I've used it. Only problem is that it (used to) lack options for certain subtitle types and (more importantly) required QT. Fine if you run KDE or RazorQT (or Crunchbang, since it includes VLC which brings in QT anyway), but I can't really justify installing a new theme engine on my setups just for one application. It would be my go-to GUI frontend if I was recommending Mplayer to a newbie, for sure. Sh*ts all over the Gnome-Mplayer frontend.
Last edited by gutterslob (2012-06-08 23:46:38)
Point & Squirt
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat