# Codecs

## Video codecs

See the codec status table for the complete, daily generated list. Quite a few codecs are available for download from our homepage. Grab them from our codecs page.

The most important ones above all:

- MPEG-1 (VCD) and MPEG-2 (DVD) video

- native decoders for DivX ;-), OpenDivX (DivX4), DivX 5 (Pro), 3ivX, M$ MPEG-4 v1, v2 and other MPEG-4 variants

- native decoder for Windows Media Video 7/8 (WMV1/WMV2), and Win32 DLL decoder for Windows Media Video 9 (WMV3), both used in `.wmv` files

- native Sorenson 1 (SVQ1) decoder

- native Sorenson 3 (SVQ3) decoder

- 3ivx v1, v2 decoder

- Cinepak and Intel Indeo codecs (3.1,3.2,4.1,5.0)

- MJPEG, AVID, VCR2, ASV2 and other hardware formats

- VIVO 1.0, 2.0, I263 and other H.263(+) variants

- FLI/FLC

- RealVideo 1.0 & 2.0 from libavcodec, and RealVideo 3.0 & 4.0 codecs using RealPlayer libraries

- native decoder for HuffYUV

- Various old simple RLE-like formats

If you have a Win32 codec not listed here which is not supported yet, please read the codec importing HOWTO and help us add support for it.

### DivX4/DivX5

This section contains information about the DivX4 and DivX5 codecs of Project Mayo. Their first available alpha version was OpenDivX 4.0 alpha 47 and 48. Support for this was included in MPlayer in the past, and built by default. We also used its postprocessing code to optionally enhance visual quality of MPEG-1/2 movies. Now we use our own, for all file types.

The new generation of this codec is called DivX4 and can even decode movies made with the infamous DivX codec! In addition it is much faster than the native Win32 DivX DLLs but slower than libavcodec. Hence its usage as a decoder is discouraged. However, it is useful for encoding. One disadvantage of this codec is that it is not available under an Open Source license.

DivX4 works in two modes:

`-vc odivx`

  Uses the codec in OpenDivX fashion. In this case it produces YV12 images in its own buffer, and MPlayer does colorspace conversion via libvo. (Fast, recommended!)

`-vc divx4`

  Uses the colorspace conversion of the codec. In this mode you can use YUY2/UYVY, too. (SLOW)

The `-vc odivx` method is usually faster, due to the fact that it transfers image data in YV12 (planar YUV 4:2:0) format, thus requiring much less bandwidth on the bus. For packed YUV modes (YUY2, UYVY) use the `-vc divx4` method. For RGB modes the speed is the same, differing at best according to your current color depth. If your video output driver supports direct rendering, then `-vc divx4` may be faster, or even the fastest solution.

The DivX4/5 binary codec library can be downloaded from avifile or divx.com Unpack it, run `./install.sh` as root and do not forget to add `/usr/local/lib` to your `/etc/ld.so.conf` and running `ldconfig`.

MPlayer autodetects DivX4/DivX5 if it is properly installed, just compile as usual. If it does not detect it, you did not install or configure it correctly.

### FFmpeg/libavcodec

FFmpeg contains an open source codec package, which is capable of decoding streams with various audio and video codecs. It also offers an impressing encoding facility and higher speed than the Win32 codecs or the DivX.com DivX4/5 libraries!

It contains a lot of nice codecs, especially important are the MPEG-4 variants: DivX3, DivX4, DivX5, Windows Media Video 7/8 (WMV1/WMV2). Also a very interesting one is the WMA decoder.

The most recent codec deserving credit is the Sorenson 3 (SVQ3) codec. This is the first, completely opensource implementation. It is even faster than the original. Be sure to prefer this instead of the binary codec!

For a complete list of supported codecs please visit the FFmpeg homepage. Supported video and audio codecs.

Both MPlayer releases and MPlayer from Subversion contain libavcodec so you don't have to care about making a separate libavcodec checkout. Just run `configure` and compile.

With FFmpeg and my Matrox G400, I can view even the highest resolution DivX movies without dropped frames on my K6-2 500.

### XAnim codecs

