# MPlayer

MPlayer is a multi-platform media player. It handles many file formats, and can play CDs, VCDs and DVDs. MPlayer also includes Mencoder which is a powerful video conversion program. Both MPlayer and Mencoder can be used from the command line (shell). MPlayer has one official graphical interface (GMplayer), however there are several third party graphic interfaces that allow access to some of Mencoder's functionality.

### Installing MPlayer

There are three components to MPlayer: MPlayer itself, GMplayer (the graphical interface), and Mencoder (the video conversion utility). You may need to install each individually if they are not packaged together.
Something else that you may find necessary are external codecs for video file formats not natively supported by MPlayer.
MPlayer packages can be obtained through your linux distributions software manager (RPM DEB etc) or from the MPlayer website http://www.mplayerhq.hu/ which also contains versions for other operating systems (Windows, Apple, Amiga) as well as extra codecs you may require.
Functionality of MPlayer in Windows is very similar to Linux.

### Starting MPlayer & Playing Files

At its simplest, MPlayer can be started from the command line; executable followed by the video file you wish to view:
You may find, if your MPlayer executable is not in your path, you'll have to specify its location:
or
as an example.
GUI:
When you start GMplayer, two windows will open:
* A viewing window - this is where videos / dvds will play.
* A control window - this is where you can use the most common commands in MPlayer.
To play a file, right-click in the viewing window, click on 'Open', and then 'Play file'. A file choosing dialog should then open. It is important to note that the file format filter at the bottom of the dialog is, by default, set to 'Video files'. This means that if you want to play an audio (sound) file, it will not be displayed in the dialog. To view audio files, click on the down arrow on the left hand side of the file format filter box, and choose 'All files'. Select a file, and click on OK. The file should start playing immediately.
Windows command line (no GUI):
Easiest way is to get the basic MPlayer package and codecs from the main MPlayer site (nothing with GUI in the name). Extract all the required files to a directory of your choosing. From there, right click on the video you'd like to watch, and choose 'Open with' and choose other. Browse for your new mplayer directory you created and check "Always use this program" to make it work via double-click.
If you experience problems, just launch mplayer via Windows CMD to get good feedback as to what the trouble is. Dragging and dropping files into a windows command line will print the name, to avoid having to type names/directories. This works with every functionality of mplayer.
(adjust content locations and continue cleanup from here -- kokushibyou).
This shows a file that starts properly; there are some errors (no subtitle fonts, which is easily fixed if required) and other interesting feedback you might be interested in.
(and movie launches in its own window, with the cmd window in the background).

### Playing CDs, DVDs and VCDs

GMplayer's menus allow access to your CD/DVD drive for playing most on disk video files. On the command prompt you can simply refer to the DVD:// device or if you have an image of a disk on your hard drive you can use the BIN:// or ISO:// devices. A win32 example is mplayer -dvd-device e: dvd://1 (for title 1).
If the disk does not play, then the system may not have a CDDA extractor such as cdparanoia, or MPlayer was not compiled from source with the correct option enabled. The CDDA extractor is only needed at compile time.

### Codecs

In most cases mplayer will automatically recognize the video's format and the environment it is running in. It will then show the video as best it can. If you are running a graphical interface (XWindow, MS Windows) you may wish to start MPlayer's GUI. This can also be started at a command line or from your desktop's "Run file" option or via its menu system. In all cases above the command is; gmplayer.
If you start running into issues with trying to determine why video/sound isn't working, try a few of the following things:
* Try running mplayer command-line only - your prompt will usually output good information about errors.
* Be sure you have the full codec pack from http://www.mplayerhq.hu ; or any other codec packs that aren't included there (pretty much everything you'd ever need is already available on their site).

### While Watching

