Hack 49. Advanced MPlayer Tweaks
There are a number of advanced tweaks you can use to get the most out of MPlayer. You can even store many of these tweaks to the MPlayer configuration file and save yourself from tons of command-line arguments.
[Hack #48] touched on the basics of multimedia playback using MPlayer, but one look at the MPlayer manpage tells you that MPlayer is much more than that. If you are new to MPlayer, wading through all of these options might leave you a bit cross-eyed, so in this hack I will point out some of the more commonly used advanced options and show you how to set up the MPlayer config file to save many of them.
3.4.1. MPlayer Config File
In this hack, I cover a number of different command-line arguments that you can use to tweak MPlayer. Basically, all of these options can also be set in the MPlayer config file. By default, MPlayer has a global config file in /etc/mplayer/mplayer.conf, and a local config file for each user in ~/.mplayer/config that overrides the global config. The format of this config file is pretty simpletake an mplayer command-line argument, remove the leading -, and set it equal to its setting with the = symbol.
For instance, if you read through the different display options you can set in MPlayer with the -vo option in [Hack #47], you might want to change the default video output option for MPlayer permanently. If you want to set the default -vo option to xv, edit ~/.mplayer/config and add the line (or edit the line if it already exists):
vo = xv
From that point on, MPlayer will behave as if -vo xv were on the command line every time. You can override any of these config settings from the command line as well, so even if vo = xv is in the config file, if you type -vo x11 on the command line, MPlayer will use the X11 video output option.
3.4.2. Go Full Screen and Set Monitor Aspect
Once video playback has started, you can hit the f key to toggle the full screen setting within MPlayer, but if you already know you want to immediately display in full screen mode, just pass the -fs option to mplayer (or fs=true in the MPlayer config file). In the case of video output arguments such as X11 that rely on software scaling, you will also have to add the -zoom option to turn on software scaling (or add zoom=true to the MPlayer config file). Note that software scaling can really bog down a CPU, so only use it if you have a fast processor.
By default, MPlayer will scale a video to full screen as if the screen had a 4:3 aspect ratio. Since most computer monitors have this aspect ratio, the default is fine, but if you have a widescreen flat panel, the full screen mode will look stretched, particularly on 16:9 or anamorphic videos. To fix this, pass the -monitoraspect option to mplayer along with the aspect ratio.
For instance, my laptop has a wide screen with max resolution of 1280 x 768, or 5:3 aspect ratio. To play a DVD full screen with the proper aspect ratio, I would run:
$ mplayer dvd://1 -fs -monitoraspect 5:3
Of course, since I want the -monitoraspect option on at all times on my laptop, I just add monitoraspect=5:3 to my~/.mplayer/config file.
3.4.3. Increase the Cache for Streaming Video
By default, MPlayer uses a 1 MB disk cache to store video it is displaying. For local files this works fine; however when playing streaming video, particularly over a slow link, you might find you run out of cache too quickly and then have to wait as the video chugs through a bit at a time. The -cache option allows you to configure how large a cache to use, so to increase the cache to 8 MB, type:
$ mplayer http://example.com/stream.avi -cache 8192
3.4.4. Rotate the Video Before Playback
This may seem like a strange option to have, unless perhaps you have a tablet-style laptop or other display device that neither Linux nor MPlayer will detect properly. With the -vf rotate option, MPlayer will rotate the image ninety degrees clockwise and flip it. You may also set the rotate option equal to zero through three to adjust how the image rotates. Table 3-2 lists the different values and their functions:
You may also set rotate equal to four through seven; however that will only perform the above rotations provided the video geometry is portrait instead of landscape.
You can also use -vf flip and -vf mirror to flip the image upside-down and rotate it on the Y axis, respectively.