Be advised that the XAnim binary codecs are packaged with a piece of text claiming to be a legally binding software license which, besides other restrictions, forbids the user to use the codecs in conjunction with any program other than XAnim. However, the XAnim author has yet to bring legal action against anyone for codec-related issues.

INSTALLATION AND USAGE

MPlayer is capable of employing the XAnim codecs for decoding. Follow the instructions to enable them:

- Download the codecs you wish to use from the XAnim site. The 3ivx codec is not there, but at the 3ivx site.

- OR download the codecs pack from our codecs page

- Use the `--with-xanimlibdir` option to tell `configure` where to find the XAnim codecs. By default, it looks for them at `/usr/local/lib/codecs`, `/usr/local/lib/xanim/mods`, `/usr/lib/xanim/mods` and `/usr/lib/xanim`. Alternatively you can set the environment variable `XANIM_MOD_DIR` to the directory of the XAnim codecs.

- Rename/symlink the files, cutting out the architecture stuff, so they will have filenames like these: `vid_cvid.xa`, `vid_h263.xa`, `vid_iv50.xa`

XAnim is video codec family xanim, so you may want to use the `-vfm xanim` option to tell MPlayer to use them if possible.

Tested codecs include: Indeo 3.2, 4.1, 5.0, CVID, 3ivX, H.263.

### VIVO video

MPlayer can play Vivo (1.0 and 2.0) videos. The most suitable codec for 1.0 files is FFmpeg's H.263 decoder, you can use it with the `-vc ffh263` option. For 2.0 files, use the Win32 DLL through the `-vc vivo` option. If you do not supply command line options MPlayer selects the best codec automatically.

### MPEG-1/2 video

MPEG-1 and MPEG-2 are decoded by the multiplatform native libmpeg2 library, whose source code is included in MPlayer. We handle buggy MPEG-1/2 video files by catching Signal 11 (segmentation fault), and quickly reinitializing the codec, continuing exactly from where the failure occurred. This recovery technique has no measurable speed penalty.

### MS Video1, Cinepak CVID, and other older codecs

MPlayer is able to play most of the older codecs used in AVI and MOV files. In the past they were decoded with binary Win32 codecs, but now we have native codecs for most of them using libavcodec.

### RealVideo

MPlayer supports decoding all versions of RealVideo:

- RealVideo 1.0, 2.0 (fourcc RV10, RV20) - en/decoding supported by libavcodec

- RealVideo 3.0, 4.0 (fourcc RV30, RV40) - decoding supported by RealPlayer libraries

Download Real codecs from http://www.mplayerhq.hu/MPlayer/releases/codecs/ and extract them to the `/usr/local/lib/codecs` directory. If you want to store them in a different location, pass the `--with-reallibdir` option to `configure`.

RealPlayer libraries currently only work with Linux, FreeBSD, NetBSD and Cygwin on the x86, Alpha and PowerPC (Linux/Alpha and Linux/PowerPC have been tested) platforms and with Mac OS X.

### XviD

XviD is a free software MPEG-4 ASP compliant video codec, which features two pass encoding and full MPEG-4 ASP support, making it a lot more efficient than the well-known DivX codec. It yields very good video quality and good performance due to CPU optimizations for most modern processors.

It began as a forked development of the OpenDivX codec. This happened when ProjectMayo changed OpenDivX to closed source DivX4 (now DivX5), and the non-ProjectMayo people working on OpenDivX got angry, then started XviD. So both projects have the same origin.

Installing XviD

Like most open source software, it is available in two flavors: official releases and the CVS version. The CVS version is usually stable enough to use, as most of the time it features fixes for bugs that exist in releases. Here is what to do to make XviD CVS work with MEncoder (you need at least autoconf 2.50, automake and libtool):

-     cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid login

-     cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid co xvidcore

-     cd xvidcore/build/generic

-     ./bootstrap.sh

-     ./configure

  You may have to add some options (examine the output of `./configure --help`).

-     make && make install

- If you specified `--enable-divxcompat`, copy `../../src/divx4.h` to `/usr/local/include/`.

- Recompile MPlayer with `--with-xvidlibdir=/path/to/libxvidcore.a` `--with-xvidincdir=/path/to/xvid.h`

### Sorenson

Sorenson is a video codec developed by Sorenson Media and licensed to Apple who distribute it with their QuickTime Player. We are currently able to decode all version of Sorenson video files with the following decoders:

- Sorenson Video v1 (fourcc SVQ1) - decoding supported by native codec (libavcodec)

- Sorenson Video v3 (fourcc SVQ3) - decoding supported by native codec (libavcodec)

COMPILING MPLAYER WITH QUICKTIME LIBRARIES SUPPORT

Currently only 32-bit Intel platforms are supported.

- download MPlayer Subversion

- download QuickTime DLL pack from

- extract QuickTime DLL pack to your Win32 codecs directory (default: `/usr/local/lib/codecs/`)

- compile MPlayer

### x264

#### What is x264?

x264 is a library for creating H.264 video streams. It is not 100% complete, but currently it has at least some kind of support for most of the H.264 features which impact quality. There are also many advanced features in the H.264 specification which have nothing to do with video quality per se; many of these are not yet implemented in x264.

Encoder features

- CAVLC/CABAC

- Multi-references

- Intra: all macroblock types (16x16, 8x8, and 4x4 with all predictions)

- Inter P: all partitions (from 16x16 down to 4x4)

- Inter B: partitions from 16x16 down to 8x8 (including SKIP/DIRECT)

- Ratecontrol: constant quantizer, constant bitrate, single or multipass ABR, optional VBV

- Scene cut detection

- Adaptive B-frame placement

- B-frames as references / arbitrary frame order

- 8x8 and 4x4 adaptive spatial transform

- Lossless mode

- Custom quantization matrices

- Parallel encoding of multiple slices

#### What is H.264?

H.264 is one name for a new digital video codec jointly developed by the ITU and MPEG. It can also be correctly referred to by the cumbersome names of "ISO/IEC 14496-10" or "MPEG-4 Part 10". More frequently, it is referred to as "MPEG-4 AVC" or just "AVC".

Whatever you call it, H.264 may be worth trying because it can typically match the quality of MPEG-4 ASP with 5%-30% less bitrate. Actual results will depend on both the source material and the encoder. The gains from using H.264 do not come for free: Decoding H.264 streams seems to have steep CPU and memory requirements. For instance, on a 1733 MHz Athlon, a DVD-resolution 1500kbps H.264 video requires around 35% CPU to decode. By comparison, decoding a DVD-resolution 1500kbps MPEG-4 ASP stream requires around 10% CPU. This means that decoding high-definition streams is almost out of the question for most users. It also means that even a decent DVD rip may sometimes stutter on processors slower than 2.0 GHz or so.

At least with x264, encoding requirements are not much worse than what you are used to with MPEG-4 ASP. For instance, on a 1733 MHz Athlon a typical DVD encode would run at 5-15fps.

This document is not intended to explain the details of H.264, but if you are interested in a brief overview, you may want to read The H.264/AVC Advanced Video Coding Standard: Overview and Introduction to the Fidelity Range Extensions.

#### How can I play H.264 videos with MPlayer?

MPlayer uses libavcodec's H.264 decoder. libavcodec has had at least minimally usable H.264 decoding since around July 2004, however major changes and improvements have been implemented since that time, both in terms of more functionalities supported and in terms of improved CPU usage. Just to be certain, it is always a good idea to use a recent Subversion checkout.

If you want a quick and easy way to know whether there have been recent changes to libavcodec's H.264 decoding, you might keep an eye on FFmpeg Subversion repository's web interface.

#### How can I encode videos using MEncoder and x264?

If you have the subversion client installed, the latest x264 sources can be gotten with this command:

        svn co svn://svn.videolan.org/x264/trunk x264

MPlayer sources are updated whenever an x264 API change occurs, so it is always suggested to use MPlayer from Subversion as well. Perhaps this situation will change when and if an x264 "release" occurs. Meanwhile, x264 should be considered very unstable, in the sense that its programming interface is subject to change.

x264 is built and installed in the standard way:

        ./configure && make && sudo make install

This installs libx264.a in /usr/local/lib and x264.h is placed in /usr/local/include. With the x264 library and header placed in the standard locations, building MPlayer with x264 support is easy. Just run the standard:

    ./configure && make && sudo make install

The configure script will autodetect that you have satisfied the requirements for x264.

## Audio codecs