Keyboard shortcuts for MPlayer include:
* q = quit
* r = sub position -
* t = sub position +y
* T = enable/disable stay on top mode
* y = sub delay reset to 0
* o/O = toggle on-screen display (enabled, disabled, time lapsed, time lapsed/remaining)
* p = play/pause
* [ = speed -10%
* ] = speed +10%
* { = speed x 1/2
* } = speed x 2
* a = sub alignment
* d = toggle framedropping (on, hard, off)
* f = toggle full-screen
* j = toggle subtitle (off, language 1, language 2, etc...)
* l = load file to playlist (GUI only)
* z = sub delay -
* x = sub delay +
* c = skin browser
* v = enable/disable subtitles
* b = toggle subtitle (off, language 1, language 2, etc...)
* m = mute on/off
* / = volume down,
* 0 = play
* . = frame advance
* 1 = contrast -
* 2 = contrast +
* 3 = brightness -
* 4 = brightness +
* 5 = tint - (green)
* 6 = tint + (red)
* 7 = color -
* 8 = color +
* / = volume -
* * = volume +
* - = audio-video delay -
* + = audio-video delay +
* up = forward 1 minute
* down = back 1 minute
* left = rewind
* right = fast forward
* home = beginning
* end = end
* pg up = forward 10 mins
* pg dn = back 10 mins
* # = toggle audio

### OSD Menu

Mplayer has a freely configurable OSD menu. Unfortunately it is not well documented (or rather, not at all...). The following is an example menu.conf (to be put in ~/.mplayer on GNU/Linux systems):
To enable it you must include something like the following keybinding in the 'input.conf' file in the same directory as 'menu.conf':
'm' can be any key (or mouse button (i.e MOUSE_BTN2)). Then start mplayer with the -menu switch (alternatively you can put menu=yes in the 'config' file.

### Preferences
## Mencoder

MEncoder is a command line video decoding, encoding and filtering tool that is included with most MPlayer packages. It is a close sibling to MPlayer and can convert all the formats that MPlayer understands into a variety of compressed and uncompressed formats using different codecs.

### Capabilities

As it is built from the same code as MPlayer, it can read from every source which MPlayer can read, decode all media which MPlayer can decode and it supports all filters which MPlayer can use. MPlayer can also be used to view the output of most of the filters (or of a whole pipeline of filters) before running MEncoder. If the system is not able to process this in realtime, audio can be disabled using -nosound to allow a smooth review of the video filtering results.
It is also possible to copy audio and/or video unmodified into the output file to avoid quality loss because of re-encoding for example, to only modify the audio or video, or to simply put the audio/video data unmodified into a different container format.
Since it uses the same code as MPlayer, it also features the same huge number of highly-configurable video and audio filters to transform the video and audio stream: Filters include Cropping, Scaling, Vertical Flipping, horizontal mirroring, expanding to create letterboxes, rotating, brightness/contrast, changing the aspect ratio of a video, colorspace conversion, hue/saturation, color-specific Gamma correction, filters for reducting the visibility of compression artifacts caused by MPEG compression (deblocking, deringing), automatic brightness/contrast enhancement (autolevel), sharpness/blur, denoising filters, several different ways of de-interlacing, and reversing telecine.

### Frame rate conversions and slow-motion

Also, changing the frame rate is possible using the -ofps or -speed options and, in addition, by using the framestep filter for skipping frames. Reducing the frame rate can be used to create fast-motion "speed" effects which are sometimes seen in films.
Doubling the frame rate of interlaced footage without duplicating or morphing frames is possible using the tfields filter to create two different frames from each of the two fields in one frame of interlaced video. This allows playback on progressive displays, while preserving the full resolution and framerate of interlaced video, unlike any de-interlacing method. It also makes the footage more usable for framerate conversion, and creating slow-motion scenes from footage taken at standard video/TV frame rates, e.g. using cheap consumer camcorders. If the filter gets wrong information about the top/bottom field order, the resulting output video will have juddering motion, because the two frames created would be displayed in the wrong order.

### Common tasks
#### Create an animation from a series of static images

To combine all png images in a directory to create an avi movie do this:

#### Split a video in a series of static images

To split up an input movie into a subdir "dirname" with a special quality.

#### Join/Merge multiple videos

To join two or more video files into one, do this:
This will only work if the video contained in the files have the same resolution and use the same codec. Of course, this works for any file format that MPlayer can play, not just AVI files. If your files are not AVI files you have to specify the output format -of. Otherwise your joined mpeg movies will reside in an AVI container. This is because AVI is the default output format. (To see the available output formats, type mencoder -of help.)

#### Rip DVD to raw video

mplayer can make quite accurate "raw stream" DVD rips, ex (saves DVD track 1 to file dvdout.mpg):
If you're on windows, you may need to replace "mplayer", above, with something like "C:\Program Files (x86)\MPlayer for WindowsUI\mplayer\mplayer.exe" to get it to work. (In this example, running from an installation of Mulder's Mplayer for Windows). Your paths may be different.
If you're on mac, and have downloaded something like mplayerx and installed it to your Applications folder, then "mplayer" above might look something like "/Applications/MPlayerX.app/Contents/Resources/binaries/m32/mplayer" or the like. Or if you installed mplayer via macports then /opt/local/bin/mplayer
Mencoder can also rip raw video streams from dvd
Though mencoder seems to have a bug that it sometimes will leave off say 20 minutes at the end of the title.
Another option might be dvd://2 instead of dvdnav://2 -nocache, though dvdnav -nocache is said to compatible with more DVD's.
NB that the mpeg is a real "raw" rip which means that its indexes might be messed up, if it comes from a DVD that resets the MPEG TS timestamps half-way through (many do, typically at about the hour mark). You can run mencoder -idx on the file to fix them up. If they're broken then seeking may behave oddly for absolute seeking/EDL's.

