MPlayer

From CCCP
Jump to: navigation, search

MPlayer is an open-source multimedia player, originally designed for Linux, but also ported to Windows, Mac OS X, the BSD's, and many other environments. It's a very competent player that can handle just about everything that the CCCP can handle (and some more), including styled softsubs. The downsides are mostly related to user-friendliness - for example, MPlayer by itself is heavily command-line based, rather than graphical. Below follows some general hints on compiling and using MPlayer.

Contents

Obtaining MPlayer

Ideally, you should get the MPlayer source from SVN (as opposed to the latest version release, which tends to be quickly outdated) and compile it, which is generally safe and not broken, giving you a version that is compiled using your favorite compiler with your settings for your computer. Of course, some of us probably don't even know what half the words in that last sentence are all about; there's a way for everyone, fortunately. Getting MPlayer 1.0 RC1 or a SVN code checkout from later is recommended at the time of this writing, because earlier versions are prone to certain problems and performance is almost always better with newer versions.

Linux

You should probably get it from your own distribution. Some might not have a recent version at all. To go over the more popular distributions: Debian users can currently get it out of the testing and unstable branches (Debian has been a bit leery of MPlayer in the past due to legal issues, but now things seem to be in the clear!). Gentoo users just emerge mplayer, and Ubuntu users should apt-get install mplayer.

Mac OS X (Tiger only)