The most important audio codecs above all:

- MPEG layer 1/2/3 (MP1/2/3) audio (native code, with MMX/SSE/3DNow! optimization)

- Windows Media Audio 7 and 8 (AKA WMAv1 and WMAv2) (native code, with libavcodec)

- Windows Media Audio 9 (WMAv3) (using DMO DLL)

- AC3 Dolby audio (native code, with MMX/SSE/3DNow! optimization)

- AC3 passing through sound card hardware

- AAC

- Ogg Vorbis audio codec (native library)

- RealAudio: DNET (low bitrate AC3), Cook, Sipro and ATRAC3

- QuickTime: Qualcomm and QDesign audio codecs

- VIVO audio (g723, Vivo Siren)

- Voxware audio (using DirectShow DLL)

- alaw and ulaw, various gsm, adpcm and pcm formats and other simple old audio codecs

- Adaptive Multi-Rate (AMR) speech codecs

### Software AC3 decoding

This is the default decoder used for files with AC3 audio.

The AC3 decoder can create audio output mixes for 2, 4, or 6 speakers. When configured for 6 speakers, this decoder provides separate output of all the AC3 channels to the sound driver, allowing for full "surround sound" experience without the external AC3 decoder required to use the hwac3 codec.

Use the `-channels` option to select the number of output channels. Use `-channels 2` for a stereo downmix. For a 4 channel downmix (Left Front, Right Front, Left Surround and Right Surround outputs), use `-channels 4`. In this case, any center channel will be mixed equally to the front channels. `-channels 6` will output all the AC3 channels as they are encoded - in the order Left, Right, Left Surround, Right Surround, Center and LFE.

The default number of output channels is 2.

To use more than 2 output channels, you will need to use OSS, and have a sound card that supports the appropriate number of output channels via the SNDCTL_DSP_CHANNELS ioctl. An example of a suitable driver is emu10k1 (used by Soundblaster Live! cards) from August 2001 or newer (ALSA CVS is also supposed to work).

### Hardware AC3 decoding

You need an AC3 capable sound card, with digital out (S/PDIF). The card's driver must properly support the AFMT_AC3 format (C-Media does). Connect your AC3 decoder to the S/PDIF output, and use the `-ac hwac3` option. It is experimental but known to work with C-Media cards and Soundblaster Live! + ALSA (but not OSS) drivers and DXR3/Hollywood+ MPEG decoder cards.

### libmad support

libmad is a multiplatform, integer (internally 24bit PCM) only MPEG audio decoding library. It does not handle broken files well, and it sometimes has problems with seeking, but it may perform better on FPU-less (such as ARM) platform than mp3lib.

To enable support, compile with the `--enable-mad` configure option.

### Hardware MPEG audio codec

This codec (selected by -ac hwmpa) passes through MPEG audio packets to hardware decoders, such as the ones found in full-featured DVB cards and DXR2 adapters. Don't use it in combination with any other audio output device (such as OSS and ALSA) that isn't able to decode it (you will hear only white noise).

### VIVO audio

The audio codec used in VIVO files depends on whether it is a VIVO/1.0 or VIVO/2.0 file. VIVO/1.0 files have g.723 audio, and VIVO/2.0 files have Vivo Siren audio. Both are supported.

### RealAudio

MPlayer supports decoding nearly all versions of RealAudio:

- RealAudio DNET - decoding supported by liba52

- RealAudio Cook/Sipro/ATRAC3 - decoding supported by RealPlayer libraries

Instructions on how to install the RealPlayer libraries are in the RealVideo section.

### QDesign codecs

QDesign audio streams (fourcc:QDMC, QDM2) are found in MOV/QT files. Both versions of this codec can be decoded with QuickTime libraries. For installation instructions please see the Sorenson video codec section.

### Qualcomm codecs

Qualcomm audio streams (fourcc:Qclp) is found in MOV/QT files. It can be decoded with QuickTime libraries. For installation instructions please see the Sorenson video codec section.

### AAC codec

AAC (Advanced Audio Coding) is an audio codec sometimes found in MOV and MP4 files. An open source decoder called FAAD is available from . MPlayer includes a CVS snapshot of libfaad 2.1 beta, so you do not need to get it separately.

