Gentoo Wiki



Command-Line Arguments

MPlayer has a lot of options for playback. See man mplayer if you're ambitious.

Tip: If you have Konqueror installed, you can read the manpage in the browser by opening the URL man:/mplayer

As a general rule, the order of the arguments you pass to mplayer won't matter. If you've seen some examples before, you can switch around the options in any order, and things will work fine.

So, something like this:

mplayer dvd://5 -chapter 12 -ao oss -vo svga

would be the same as this:

mplayer -chapter 12 -vo svga dvd://5 -ao oss

The examples included in this guide will try to display them in a logical and consistent presentation so you can more easily distinguish which options are being passed.

Configuration Files

MPlayer stores per-user config files in the ~/.mplayer directory and system settings in /etc/mplayer.conf. For mplayer, you want to modify the file ~/.mplayer/config.

Arguments that you would normally pass with mplayer would be put in the config file in format argument=option,option. If an argument has suboptions, each one is separated with a colon.

For example, if we always wanted to use these playback options:

mplayer dvd:// -vo xv -ao alsa -channels 4 -alang=en,es

this is what your ~/.mplayer/config would include:

File: ~/.mplayer/config

and you would then get the same result when running this command:

mplayer dvd://

Watching Videos

Once you have MPlayer installed, you're ready to watch something! All you will need to do is run mplayer, and then the file you want to watch.

mplayer movie.avi

Keyboard Navigation

For those of you who don't like looking through MAN pages, here are some of the keys to control playback:

General Playback Options

Once again, these are only a few of the many options available that most people might be looking for. See the MAN page for more details. Almost all of these descriptions are taken straight from the man.

Seeks to 56 seconds:

mplayer movie.avi -ss 56

seeks to 1 hour 10 minutes:

mplayer movie.avi -ss 01:10:00

Video Out Drivers

MPlayer has a lot of video out options. This will cover some of the more basic ones.

First of all, when you installed mplayer, there are a number of video output drivers you can use. You can see your list of possibilities by running:

mplayer -vo help

For example, if you compiled it with X in your USE flags, then you will see x11 in the list.

In each option below, if you want to use that video-out option, use -vo on the command line, or add vo=<value> to your config file.

Here is a short explanation on some of the video output options.

See the man page for more options specific to using SDL.

There are still a few more drivers, but most desktop users will want to use one of the above.

Video Out Options

Along with a wide selection of output drivers, MPlayer also offers you lots of ways to tweak the visual experience as well. Here are a few of the more common options available. Please note that some of these are only available while using certain video output drivers. See the man page for details.

"Specify the hostname and display number of the X server you want to display on." The default will, of course, use the display you are already in.

"Supported by video output drivers which use X11, except SDL, as well as directx and gl2."

"Enables pan-and-scan functionality (cropping the sides of e.g. a 16:9 movie to make it fit a 4:3 display without black bands). The range controls how much of the image is cropped. Only works with the xv, xmga, mga, gl, quartz and xvidix video output drivers."

"Desktop background images may cover the movie window, though. Only works with the x11, xv, xmga, xvidix, quartz and directx video output drivers."

"Turns off xscreensaver at startup and turns it on again on exit."

If you want to add any of these options to your ~/.mplayer/config just add =1 to the option:

File: ~/.mplayer/config

Watching DVDs

If you installed MPlayer with support for DVD playback, then you have a few more options.

First, playing a DVD:

mplayer dvd://

MPlayer will look for the longest title on the DVD and playback that file. In most cases the longest title will be the actual movie (on a DVD movie), and it will show that video.

If you want to play a different title other than the default one, you can specify it as a number after the dvd:// option. This example will play title three:

mplayer dvd://3

Most DVDs that are movies will also be split up into chapters. You can specify a chapter for playback by passing the -chapter argument. This example will play the default title, and the second chapter:

mplayer dvd:// -chapter 2

If You have got image of DVD ( in .mdf or .iso file ), You can also watch it without burning. Just mount it ( using -o loop ) and then:

mplayer -dvd-device /mnt/iso_image dvd://

DVD Audio Languages

