# Installation

A quick installation guide can be found in the `README` file. Please read it first and then come back here for the rest of the gory details.

In this section I'll try to guide you through the compiling and configuring process of MPlayer. It's not easy, but it won't necessarily be hard. If you experience a different behavior than what I explain, please search through this documentation and you'll find your answers. If you see links, please follow them and read carefully what they contain. It will take some time, but it IS worth it.

You need a fairly recent system. On Linux, 2.4.x kernels are recommended.

## Software requirements

- binutils - suggested version is 2.11.x. This program is responsible for generating MMX/ 3DNow!/etc instructions, thus very important.

- gcc - suggested versions are: 2.95.3 (maybe 2.95.4) and 3.2+. Never use 2.96 or 3.0.x! They generate faulty code for MPlayer. If you decide to change gcc from 2.96, then don't decide in favor of 3.x just because it's newer! Early releases of 3.x were even more buggy than 2.96. So downgrade to 2.95.x (downgrade libstdc++ too, other programs may need it) or don't up/downgrade at all (but in this case, be prepared for runtime problems). If you vote for 3.x, try to use the latest version, early releases had various bugs, so be sure you use at least 3.1, it's tested and working. For detailed information about gcc 2.96's bugs (that are still NOT fixed, they have been WORKED AROUND in MPlayer!),see the gcc 2.96 section and the .

- XFree86 - suggested version is always the newest (4.3). Normally, everyone wants this, as starting with XFree86 4.0.2, it contains the XVideo extension (somewhere referred to as Xv) which is needed to enable the hardware YUV acceleration (fast image display) on cards that support it. Make sure its development package is installed, too, otherwise it won't work. For some video cards you don't need XFree86. See list below.

- make - suggested version is always the newest (at least 3.79.x). This usually isn't important.

- SDL - it's not mandatory, but can help in some cases (bad audio, video cards that lag strangely with the xv driver). Always use the newest (beginning from 1.2.x).

- libjpeg - optional JPEG decoder, used by the `-mf` option and some QT MOV files. Useful for both MPlayer and MEncoder if you plan to work with jpeg files.

- libpng - recommended and default (M)PNG decoder. Required for GUI. Useful for both MPlayer and MEncoder.

- lame - recommended, needed for encoding MP3 audio with MEncoder, suggested version is always the newest (at least 3.90).

- zlib - recommended, necessary for compressed MOV header and PNG support.

- libogg - optional, needed for playing OGG file format.

- libvorbis - optional, needed for playing OGG Vorbis audio.

- LIVE.COM Streaming Media - optional, needed for playing RTSP/RTP streams.

- directfb - optional, from . At least 0.9.13 is required.

- cdparanoia - optional, for CDDA support

- libfreetype - optional, for TTF fonts support. At least 2.0.9 is required.

- libxmms - optional, for XMMS input plugin support. At least 1.2.7 is required.

- libsmb - optional, for Samba support.

- ALSA - optional, for ALSA audio output support. At least 0.9.0rc4 is required.

- bio2jack - optional, for JACK audio output support, needed only in compile time. You can obtain it from http://bio2jack.sf.net. Since it doesn't have install option you have to manually put the file `libbio2jack.a` somewhere in your library path (e.g. `/usr/local/lib`) or use the `--with-bio2jack=DIR` switch to tell `./configure` where that file is.

## Codecs

- libavcodec: This codec package is capable of decoding H.263/MJPEG/RV10/DivX3/DivX4/DivX5/MP41/MP42/WMV1/WMV2/SVQ1/SVQ3 encoded video streams and WMA (Windows Media Audio) v1/v2 audio streams, on multiple platforms. It is also known to be the fastest for this task. See FFmpeg section for details. Features:

  - gain decoding of videos mentioned above, on non-x86 machines

  - encoding with most of the mentioned codecs

  - this codec is the fastest codec available for DivX/3/4/5 and other MPEG-4 types. Recommended!