These instructions have not been tested with the latest version of MPlayer OS X and may not even still apply Download the Mac OS X release dmg file from the official site. Open it and yawn as you drag the app from the disk image to the Applications folder (or wherever. Pretty easy, wasn't it?). Except for the fact that your (non-SSA/ASS) subtitles are now all question marks, should you enable them. This is fixed by NOT setting it in the preferences (set it to 'none' if you already have); instead, you need to set up a default font. The easiest way to do this is to open up a terminal (Terminal.app from /Applications/Utilities ) and use the following lines:

cd
mkdir .mplayer
ln -s /Library/Fonts/ArialHB.ttf .mplayer/subfont.ttf

(you can, however, use whatever ttf font you like, especially if you're not viewing English subs; all that matters with this method is that there is a font accessed through subfont.ttf)

Windows

If you have Windows, you should seriously consider using CCCP and the programs that come with it (styled subtitles pretty much work correctly due to the fact that they're shown with the same software most -- if not all -- subbers currently use, you can use prettier Directshow players like the ones included with CCCP, and because we like CCCP a lot (go figure!), among other good reasons). Nonetheless, there is an MPlayer for Windows. There is a command-line binary and a GUI version available from the official MPlayer site, but we can neither attest to nor account for its stability.

An MPlayer CCCP build has been created for you which should mirror most of the support you get with the CCCP. Most importantly, this build includes support for ASS/SSA subtitles.

Compiling from source

If there is no binary distribution for your OS, or there's a very very new feature you'd like to have, or if you otherwise would like to customize your code somehow, you have to compile MPlayer from the source. It isn't that hard, just time-consuming (and if you have a slower computer, it can be an exercise in patience).

The Compile_MPlayer article contains a script which will automate compiling MPlayer for Windows as much as possible. Read the directions and follow any other instructions on how to setup MSYS-MinGW and you are on your way to making your own MPlayer build.

Instructions for other systems to be written

Codecs

From the MPlayer readme:

MPlayer and libavcodec have builtin support for the most common audio and video
formats, but some formats require external codecs. Examples include Real, Indeo
and QuickTime audio formats. Support for Windows Media formats except WMV9
exists but still has some bugs, your mileage may vary. This step is not
mandatory, but recommended for getting MPlayer to play a broader range of
formats. Please note that most codecs only work on Intel x86 compatible PCs.

Unpack the codecs archives and put the contents in a directory where MPlayer
will find them. The default directory is /usr/local/lib/codecs/ (it used to be
/usr/local/lib/win32 in the past, this also works) but you can change that to
something else by using the '--with-codecsdir=DIR' option when you run
'./configure'.

In other words: For external Windows-only codecs like WMV9, download the essential codecs package from the MPlayer website and put it in the MPlayer codecs directory. This info is actually outdated, since MPlayer now has better support for WMV9 than it used to, but the principle still applies.

Known issues

MPlayer can play most releases, however, there are a few caveats:

  • Architecture: If you are using X86-64, you will be unable to have mplayer use the win32 codecs unless you compile mplayer for a 32-bit x86 architecture. This generally becomes a problem when an encoded release uses WMV or WMA codecs (older KAA releases uses WMV). The same thing goes for PPC (i.e., Macs) - you can't use the WMV codec from the DLL's on a PPC Mac (not in Linux, not in Mac OS X).
  • Speed: MPlayer uses its own internal decoders from the FFMpeg project, which can make some codecs slower than preferable (and other methods are often only available to Windows users). See the configuration section below for solutions to alleviate this.
  • H264/X264 confusion: Some H.264 releases use the FOURCC code h264 while others use x264. x264 as a fourcc code is not supported by default in older versions of MPlayer. To identify this problem, simply start mplayer and look for the following lines (presented in context):

 Matroska file format detected.
 VIDEO:  [x264]  640x480  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
 ==========================================================================

You should simply upgrade MPlayer (see above) to solve this; it is more up-to-date and will have a slightly more optimized decoder anyway. However, you can also follow the instructions below if your version of MPlayer supports H.264 but not the x264 fourcc and prefer to keep your old version.

Instructions on modifying codecs.conf

You can obtain a default codecs.conf from the mplayer source distribution, found on their web site. It is in the etc directory of the directory extracted by the tarball. The section that requires modification is in red.

 videocodec ffh264
   info "FFmpeg H.264"
   status working
   fourcc H264,h264,x264,X264
   fourcc avc1
   format 0x10000005
   driver ffmpeg
   dll h264
   out YV12,I420,IYUV

After modification save to ~/.mplayer.conf

You may also place this modified conf in the mplayer shared directory if you want this change to affect all user accounts of the machine. See the mplayer documentation on codecs.conf for additional details.

Configuring MPlayer

Most of MPlayer's configuration is strictly a matter of taste, but for some options it can make the difference between enjoying your video or not. You may need to edit the files /etc/mplayer/mplayer.conf and/or ~/.mplayer/config depending on your preference (the former is system-wide, the latter is per-user). You can and should read the official documentation to get the most out of configuration, but there are a few options we recommend you set or change.

Widescreen

By default, MPlayer assumes you have a normal 4:3 screen ratio. This is incorrect if you have a newer widescreen monitor/notebook, or if your monitor's native resolution is an oddball like 1280x1024 (many monitors support this resolution but keep the 4:3 ratio by the way, in which case you shouldn't bother), if you use your HDTV as a screen, etc. Figure out the correct aspect ratio and set it, like below. If you aren't sure, get out your measuring tape, measure the viewable surface, and do the math (you can't count on pixels, because sometimes they aren't squares). This is an important configuration step, because if this setting is incorrect, everything looks stretched or smashed. Remember, this is the aspect ratio of the screen itself and not the resolution!

monitoraspect=4:3   # This is the default for normal screens
monitoraspect=5:4   # This is usually for 1280x1024-native LCD's
monitoraspect=16:9  # This is for most HDTV's and widescreens
monitoraspect=16:10 # This is for most computer widescreens.

Styled Subtitles

Since one of the biggest advantages to the CCCP is applying the "it just works" mentality to ASS/SSA styled subtitles, you're probably interested in this. Note that your version of MPlayer has to be compiled to support ASS/SSA (this requires a modestly recent version of Freetype) and fontconfig. Assuming you have these in your MPlayer, support is as simple as having these lines in your configuration. The first time you run it with these options, though, you may have to be a little patient as the subsystem takes its jolly time caching the fonts. (Don't forget to actually activate the subtitle track! Specify it on the command line or press "j" until the subtitle track you want is activated)

ass=yes
embeddedfonts=yes
fontconfig=yes

Subtitles

If you watch just about everything with subtitles, you probably want to put this in your configuration (sid 0 enables the first subtitle embedded in a video ... including DVD's, by the way. Since 0 is generally the one the subbers think you will want to see the most, this is usually correct. You can also just press "j" until you hit the right track.).

sid=0

Slow computer?

There isn't too much you can do if you're on the wrong side of 1 GHz and trying to H264 with the rest of 'em, but there are a few things you can try (don't try all of them at once, experiment until you're satisfied). lavdopts options can be used in combination, by the way; for example, to combine the first two, use a colon like so: lavdopts="threads=2:fast"

lavdopts="threads=2" # this isn't too useful for some codecs where support
            # hasn't been put in, but if you have more than one usable
            # processor core in your computer you should try this to squeeze the most you can.
lavdopts="fast" # got a huge MPEG2 HD stream going that your poor machine
            # just can't handle?  Enable this, it cuts a few corners.
lavdopts="lowres=1" # decode at a smaller resolution; you get more errors, though
lavdopts="skiploopfilter=all" # drops the loop filter; speeds decoding up, loses some quality
framedrop=yes # drops frames (any filters you use won't waste processing speed)
hardframedrop=yes # drops frames and doesn't bother decoding them, even; causes distorted images!

Video filtering

These are various filters that do various things. Note that they can be used in combination (seperate them with a comma). Note that they have an order, which means you shouldn't do certain things before others (for example, post-processing shouldn't be done before you perform inverse telecine / pullup; that's usually not what you're going for!). This is not an exhaustive list, but rather a few recommendations for typical enjoyable playback. Read the MPlayer documentation for full details; you could conceivably come up with the perfect settings for your own preferences.

If you watch a DVD in MPlayer, you'll probably want to enable some sort of inverse telecine or suffer the consequences as faces turn into venetian blinds. The best one for normal viewing is probably pullup, and is probably best done on the command line (since every single half-competent release group out there makes this unnecessary, you don't need it all the time). For example:

mplayer -vf pullup dvd://2 # On many DVD's, this 

Ever look at a video and go MY BLEEDING EYES, OH THE ARTIFACTS? Even some of the better releases (and an annoying number of DVDs) have this problem, and you're just sensitive to it. Try using the default settings for the postprocessing filter, and play around with some of the settings if you feel like it (or aren't satisfied). Also helps for crappy Youtube-quality videos. Probably (not always) a good to turn this on by default unless you're trying to squeeze the CPU or your job is to ensure there's good quality (you aren't squirming out of that one, do it right).

vf="pp"

Feeling nostalgic for the old days of analog broadcast and film grain? Which means just about anything that wasn't done on computers, which is nearly everything pre-1998 or so. Well, some of us don't appreciate it, but some of us like a little noise. It gives things... texture. At the cost of clarity, of course. You'll probably want to look into blurring things a little first, maybe? (You can also do this to fake restoring something that was originally grainy/noisy; since noise hurts compression, it only makes sense to get rid of it when putting it into MPEG4, after all)

vf="noise=7th:4th" # a comfortably subtle setting, fiddle with it

Opposite feeling? Older cartoons driving you nuts with the grainy cels AND grainy film? Fear not, there are a few options, you'll probably want to experiment and stick to one.

vf="pp=tn" # pp filter's temporal noise reduction; note that this knocks out the defaults for pp.
vf="nr=500" # a noise reduction filter that goes a little easy on the CPU
vf="denoise3d" # makes things smooth
vf="hqdn3d" # higher-quality filter than above, takes more CPU

External links

Personal tools
Namespaces

Variants
Actions
Navigation
Help
Toolbox