A lot of movie DVDs these days come with more than one audio track in different languages.

MPlayer will (usually) default to first audio language track (I think), but if you need to change it, you can use the -alang argument along with the language code.

This example will always play the English audio track:

mplayer dvd:// -alang en

This example plays the Spanish audio track:

mplayer dvd:// -alang es

You can also pass more than one language with the argument, so if the first is not available, it will fall back to the second, and then the next available:

mplayer dvd:// -alang hu,en,es

For more information about languages, see Demuxer/Stream Options in the man page.

DVD Surround Sound

As you are probably aware, a lot of DVDs have their audio stream in surround sound stereo, or more than two channels. By default, MPlayer will downplay all the extra channels to stereo (two channel). This can be changed by using the -channels argument.

This example is the same as the default -- play a DVD in 2-channel stereo mode:

mplayer dvd:// -channels 2

For surround sound, change the number to four:

mplayer dvd:// -channels 4

For full 5.1 surround sound, change the number to six:

mplayer dvd:// -channels 6

To emulate surround sound in headphones (or stereo speakers):

mplayer dvd:// -channels 6 -af resample=48000,hrtf

For more information about how MPlayer handles channels, see Demuxer/Stream Options in the man page.

For help with sending the audio stream straight to your receiver, see Dolby Digital and DTS.

Regional Support

If you get errors like this when watching DVDs:

libdvdread: Invalid IFO for title 2 (VTS_02_0.IFO).
Cannot open the IFO file for DVD title 2.

then you can install regionset:

emerge -av regionset

Run it and follow the prompts to set your player's region code correctly (note there is a hardware limitation on your drive how many times you can change the region code, just running regionset will show you this information):

Code: regionset
regionset version 0.1 -- reads/sets region code on DVD drives
Current Region Code settings:
RPC Phase: II
type: NONE
vendor resets available: 4
user controlled changes resets available: 5
drive plays discs from region(s):, mask=0xFF
Would you like to change the region setting of your drive? [y/n]:y
Enter the new region number for your drive [1..8]:2
New mask: 0xFFFFFFFD, correct? [y/n]:y
Region code set successfully!

See this for more information.

Watching Movies on a Widescreen Monitor

DVDs usually come in either 720x480 (ratio 3:2 or 1.5) for NTSC, and 720x576 (ratio 4:3 or 1.25) for PAL, but when watching DVDs that come in widescreen on a widescreen monitor, some of the picture space is taken up by black bars on the top and bottom, and these need to be removed to get the correct aspect ratio.

First, we must detect the amount of the movie we need to crop. This can be done quite simply with mplayer:

mplayer -vf cropdetect dvd://

This command produces a great amount of output, such as

Code: mplayer -vf cropdetect dvd://
crop area: X: 176..548  Y: 74..362  (-vf crop=368:288:178:74)% 2 0 69%
crop area: X: 136..587  Y: 74..371  (-vf crop=448:288:138:80)% 2 0 68%
crop area: X: 0..719  Y: 74..501  (-vf crop=720:416:0:80) 0.7% 2 0 66%
crop area: X: 0..719  Y: 74..501  (-vf crop=720:416:0:80) 0.7% 2 0 66%
crop area: X: 0..719  Y: 74..501  (-vf crop=720:416:0:80) 0.7% 2 0 66%

Let the movie run for some time, until the values does not change anymore, and use the value in the parenthesis:

mplayer -vf crop=720:416:0:80 dvd://

This crops the movie, but as the aspect-ratio of the DVD isn't set yet, it doesn't fully work yet. We are able to set the aspect-ratio like this:

mplayer -stop-xscreensaver -vf crop=720:416:0:80 -aspect 4:3 dvd://

There you have it. To fully enjoy widescreen, remember to set monitor-aspect as well. It can be set through commandline ("-monitoraspect=16:10", for example), or through the mplayer config files, either /etc/mplayer.conf or ~/.mplayer/config (monitoraspect = "16:10"). The latter overrides the system default, and the commandline overrides them both.

See this for more information.

