MPlayer

About
MPlayer is a high quality media player with a rich set of options that can playback almost every media file you can throw at it, similar to VLC. This guide explains how to setup MPlayer on your Gentoo system. This page provides some documentation for the most common uses and covers some lesser-known features that may come in handy. Feel free to add your own tips and tricks. Examples are also welcome.

Before installing MPlayer, it's important to see what USE flags you have set, because they will in large part determine the functionality of MPlayer. Some codecs and options are only installed with certain USE flags.

Packages
There is the portage ebuild, with snapshots of svn://svn.mplayerhq.hu/mplayer/trunk. It is also possible to choose between two other packages in the multimedia Overlay: Official comparison with MPlayer.
 * , with snapshots of svn://svn.mplayerhq.hu/mplayer/trunk with optional ffmpeg-mt patch.
 * , with snapshots of git://repo.or.cz/mplayer.git. This fork has several useful features:
 * 1) * Multithreaded ffmpeg.
 * 2) * Ability to change many settings staying paused.
 * 3) * Matroska ordered (aka external, linked) chapters support.
 * 4) * Matroska editions support, commit.
 * 5) * Ability to build with shared ffmpeg libraries.

Discussion at forums.gentoo.org

List of all supported USE flags
To see a list of USE options recognised by mplayer:

The following lists the most important of these flags.

Audio and video codecs

 * decoding ATSC A/52 streams used in DVD. Needed for AC3.
 * enables FAAD2 (open source MPEG-4 and MPEG-2 AAC decoder) support
 * , amrwb enables support for Adaptive Multi-Rate Audio encoding (required for playing files recorded by many mobile phones) (on newer mplayer opencore-amr)
 * Enables libdts (DTS Coherent Acoustics decoder) support, found on some DVDs
 * enables Live.com streaming media support
 * adds support for the MAD mp3 decoder
 * adds support for MP2 audio encoding using TwoLame
 * adds support for MP3 audio encoding
 * adds support for the musepack audio codec
 * uses RealPlayer codecs for audio/video playback
 * to play Ogg Theora video files
 * add support for Ogg Vorbis playback and encoding
 * installs the binary codecs
 * support for encoding X264/AVC (MPEG-4) streams
 * adds support for XAnim
 * enables support for XviD encoding

Audio and video output

 * adds support for ASCII output (see libcaca for color)
 * adds support for ALSA (Advanced Linux Sound Architecture) audio output/recording
 * adds support for audio output through aRts
 * Adds DGA Support (Xfree86) (DGA=Direct Graphic Access)
 * adds framebuffer support through the DirectFB layer
 * adds support for audio output through EsounD
 * adds framebuffer output option for video
 * adds support for the LibGGI graphics card drivers
 * lets you encode to and from GIF images
 * enables JACK sound support
 * lets you encode to and from JPEG images
 * adds support for color ASCII output (see aalib for non-color ASCII)
 * enables Network Audio System support
 * lets you use OpenGL for video output
 * adds OSS audio output/recording support
 * lets you encode to and from PNG images
 * adds SDL (Simple Direct Layer) as an audio and/or video output wrapper
 * adds framebuffer support through SVGAlib
 * adds support for dual-screen output (or something)
 * direct video output format

Hardware support

 * builds with 3DNow! support
 * builds with extended 3DNow! support
 * adds paranoia support when ripping/playing CDs (needed for cd-audio playing)
 * to watch/record TV using DVB (Digital Video Broadcast) format, not NTSC (see also v4l and v4l2)
 * will let you rip/play DVDs
 * Enables support for the i8x0 xvmc video driver
 * enables joystick support
 * uses LIRC library for remote controls
 * adds support for Matrox G200/G4x0/G550
 * builds with MMX support
 * builds with MMX2 support
 * adds support for RTC (/dev/rtc)
 * adds support for SSE
 * adds support for SSE2
 * adds support for SSSE3
 * and v4l2 to watch/record TV (see also dvb)
 * Enables X-Video Motion Compensation support