- Win32 codecs: If you plan to use MPlayer on x86 architecture, you will possibly need them. Download a codec package from our codecs page and put the codecs in `/usr/local/lib/codecs` BEFORE compiling MPlayer, otherwise no Win32 support will be compiled!

  The avifile project has similar codecs package, but it differs from ours, so if you want to use all supported codecs, then use our package (do not worry, avifile works with it without problems).

  Features:

  - you need this if you want to play or encode for example movies recorded with various hardware compressors, like tuner cards, digital cameras (example: DV, ATI VCR, MJPEG)

  - needed if you want to play WMV9/WMA9 movies.

  - Not needed for old ASF's with MP41 or MP42 video (though VoxWare audio is frequent for these files - it's done by the Win32 codec), or WMV7. Also not needed for WMA (Windows Media Audio), libavcodec has open source decoder for that.

- QuickTime codecs: on x86 platforms these codecs can be used to decode RPZA, and other QuickTime video, and QDesign audio streams. Installation instructions can be found in the Sorenson video codec section.

- DivX4/DivX5: information about this codec is available in the DivX4/DivX5 section. You possibly don't want this codec as libavcodec (see above) is much faster and has better quality than this, for both decoding and encoding. Features:

  - one pass or two pass encoding with MEncoder

  - can play old DivX3 movies much faster than the Win32 DLL but slower than libavcodec!

  - it's closed-source, and only a x86 version is available.

- XviD: Open source encoding alternative to DivX4Linux. Features:

  - one pass or two pass encoding with MEncoder

  - it's open-source, so it's multiplatform.

  - it's about 2 times faster than divX4 when encoding - about the same quality

- The XAnim codecs are the best (full screen, hardware YUV zoom) for decoding 3ivx and Indeo 3/4/5 movies, and some old formats. And they are multiplatform, so this is the only way to play Indeo on non-x86 platforms (well, apart from using XAnim:). But for example Cinepak movies are best played with MPlayer's own Cinepak decoder!

- For Ogg Vorbis audio decoding you need to install libvorbis properly. You can get binary packages and source code from the Ogg Vorbis site.

- MPlayer can use the libraries of RealPlayer 8 or RealONE to play files with RealVideo 3.0 and 4.0 video, and Sipro/Cook audio. See the RealMedia file format section for installation instructions and more information.

## Video cards

There are generally two kind of video cards. One kind (the newer cards) has hardware scaling and YUV acceleration support, the other cards don't.

### YUV cards

They can display and scale (zoom) the picture to any size that fits in their memory, with small CPU usage (even when zooming), thus fullscreen is nice and very fast.

- Matrox G200/G400/G450/G550 cards: although a Vidix driver is provided, it is recommended to use the mga_vid module instead, for it works much better. Please see the mga_vid section about its installation and usage. It is important to do these steps before compiling MPlayer, otherwise no mga_vid support will be built. Also check out the Matrox TV-out section. If you don't use Linux, your only possibility is the VIDIX driver: read the VIDIX section.

- 3Dfx Voodoo3/Banshee cards: please see tdfxfb section in order to gain big speedup. It is important to do these steps before compiling MPlayer, otherwise no 3Dfx support will be built. Also see the 3dfx TV-out section. If you use X, use at least 4.2.0, as 3dfx Xv driver was broken in 4.1.0, and earlier releases.

- ATI cards: VIDIX driver is provided for the following cards: Radeon, Rage128, Mach64 (Rage XL/Mobility, Xpert98). Also see the ATI cards section of the TV-out documentation, to know if you card's TV-out is supported under Linux/MPlayer.

- S3 cards: the Savage and Virge/DX chips have hardware acceleration. Use as new XFree86 version as possible, older drivers are buggy. Savage chips have problems with YV12 display, see S3 Xv section for details. Older, Trio cards have no, or slow hardware support.

- nVidia cards: may or may not be good choice for video playing. If you do not have a GeForce2 (or newer) card, it's not likely to work without bugs. the built-in nVidia driver in XFree86 does not support hardware YUV acceleration on all nVidia cards. You have to download nVidia's closed-source drivers from nVidia.com. See the nVidia Xv driver section for details. Please also check the nVidia TV-out section if you wish to use a TV.

- 3DLabs GLINT R3 and Permedia3: a VIDIX driver is provided (pm3_vid). Please see the VIDIX section for details.

- Other cards: none of the above?

  - Try if the XFree86 driver (and your card) supports hardware acceleration. See the Xv section for details.

  - If it doesn't, then your card's video features aren't supported under your operating system :( If hardware scaling works under Windows, it doesn't mean it will work under Linux or other operating system, it depends on the drivers. Most manufacturers neither make Linux drivers nor release specifications of their chips - so you are unlucky if using their cards. See .