For random letterboxed or underscanned files that are not stored on a DVD there is a script under development named fsmplayer available from which automates the task of detecting and issuing the correct cropping command line, and can handle various uncommon cases such as white letterbox bars, files where the "black" level is more like dark gray, and files that have intros and trailers at diferent aspect ratios compared to the main video. This script is intended to be a suitable replacement for invoking mplayer directly, except for dvd and streaming playback (although those features are under consideration).

Misc. Tips and Tricks

Get File Details

Use midentify to see some details about your media file.

midentify movie.avi

For some more generic info, you can also run:

file movie.avi

Turning off Annoyances

KDE3 Screensaver

The KDE3 Screensaver is not turned off by passing -stop-xscreensaver to MPlayer, the player tells you that it cannot disable it. However, this is remedied with a simple DCOP call:

dcop kdesktop KScreensaverIface enable false

Replace false with true to turn it on again. The list of available screensaver DCOP calls can be retrieved by removing the final two arguments.


If you have DPMS turned on, it may also start in the middle of watching, this is turned off by:

xset -dpms

and pass +dpms instead to turn it back on. For more information on DPMS refer here.

Automate The Process

This is fairly annoying to have to do everytime before starting MPlayer, so automate the process, put this in your .bashrc or something else sourced at startup:

File: ~/.bashrc
#mplayer wrapper to turn off KDE Screensaver and DPMS
#requires xset

function mplayerwrap {
	dcop kdesktop KScreensaverIface enable false
	xset -dpms
	mplayer "$@"
	xset +dpms
	dcop kdesktop KScreensaverIface enable true

#make wrapper execute by default
alias mplayer="mplayerwrap"

This should make the KDE Screensaver and DPMS turn off while watching a movie, and turn back on later.

Using mplayer in slave mode

From mplayer documentation: "The slave mode allows you to build simple frontends to MPlayer. When run with the -slave option MPlayer will read commands separated by a newline (\n) from stdin. The commands are documented in the slave.txt file."

You can also see the commands by running 'mplayer -input cmdlist'.

There are two ways to run MPlayer in slave mode: directly, or using a fifo.

The first method, you would run mplayer normally, but supress all output. MPlayer will listen for slave commands that you type in.

Code: sample slave commands
$ mplayer -slave -really-quiet

Or, MPlayer can read commands separated by a newline (\n) from stdin using a named pipe (fifo). We need to create the fifo first:

Code: creating mplayer fifo
# mkfifo /home/dom/.mplayer/pipe

Let start mplayer in slave mode:

Code: starting mplayer in slave mode
# mplayer -slave -idle -input file=/home/dom/.mplayer/pipe

This tells mplayer to read commands from the pipe and not to quit when it doesn't have anything to play. So it will just sit around and wait for commands. Another way to do the same:

Code: starting mplayer in slave mode
# mplayer -ao jack, -menu -fs -fixed-vo -slave -idle -input file=/home/$[USERDIR]/.mplayer/pipe

This tell mplayer to do the same as before, but to test if JACK is running, use it if found for the sound output, try the other sound servers if not found. It will also start in full screen, use a fixed video system for multiples files (one (un)initialization for all files) and turn ON the OSD menu.

I have been using this last command from months and find this slave mode the most robust and fastest way to run mplayer.

Now, we can use the loadfile and loadlist commands as documented in slave.txt:

Code: loading a media file
echo "loadfile my_media_file 1" > /home/dom/.mplayer/pipe

The "1" in the loadfile command tell mplayer to append the file to its playing queue. A value of "0" will stop the current playing if any and start playing this new file.

Code: loading a playlist file
echo "loadlist my_media_file 1" > /home/dom/.mplayer/pipe

This will do the same as loadfile, but for a playlist.

More advanced examples can be found here: Control mplayer with FVWM menus and here: FVWM-Crystal: Music-mplayer control and its wrapper script, now included in FVWM-Crystal-3.0.5. Just run 'emerge fvwm-crystal' if you want to try it.

See also

Retrieved from ""

Last modified: Mon, 22 Sep 2008 03:58:00 +0000 Hits: 94,328