If you use gcc 3.2 which fails to compile our internal FAAD or want to use the external library for some other reason, download the library from the download page and pass `--enable-external-faad` to `configure`. You do not need all of faad2 to decode AAC files, libfaad is enough. Build it like this:

    cd faad2/
    sh bootstrap
    ./configure
    cd libfaad
    make
    make install

Binaries are not available from audiocoding.com, but you can (apt-)get Debian packages from Christian Marillat's homepage, Mandrake/Mandriva RPMs from the P.L.F and RedHat RPMs from Grey Sector.

### AMR codecs

Adaptive Multi-Rate speech codec is used in third generation (3G) mobile phones. Reference implementation is available from The 3rd Generation Partnership Project (free for private use).

To enable support, download the sources for AMR-NB and AMR-WB codecs, put them in the directory where you unpacked the MPlayer source and run the following commands:

    unzip 26104-610.zip
    unzip 26104-610_ANSI_C_source_code.zip
    mv c-code libavcodec/amr_float
    unzip 26204-600.zip
    unzip 26204-600_ANSI-C_source_code.zip
    mv c-code libavcodec/amrwb_float

After that, follow the usual MPlayer build procedure.

## Win32 codecs importing HOWTO

### VFW codecs

VFW (Video for Windows) is the old Video API for Windows. Its codecs have the `.DLL` or (rarely) `.DRV` extension. If MPlayer fails at playing your AVI with this kind of message:

    UNKNOWN video codec: HFYU (0x55594648)

It means your AVI is encoded with a codec which has the HFYU fourcc (HFYU = HuffYUV codec, DIV3 = DivX Low Motion, etc.). Now that you know this, you have to find out which DLL Windows loads in order to play this file. In our case, the `system.ini` contains this information in a line that reads:

    VIDC.HFYU=huffyuv.dll

So you need the `huffyuv.dll` file. Note that the audio codecs are specified by the MSACM prefix:

    msacm.l3acm=L3codeca.acm

This is the MP3 codec. Now that you have all the necessary information (fourcc, codec file, sample AVI), submit your codec support request by mail, and upload these files to the FTP site: ftp://ftp.mplayerhq.hu/MPlayer/incoming/[codecname]/

On Windows NT/2000/XP search for this info in the registry, e.g. search for "VIDC.HFYU". To find out how to do this, look at the old DirectShow method below.

### DirectShow codecs

DirectShow is the newer Video API, which is even worse than its predecessor. Things are harder with DirectShow, since

- `system.ini` does not contain the needed information, instead it is stored in the registry and

- we need the GUID of the codec.

New Method:

Using Microsoft GraphEdit (fast)

- Get GraphEdit from either DirectX SDK or doom9

- Start `graphedit.exe`.

- From the menu select Graph -> Insert Filters.

- Expand item DirectShow Filters

- Select the right codec name and expand item.

- In the entry DisplayName look at the text in winged brackets after the backslash and write it down (five dash-delimited blocks, the GUID).

- The codec binary is the file specified in the Filename entry.

If there is no Filename and DisplayName contains something like device:dmo, then it is a DMO-Codec.

Old Method:

Take a deep breath and start searching the registry...

- Start `regedit`.

- Press Ctrl+F, disable the first two checkboxes, and enable the third. Type in the fourcc of the codec (e.g. `TM20`).

- You should see a field which contains the path and the filename (e.g. `C:\WINDOWS\SYSTEM\TM20DEC.AX`).

- Now that you have the file, we need the GUID. Try searching again, but now search for the codec's name, not the fourcc. Its name can be acquired when Media Player is playing the file, by checking File -> Properties -> Advanced. If not, you are out of luck. Try guessing (e.g. search for TrueMotion).

- If the GUID is found you should see a FriendlyName and a CLSID field. Write down the 16 byte CLSID, this is the GUID we need.

If searching fails, try enabling all the checkboxes. You may have false hits, but you may get lucky...

Now that you have all the necessary information (fourcc, GUID, codec file, sample AVI), submit your codec support request by mail, and upload these files to the FTP site: ftp://ftp.mplayerhq.hu/MPlayer/incoming/[codecname]/

If you want to add a codec yourself, read DOCS/tech/codecs.conf.txt.