### Non-YUV cards

Fullscreen playing can be achieved by either enabling software scaling (use the `-zoom` or `-vf` option, but I warn you: this is slow), or switching to a smaller video mode, for example 352x288. If you don't have YUV acceleration, this latter method is recommended. Video mode switching can be enabled by using the `-vm` option and it works with the following drivers:

- using XFree86: see details in DGA driver and X11 driver sections. DGA is recommended! Also try DGA via SDL, sometimes it's better.

- not using XFree86: try the drivers in the following order: vesa, fbdev, svgalib, aalib.

### Cirrus-Logic cards

- GD 7548: present on-board and tested in Compaq Armada 41xx notebook series.

  - XFree86 3: works in 8/16bpp modes. However, the driver is dramatically slow and buggy in 800x600@16bpp. Recommended: 640x480@16bpp

  - XFree86 4: the Xserver freezes soon after start unless acceleration is disabled, but then the whole thing gets slower than XFree86 3. No XVideo.

  - FBdev: framebuffer can be turned on with the clgenfb driver in the kernel, though for me it worked only in 8bpp, thus unusable. The clgenfb source had to be extended with the 7548 ID before compilation.

  - VESA: the card is only VBE 1.2 capable, so VESA output can't be used. Can't be workarounded with UniVBE.

  - SVGAlib: detects an older Cirrus chip. Usable but slow with `-bpp 8`.

## Sound cards

- Soundblaster Live!: with this card you can use 4 or 6 (5.1) channels AC3 decoding instead of 2. Read the Software AC3 decoding section. For hardware AC3 passthrough you must use ALSA 0.9 with OSS emulation!

- C-Media with S/PDIF out: hardware AC3 passthrough is possible with these cards, see Hardware AC3 decoding section.

- Features of other cards aren't supported by MPlayer. It's very recommended to read the sound card section!

## Features

- Decide if you need GUI. If you do, see the GUI section before compiling.

- If you want to install MEncoder (our great all-purpose encoder), see the MEncoder section.

- If you have a V4L compatible TV tuner card, and wish to watch/grab and encode movies with MPlayer, read the TV input section.

- There is a neat OSD Menu support ready to be used. Check the OSD menu section.

Then build MPlayer:

    ./configure
    make
    make install

At this point, MPlayer is ready to use. The directory `$PREFIX/share/mplayer` contains the `codecs.conf` file, which is used to tell the program all the codecs and their capabilities. This file is needed only when you want to change its properties, as the main binary contains an internal copy of it. Check if you have `codecs.conf` in your home directory (`~/.mplayer/codecs.conf`) left from old MPlayer versions, and remove it.

Note that if you have a `codecs.conf` in `~/.mplayer/`, the builtin and system `codecs.conf` will be ignored completely. Do not do this unless you want to fiddle with MPlayer internals as this can can cause many problems. If you want to change the codecs search order, use the `-vc`, `-ac`, `-vfm`, or `-afm` options either on the command line or in your config file (see the manual page).

Debian users can build a .deb package for themselves, it's very simple. Just exec

    fakeroot debian/rules binary

in MPlayer's root directory. See Debian packaging for detailed instructions.

Always browse the output of `./configure`, and the `configure.log` file, they contain information about what will be built, and what will not. You may also want to view `config.h` and `config.mak` files. If you have some libraries installed, but not detected by `./configure`, then check if you also have the proper header files (usually the -dev packages) and their version matches. The `configure.log` file usually tells you what is missing.

Though not mandatory, the fonts should be installed in order to gain OSD, and subtitle functionality. The recommended method is installing a TTF font file and telling MPlayer to use it. See the Subtitles and OSD section for details.

# What about the GUI?