Optional features

 * adds support for FriBiDi libraries
 * adds support for blinkenlights
 * will make the output of MPlayer in color format (and will likely break any scripts parsing it)
 * installs extra documentation
 * will install MEncoder
 * will also install an MPlayer GUI (gmplayer)
 * adds support for IPv6
 * Enables LZO compression support
 * allows you to play a file and output to MD5 hashes
 * allows you to play files over a Samba share directly
 * enables FreeType font rendering support
 * enables support for MPlayer to stop the screensaver on playback

Choosing your USE flags
A reasonable question might be: which USE flags do I want to install? The answer depends on your situation.

If you want to enable support for all the most common video codecs that MPlayer has, the USE Flags you would use are:.

Audio/video USE flags
You probably already have your audio USE flags setup, so for most general uses, there's not much to be said here.

For video output, there are some generic flags that you should add:.

MPlayer has several ways to output video to the screen, using. Xv is the fastest and will be the default.

If you enjoy watching movies on the console (no X session), then the optional flags you would want to enable are:.

Each one actually adds support for a different framebuffer library. DirectFB and fbcon will need framebuffer support enabled in the kernel, while svga requires an external module, svgalib_helper. See MPlayer on Framebuffer for more information.

If you want to watch videos in the terminal without a framebuffer, you can enable these flags:.

AAlib and Libcaca will both output video to the terminal. Libcaca is in color but AAlib is not.

DVD support
If you have a DVD-ROM or DVD-RW in your computer, then make sure to add these flags:.

Most DVDs use AC3 audio (Dolby Digitial), and playback support is provided by liba52 (Provided by USE Flag ). Some DVDs will also provide DTS as well, but is not as common.

Alternately, use the following recommendation to enable menu navigation support:

MPlayer GUI
MPlayer will play in GNOME with its own UI. You can also install a graphical program called GMPlayer, which is a gtk application. Just add to your USE flags.

MPlayer CLI using framebuffer
Follow Framebuffer to get Framebuffer working, after this, you can run mplayer -vo [framebuffer driver] -zoom -fs -xy [framebuffer dimention] [filename.avi]

Example mplayer -vo fbdev -zoom -fs -xy 1280 foo.avi

Hardware USE flags
You can greatly improve MPlayer's performances (in my experience, by up to +40%!) by recompiling it with appropriate CPU-related USE flags. Run mplayer without any parameters, and look for something like this:

As you can see in this case, none of the supported CPU-features have been enabled; so you can recompile MPlayer with the following USE flags:.

Codecs
Old versions of mplayer have a dependency on, which is a collection of codecs originally designed for 32-bit Windows systems. MPlayer can use these codecs to playback formats such as Windows Media Video, RealPlayer, and QuickTime. There is a much longer list of codecs that are also supported, but are not as common or well-known. will install the "all" codec package.

win32codecs also has an optional USE flag that you can enable, if you want to be able to playback most QuickTime movies.

It's important to note that there is already native support for most of these codecs in MPlayer already, and most people will not need win32codecs installed for the majority of their basic video playback needs.

For those using, there is a binary package of 64-bit binary codecs for some Real codecs, packaged in.

Emerge MPlayer
mplayer is probably the package with more compile time options than any other.

Since most of these USE options only concern mplayer it makes sense to put them in as an entry for mplayer rather than adding them to  as you would for system wide options.

Once you've chosen all your USE options, make sure everything looks alright, then emerge the package.

XvMC
XvMC output can be used to reduce CPU usage while playing MPEG2 videos. It needs to be supported by the graphics hardware and driver, one driver supporting this is the nvidia binary driver.

The file should exist and its contents should point to your libXvMC, for example in the case of nvidia's binary driver this should be :

To correctly set your XvMC settings, you can run

XvMC can now be used like this:

Tips and Tricks
MPlayer integration with your desktop gives you its potencial and flexibility without the cost in resources of a GUI user interface.

MPlayer in Firefox
Firefox multimedia file extensions can be associated with a bash script that plays the content of the file in a terminal using MPlayer. For example, to play m3u files you can create the following script:

It uses the urxvtc client, improving memory usage and start-up time. The association of m3u file extensions with this script in Firefox will play the playlist in a low-resources terminal context.

Codecs/settings used in a container
, from MPlayer, gives information on containers and codecs (idea an example from this post): midentify Alice\ in\ Wonderland.mp4

MPlayer with a multi-tuner DVB card
The problem is than, when using multiple dvb tuners, MPlayer want to search for the first tuner in the first dvb card, for the second tuner in the second one, and so on. It is hard-coded into MPlayer and the only thing we can do about this is to write a patch for mplayer. In short and with a multi-tuner dvb card, MPlayer will be able to only find and use the first tuner (typically /dev/dvb/adapter0/frontend0).

It is several ways to solve this issue. A workaround is to use udev to make a fake second dvb card with the second hardware tuner as first tuner. This is only a workaround and it can cause problems when several programs try to access the same hardware with 2 different device files. So, we will skip it.

The second way is a 3 steps setup. 1) Make a channel list with scan (dvbscan on gentoo). 2) Tune the wanted tuner with tzap and szap. 3) Play the channel with mplayer using the coresponding dvr* device.

Another way to fix this issue, and this would be a better one, would be to write a patch for mplayer and test it. That way, we could use mplayer directly with a single command. See Playing trouble with multi-tuner dvb card.

Make the channel list
I have a card that have several tuners: fm radio, analog tv, dvb-t and dvb-s. According to mplayer documentation, the channel list can be ~/.mplayer/channels.conf, or alternatively ~/.mplayer/channels.conf.sat, ~/.mplayer/channels.conf.ter, ~/.mplayer/channels.conf.cbl and ~/.mplayer/channels.conf.atsc for respectively Satellite, Terrestrial, Cable and ATSC. We will not use them but use another location instead:

We will make the channels list for dvb-t and dvb-s.

DVB-T
We will use dvbscan from the linuxtv-dvb-apps package. Be aware than gentoo change the name of the scan software into dvbscan. That imply that the installed dvbscan is in fact scan from linuxtv-dvb-apps, and that dvbscan from linuxtv-dvb-apps is not installed. See this bug report. If you use the patch from this bug report to make your own ebuilds, emerge will install both scan softwares, scan will be renamed into scan-dvb, and you will have to replace dvbscan by scan-dvb in all the following commands using it.

Find the correct frequency list for your region and type of reception. These files are stored under /usr/share/dvb/. For reception with DVB-T in Switzerland, you can use /usr/share/dvb/dvb-t/ch-All The dvb-s tuner is the first tuner of my card (the first adapter), the dvb-t tuner is the second one. For dvbscan the card is the adapter 0 and the tuner are respectively 0 and 1.

DVB-S
We will do another channel search for Astra 19.2E using the file /usr/share/dvb/dvb-s/Astra-19.2E, and we don't want the scrambled channels (mplayer will wait forever with them).

This will take a while with such a satellite. Don't be alarmed by the messages "WARNING: >>> tuning failed!!!". They append when a frequency is reserved but not currently in use, or used for something else than TV.

When this run is finished, we can sort the channels by alphanumeric order:

We can make another channels list for the radio channels:

Enjoy Watching
For watching a channel, we have to run 2 processes in 2 different terminals.

To watch the channel named "RTS Un" in channels.conf.ter (dvb-t channel):

and

or

Don't forget the final "-", or it won't work. It tell mplayer that this is the end of options. Without it, mplayer will espect a filename to play and quit.

To watch the channel named "Cubavision Internacional" in channels_sat.conf (dvb-s channel):

and

or

The advantages of the first mplayer's command is than we are able to change the channel with tzap (or szap) without restarting mplayer, and if the signal is becoming of bad quality, mplayer will wait.

Also, mplayer can try to seek on the device with this first mplayer's command, and this is not dangerous for your hardare (according to awwalls on irc: #linuxtv@freenode).

Links

 * Official MPlayer homepage
 * MPlayer Features
 * MPlayer documentation

MPlayer HOWTO Mplayer