#### Rip DVD into quality compressed avi

To perform a two-pass encode of the second title on a DVD to an MPEG-4 AVI while copying the audio track, execute these two commands in this order:
The first pass creates some temporary files (having names ending with .log) with a size of few megabytes. Do not delete these temporary files between the two passes. In the second pass, the output file is created using the bitrate data from the temporary file. The resulting file will have much better image quality than a one-pass encoding would produce, since the extra step allows for more bitrate for those moments that need it and less for those that don't in order to keep a stable quality level as opposed to having a stable bitrate, and while still keeping the desired average bitrate.
For subtitles, use the -slang (for example, to have English subtitles along with the video do -slang en) or -sid (eg. -sid 0) switch. When more than one language is used for dialogue subtitles may appear for all dialogue including the primary language. −forcedsubsonly may, depending on how the DVD was authored, because only dialogue that is not in the primary language to be subtitled. e.g. In a movie with both english and german dialogue with the primary language being english, using -forcedsubsonly may stop english dialogue being subtitled as well as german.
For changing the audio (such is the case in Canada where videos are often available in French and English) specify the -alang or -switch (eg. -alang en)
You may also want to use dvdnav:// -nocache for newer dvd's

#### Split/sub-section videos

You can use the -ss and -endpos parameters to specify start and end point, but it can only start on the nearest keyframe. So, depending on how frequently keyframes were placed into the video, the actual start time may be as much as 10 seconds off (mp4) or 0.5s off (MPEG-2 [dvd's] an i-frame occurs at least every 15 frames, or 0.5 seconds). The stop time will be relative to the adjusted start time
Example: note the mb suffix in the -endpos switch:
Suppose you want to split video_input.avi such that you skip "approximately" the first 3.2 seconds and will take the next 2 seconds of video (until "approximately" second 5.2)
In general
This copy part of video_input.avi to video_output.avi. Part start from -ss time and stops to -endpos time. Those time could also be megabytes with mb-postfix.
If your audio/video codecs support exact positioning (e.g. a full-frame codec like MJPEG, huffyuv, regular PCM for audio, etc.), mencoder is able to losslessly cut an audio/video container into segments.
You could also first re-encode your stream with a "keyint" setting of 1, which would make every frame an i-frame, and thus make it subsequently support exact positioning.
If your stream supports exact positioning, the following command could then be used for losslessly cutting a video in 1-minute segments:
Also note that the -hr-edl-seek option might help it be more accurate with certain streams, see http://betterlogic.com/roger/2011/06/mplayer-hr-edl-seek.

#### Convert FLV to AVI

You can use mencoder to convert FLV files from sites like YouTube and Google Video to AVI with mencoder.

#### Using filters
##### Increase or decrease gamma, contrast , brightness, saturation

where gamma 0.1 - 10 (default 1.0), contrast -2 − 2 (default 1.0), brightness -1 - 1 (default 0.0), saturation 0 − 3 (default 1.0),

## see also

* MPlayer/sharpen video filter