The GUI needs GTK 1.2.x (it isn't fully GTK, but the panels are). The skins are stored in PNG format, so GTK, libpng (and their devel stuff, usually called gtk-dev and libpng-dev) has to be installed. You can build it by specifying `--enable-gui` during `./configure`. Then, to turn on GUI mode, you have to execute the `gmplayer` binary.

Currently you can't use the `-gui` option on the command line, due to technical reasons.

As MPlayer doesn't have a skin included, you have to download them if you want to use the GUI. See the download page. They should be extracted to the usual system-wide directory (`$PREFIX/share/mplayer/Skin`), or to `$HOME/.mplayer/Skin`. MPlayer by default looks in these directories for a directory named `default`, but you can use the `-skin newskin` option, or the `skin=newskin` config file directive to use the skin in `*/Skin/newskin` directory.

# Subtitles and OSD

MPlayer can display subtitles along with movie files. Currently the following formats are supported:

- VOBsub

- OGM

- CC (closed caption)

- MicroDVD

- SubRip

- SubViewer

- Sami

- VPlayer

- RT

- SSA

- PJS (Phoenix Japanimation Society)

- MPsub

- AQTitle

- JACOsub

MPlayer can dump the previously listed subtitle formats (except the three first) into the following destination formats, with the given options:

- MPsub: `-dumpmpsub`

- SubRip: `-dumpsrtsub`

- MicroDVD: `-dumpmicrodvdsub`

- JACOsub: `-dumpjacosub`

- Sami: `-dumpsami`

MEncoder can dump DVD subtitles into VOBsub format.

The command line options differ slightly for the different formats:

## VOBsub subtitles

VOBsub subtitles consist of a big (some megabytes) `.SUB` file, and optional `.IDX` and/or `.IFO` files. If you have files like `sample.sub`, `sample.ifo` (optional), `sample.idx` - you have to pass MPlayer the `-vobsub sample [-vobsubid id]` options (full path optional). The `-vobsubid` option is like `-sid` for DVDs, you can choose between subtitle tracks (languages) with it. In case that `-vobsubid` is omitted, MPLayer will try to use the languages given by the `-slang` option and fall back to the langidx in the `.IDX` file to set the subtitle language. If it fails, there will be no subtitles.

## Other subtitles

The other formats consist of a single text file containing timing, placement and text information. Usage: If you have a file like `sample.txt`, you have to pass the option `-sub sample.txt` (full path optional).

## Adjusting subtitle timing and placement:

`-subdelay sec`

  Delays subtitles by `sec` seconds. Can be negative. The value is added to movie's time position counter.

`-subfps RATE`

  Specify frame/sec rate of subtitle file (float number).

`-subpos 0-100`

  Specify the position of subtitles.

If you experience a growing delay between the movie and the subtitles when using a MicroDVD subtitle file, most likely the frame rate of the movie and the subtitle file are different. Please note that the MicroDVD subtitle format uses absolute frame numbers for its timing, but there is no fps information in it, and therefore the `-subfps` option should be used with this format. If you like to solve this problem permanently, you have to manually convert the subtitle file framerate. MPlayer can do this conversion for you:

    mplayer -dumpmicrodvdsub -fps subtitles_fps -subfps avi_fps -sub subtitle_filename dummy.avi

About DVD subtitles, read the DVD section.

## MPlayer's own subtitle format (MPsub)

MPlayer introduces a new subtitle format called MPsub. It was designed by Gabucino. Basically its main feature is being dynamically time-based (although it has frame-based mode too). Example (from DOCS/tech/mpsub.sub):

    FORMAT=TIME
    # first number  : wait this much after previous subtitle disappeared
    # second number : display the current subtitle for this many seconds

    15 3
    A long long, time ago...

    0 3
    in a galaxy far away...

    0 3
    Naboo was under an attack.

So you see, the main goal was to make subtitle editing/timing/joining/cutting easy. And, if you - say - get an SSA subtitle but it's badly timed/delayed to your version of the movie, you simply do a

    mplayer dummy.avi -sub source.ssa -dumpmpsub

A `dump.mpsub` file will be created in the current directory, which will contain the source subtitle's text, but in MPsub format. Then you can freely add/subtract seconds to/from the subtitle.

Subtitles are displayed with a technique called 'OSD', On Screen Display. OSD is used to display current time, volume bar, seek bar etc.

## Installing OSD and subtitles

You need an MPlayer font package to be able to use OSD/SUB feature. There are many ways to get it:

- Use the font generator tool at `TOOLS/subfont-c`. It's a complete tool to convert from TTF/Type1/etc font to mplayer font pkg (read `TOOLS/subfont-c/README` for details).

- Use the font generator GIMP plugin at `TOOLS/subfont-GIMP` (note: you must have HSI RAW plugin too, see ).

- using a TrueType (TTF) font, by the means of the freetype library. Version 2.0.9 or greater is mandatory! Then you have two methods:

  - use the `-font /path/to/sample_font.ttf` option to specify a TrueType font file on every occasion

  - create a symlink:

        ln -s /path/to/sample_font.ttf ~/.mplayer/subfont.ttf

  If MPlayer was compiled with fontconfig support, the above methods won't work, instead the `-font` expects a fontconfig font name and defaults to the sans-serif font. To get a list of fonts known to fontconfig, use `fc-list`. Example: `-font 'Bitstream Vera Sans'`

- Download ready-to-use font packages from MPlayer site. Note: currently available fonts are limited for ISO 8859-1/2 support, but there are some other (including Korean, Russian, ISO 8859-8 etc) fonts at contrib/font section of FTP, made by users.

  Font should have appropriate `font.desc` file which maps unicode font positions to the actual code page of the subtitles text. Other solution is to have subtitles encoded in UTF-8 encoding and use `-utf8` option or just name the subtitles file `<video_name>.utf` and have it in the same dir as the video file. Recoding from different codepages to UTF-8 could be done by using `konwert` or `iconv` programs.

  ### Some URLs

  URL | Comment
  --- | ---
  | ISO fonts
  | various fonts by users
  | Korean fonts and RAW plugin

If you chose non-TTF fonts, UNZIP the file you downloaded to `~/.mplayer` or `$PREFIX/share/mplayer`. Then rename or symlink one of the extracted directories to `font`, for example:

    ln -s ~/.mplayer/arial-24 ~/.mplayer/font

Now you have to see a timer at the upper left corner of the movie (switch it off with the o key).

(subtitles are always enabled, for disabling them please read the man page)

OSD has 4 states (switch with o):

1. volume bar + seek bar (default)

2. volume bar + seek bar + timer + file position percentage on seeking

3. volume bar + seek bar + timer + total duration of the media

4. subtitles only

You can change default behaviour by setting `osdlevel` variable in config file, or the `-osdlevel` command line option.

## OSD menu

MPlayer has a completely user definiable OSD Menu interface.

the Preferences menu is currently UNIMPLEMENTED!

### Installation

1. compile MPlayer by passing the `--enable-menu` to `./configure`

2. make sure you have an OSD font installed

3. copy `etc/menu.conf` to your `.mplayer` directory

4. copy `etc/input.conf` to your `.mplayer` directory, or to the system-wide MPlayer config dir (default: `/usr/local/etc/mplayer`)

5. check and edit `input.conf` to enable menu movement keys (it is described there).

6. start MPlayer by the following example:

       $ mplayer -menu file.avi

7. push any menu key you defined

# RTC

There are three timing methods in MPlayer.

- To use the old method, you don't have to do anything. It uses usleep() to tune A/V sync, with +/- 10ms accuracy. However sometimes the sync has to be tuned even finer.

- The new timer code uses the RTC (RealTime Clock) for this task, because it has precise 1ms timers. It is automagically enabled when available, but requires root privileges, a setuid root MPlayer binary or a properly set up kernel. If you are running kernel 2.4.19pre8 or later you can adjust the maximum RTC frequency for normal users through the /proc filesystem. Use this command to enable RTC for normal users:

      echo 1024 > /proc/sys/dev/rtc/max-user-freq

  If you do not have such a new kernel, you can also change one line in `drivers/char/rtc.c` and recompile your kernel. Find the section that reads

             * We don't really want Joe User enabling more
             * than 64Hz of interrupts on a multi-user machine.
             */
            if ((rtc_freq > 64) && (!capable(CAP_SYS_RESOURCE)))

  and change the 64 to 1024. You should really know what you are doing, though. You can see the new timer's efficiency in the status line. The power management functions of some notebook BIOSes with speedstep CPUs interact badly with RTC. Audio and video may get out of sync. Plugging the external power connector in before you power up your notebook seems to help. You can always turn off RTC support with the `-nortc` option. In some hardware combinations (confirmed during usage of non-DMA DVD drive on an ALi1541 board) usage of the RTC timer causes skippy playback. It's recommended to use the third method in these cases.

- The third timer code is turned on with the `-softsleep` option. It has the efficiency of the RTC, but it doesn't use RTC. On the other hand, it requires more CPU.

NEVER install a setuid root MPlayer binary on a multiuser system! It's a clear way for everyone to become root.