1 <?xml version="1.0" encoding="utf-8"?>
6 <sect1 id="video-codecs">
7 <title>Video codecs</title>
10 The <ulink url="../../codecs-status.html">codec status table</ulink> is a
11 complete list of all supported codecs, regenerated daily.
12 Some binary codecs for use with MPlayer are available in the
13 <ulink url="http://www.mplayerhq.hu/design7/dload.html#binary_codecs">download section</ulink>
18 The most important ones above all:
23 <emphasis role="bold">MPEG-1</emphasis> (<emphasis role="bold">VCD</emphasis>) and
24 <emphasis role="bold">MPEG-2</emphasis> (<emphasis role="bold">DVD</emphasis>) video
27 native decoders for <emphasis role="bold">all DivX variants,
28 3ivX, Microsoft MPEG-4</emphasis> v1, v2 and other MPEG-4 variants
31 native decoder for <emphasis role="bold">Windows Media Video 7/8</emphasis>
32 (<emphasis role="bold">WMV1/WMV2</emphasis>), and Win32 DLL decoder
33 for <emphasis role="bold">Windows Media Video 9</emphasis>
34 (<emphasis role="bold">WMV3</emphasis>),
35 both used in <filename>.wmv</filename> files
38 native <emphasis role="bold">Sorenson 1 (SVQ1)</emphasis> decoder
41 native <emphasis role="bold">Sorenson 3 (SVQ3)</emphasis> decoder
44 <emphasis role="bold">3ivx</emphasis> v1, v2 decoder
47 Cinepak and <emphasis role="bold">Intel Indeo</emphasis> codecs
51 <emphasis role="bold">MJPEG</emphasis>, AVID, VCR2, ASV2 and other hardware
55 VIVO 1.0, 2.0, I263 and other <emphasis role="bold">H.263(+)</emphasis>
62 <emphasis role="bold">RealVideo 1.0 & 2.0</emphasis> from
63 <systemitem class="library">libavcodec</systemitem>, and
64 <emphasis role="bold">RealVideo 3.0 & 4.0</emphasis> codecs using
68 native decoder for HuffYUV
71 Various old simple RLE-like formats
76 If you have a Win32 codec not listed here which is not supported yet,
77 please read the <link linkend="codec-importing">codec importing HOWTO</link>
78 and help us add support for it.
83 <sect2 id="ffmpeg" xreflabel="FFmpeg/libavcodec">
84 <title>FFmpeg/libavcodec</title>
87 <ulink url="http://ffmpeg.org">FFmpeg</ulink> contains
88 <systemitem class="library">libavcodec</systemitem>, the leading
89 open source video and audio codec library. It is capable
90 of decoding most multimedia formats, usually at higher speeds
91 than the alternatives, and aims to add support for
92 the rest of them eventually. It is the default decoder for
93 the majority of codecs that <application>MPlayer</application>
94 supports. Encoding is also possible for some formats and
95 supported in <application>MEncoder</application>.
99 For a complete list of supported
100 <ulink url="http://ffmpeg.org/ffmpeg-doc.html#SEC19">video</ulink>
101 and <ulink url="http://ffmpeg.org/ffmpeg-doc.html#SEC20">audio</ulink>
102 codecs please visit the FFmpeg homepage.
106 <application>MPlayer</application> contains
107 <systemitem class="library">libavcodec</systemitem>.
108 Just run <filename>./configure</filename> and compile.
118 <ulink url="http://www.xvid.org">Xvid</ulink> is a free software MPEG-4 ASP
119 compliant video codec, which features two pass encoding and full MPEG-4 ASP
120 support, making it a lot more efficient than the well-known DivX codec.
121 It yields very good video quality and good performance due to CPU
122 optimizations for most modern processors.
126 It began as a forked development of the OpenDivX codec.
127 This happened when ProjectMayo changed OpenDivX to closed source
128 DivX4, and the non-ProjectMayo people working on OpenDivX got angry,
129 then started Xvid. So both projects have the same origin.
133 Note that Xvid is not necessary to decode Xvid-encoded video.
134 <systemitem class="library">libavcodec</systemitem> is used by
135 default as it offers better speed.
139 <title>Installing <systemitem class="library">Xvid</systemitem></title>
141 Like most open source software, it is available in two flavors:
142 <ulink url="http://www.xvid.org/downloads.html">official releases</ulink>
144 The CVS version is usually stable enough to use, as most of the time it
145 features fixes for bugs that exist in releases.
146 Here is what to do to make <systemitem class="library">Xvid</systemitem>
147 CVS work with <application>MEncoder</application> (you need at least
148 <application>autoconf</application> 2.50,
149 <application>automake</application> and <application>libtool</application>):
152 <screen>cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid login</screen>
155 <screen>cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid co xvidcore</screen>
158 <screen>cd xvidcore/build/generic</screen>
161 <screen>./bootstrap.sh</screen>
164 <screen>./configure</screen>
165 You may have to add some options (examine the output of
166 <command>./configure --help</command>).
169 <screen>make && make install</screen>
172 If you specified <option>--enable-divxcompat</option>,
173 copy <filename>../../src/divx4.h</filename> to
174 <filename class="directory">/usr/local/include/</filename>.
177 Recompile <application>MPlayer</application> with
178 <option>--with-xvidlibdir=<replaceable>/path/to/</replaceable>libxvidcore.a</option>
179 <option>--with-xvidincdir=<replaceable>/path/to/</replaceable>xvid.h</option>.
186 <sect2 id="codec-x264">
187 <title><systemitem class="library">x264</systemitem></title>
189 <sect3 id="codec-x264-whatis">
190 <title>What is <systemitem class="library">x264</systemitem>?</title>
193 <ulink url="http://developers.videolan.org/x264.html"><systemitem class="library">x264</systemitem></ulink>
194 is a library for creating H.264 video streams.
195 It is not 100% complete, but supports most of H.264's features which impact
197 There are also many advanced features in the H.264 specification
198 which have nothing to do with video quality per se; many of these
199 are not yet implemented in <systemitem class="library">x264</systemitem>.
203 <title>Encoder features</title>
204 <listitem><para>CAVLC/CABAC</para></listitem>
205 <listitem><para>Multi-references</para></listitem>
207 Intra: all macroblock types (16x16, 8x8, and 4x4 with all predictions)
210 Inter P: all partitions (from 16x16 down to 4x4)
213 Inter B: partitions from 16x16 down to 8x8 (including SKIP/DIRECT)
216 Ratecontrol: constant quantizer, constant bitrate, single or multipass ABR,
219 <listitem><para>Scene cut detection</para></listitem>
220 <listitem><para>Adaptive B-frame placement</para></listitem>
222 B-frames as references / arbitrary frame order
224 <listitem><para>8x8 and 4x4 adaptive spatial transform</para></listitem>
225 <listitem><para>Lossless mode</para></listitem>
226 <listitem><para>Custom quantization matrices</para></listitem>
227 <listitem><para>Parallel encoding of multiple slices</para></listitem>
228 <listitem><para>Interlacing</para></listitem>
233 <sect3 id="codec-h264-whatis">
234 <title>What is H.264?</title>
237 H.264 is one name for a new digital video codec jointly developed
239 It can also be correctly referred to by the cumbersome names of
240 "ISO/IEC 14496-10" or "MPEG-4 Part 10".
241 More frequently, it is referred to as "MPEG-4 AVC" or just "AVC".
245 Whatever you call it, H.264 may be worth trying because it can typically match
246 the quality of MPEG-4 ASP with 5%-30% less bitrate.
247 Actual results will depend on both the source material and the encoder.
248 The gains from using H.264 do not come for free: Decoding H.264
249 streams seems to have steep CPU and memory requirements.
250 For instance, on a 1733 MHz Athlon, a DVD-resolution 1500kbps H.264
251 video requires around 35% CPU to decode.
252 By comparison, decoding a DVD-resolution 1500kbps MPEG-4 ASP stream
253 requires around 10% CPU.
254 This means that decoding high-definition streams is almost out of
255 the question for most users.
256 It also means that even a decent DVD rip may sometimes stutter on
257 processors slower than 2.0 GHz or so.
261 At least with <systemitem class="library">x264</systemitem>,
262 encoding requirements are not much worse than what you are used to
264 For instance, on a 1733 MHz Athlon a typical DVD encode would run
269 This document is not intended to explain the details of H.264,
270 but if you are interested in a brief overview, you may want to read
271 <ulink url="http://www.cdt.luth.se/~peppar/kurs/smd151/spie04-h264OverviewPaper.pdf">The H.264/AVC Advanced Video Coding Standard: Overview and Introduction to the Fidelity Range Extensions</ulink>.
276 <sect3 id="codec-x264-playback">
277 <title>How can I play H.264 videos with
278 <application>MPlayer</application>?</title>
281 <application>MPlayer</application> uses
282 <systemitem class="library">libavcodec</systemitem>'s H.264 decoder.
283 <systemitem class="library">libavcodec</systemitem> has had at
284 least minimally usable H.264 decoding since around July 2004,
285 however major changes and improvements have been implemented since
286 that time, both in terms of more functionalities supported and in
287 terms of improved CPU usage.
288 Just to be certain, it is always a good idea to use a recent Subversion
293 If you want a quick and easy way to know whether there have been
294 recent changes to <systemitem class="library">libavcodec</systemitem>'s
295 H.264 decoding, you might keep an eye on
296 <ulink url="http://svn.mplayerhq.hu/ffmpeg/trunk/libavcodec/h264.c?view=log">FFmpeg Subversion repository's web interface</ulink>.
301 <sect3 id="codec-x264-encode">
302 <title>How can I encode videos using <application>MEncoder</application>
303 and <systemitem class="library">x264</systemitem>?</title>
306 If you have the GIT client installed, the latest x264
307 sources can be gotten with this command:
308 <screen>git clone git://git.videolan.org/x264.git</screen>
309 <application>MPlayer</application> sources are updated whenever
310 an <systemitem class="library">x264</systemitem> API change
311 occurs, so it is always suggested to use
312 <application>MPlayer</application> from Subversion as well.
313 Perhaps this situation will change when and if an
314 <systemitem class="library">x264</systemitem> "release" occurs.
315 Meanwhile, <systemitem class="library">x264</systemitem> should
316 be considered a bit unstable, in the sense that its programming
317 interface is subject to change.
321 <systemitem class="library">x264</systemitem> is built and
322 installed in the standard way:
323 <screen>./configure && make && sudo make install</screen>
324 This installs libx264.a in /usr/local/lib and x264.h is placed in
327 With the <systemitem class="library">x264</systemitem> library
328 and header placed in the standard locations, building
329 <application>MPlayer</application> with
330 <systemitem class="library">x264</systemitem> support is easy.
331 Just run the standard:
332 <screen>./configure && make && sudo make install</screen>
333 The <filename>./configure</filename> script will autodetect that you have
334 satisfied the requirements for <systemitem class="library">x264</systemitem>.
341 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
344 <sect1 id="audio-codecs">
345 <title>Audio codecs</title>
348 <title>The most important audio codecs above all:</title>
350 MPEG layer 1/2/3 (MP1/2/3) audio (<emphasis role="bold">native</emphasis>
351 code, with MMX/SSE/3DNow! optimization)
354 Windows Media Audio 7 and 8 (AKA WMAv1 and WMAv2)
355 (<emphasis role="bold">native</emphasis> code, with
356 <link linkend="ffmpeg"><systemitem class="library">libavcodec</systemitem></link>)
359 Windows Media Audio 9 (WMAv3) (using DMO DLL)
362 AC-3 Dolby audio (<emphasis role="bold">native</emphasis> code, with
363 MMX/SSE/3DNow! optimization)
366 AC-3 passing through sound card hardware
372 Ogg Vorbis audio codec (<emphasis role="bold">native</emphasis> library)
375 RealAudio: DNET (low bitrate AC-3), Cook, Sipro and ATRAC3
378 QuickTime: Qualcomm and QDesign audio codecs
381 VIVO audio (g723, Vivo Siren)
384 Voxware audio (using DirectShow DLL)
387 alaw and ulaw, various gsm, adpcm and pcm formats and other simple old
391 Adaptive Multi-Rate (AMR) speech codecs
398 <title>Software AC-3 decoding</title>
401 This is the default decoder used for files with AC-3 audio.
405 The AC-3 decoder can create audio output mixes for 2, 4, or 6 speakers.
406 When configured for 6 speakers, this decoder provides separate output of
407 all the AC-3 channels to the sound driver, allowing for full "surround
408 sound" experience without the external AC-3 decoder required to use the
413 Use the <option>-channels</option> option to select the number of output
414 channels. Use <option>-channels 2</option> for a stereo downmix. For a 4
415 channel downmix (Left Front, Right Front, Left Surround and Right Surround
416 outputs), use <option>-channels 4</option>. In this case, any center
417 channel will be mixed equally to the front channels.
418 <option>-channels 6</option> will output all the AC-3 channels as they are
419 encoded - in the order Left, Right, Left Surround, Right Surround, Center and
424 The default number of output channels is 2.
428 To use more than 2 output channels, you will need to use OSS, and have a
429 sound card that supports the appropriate number of output channels via the
430 SNDCTL_DSP_CHANNELS ioctl. An example of a suitable driver is emu10k1
431 (used by Soundblaster Live! cards) from August 2001 or newer (ALSA CVS is
432 also supposed to work).
439 <title>Hardware AC-3 decoding</title>
442 You need an AC-3 capable sound card, with digital out (S/PDIF). The card's
443 driver must properly support the AFMT_AC3 format (C-Media does). Connect
444 your AC-3 decoder to the S/PDIF output, and use the <option>-ac
445 hwac3</option> option. It is experimental but known to work with C-Media
446 cards and Soundblaster Live! + ALSA (but not OSS) drivers and DXR3/Hollywood+
454 <title><systemitem class="library">libmad</systemitem> support</title>
457 <ulink url="http://www.underbit.com/products/mad/"><systemitem class="library">libmad</systemitem></ulink>
458 is a multiplatform, integer (internally 24bit PCM) only
459 MPEG audio decoding library. It does not handle broken files well, and it
460 sometimes has problems with seeking, but it may perform better on FPU-less
461 (such as <link linkend="arm">ARM</link>)
462 platform than <systemitem class="library">mp3lib</systemitem>.
466 If you have a proper installation of
467 <systemitem class="library">libmad</systemitem>,
468 <filename>./configure</filename> will notice and support for MPEG audio
469 decoding via <systemitem class="library">libmad</systemitem> will be built
477 <title>Hardware MPEG audio codec</title>
480 This codec (selected by <option>-ac hwmpa</option>) passes through MPEG audio
481 packets to hardware decoders, such as the ones found in full-featured DVB cards
483 Don't use it in combination with any other audio output device
484 (such as OSS and ALSA) that isn't able to decode it (you will hear
492 <title>AAC codec</title>
495 AAC (Advanced Audio Coding) is an audio codec sometimes found in MOV and MP4
496 files. An open source decoder called FAAD is available from
497 <ulink url="http://www.audiocoding.com"/>.
498 <application>MPlayer</application> includes a CVS snapshot of libfaad 2.1
499 beta, so you do not need to get it separately.
503 If you use gcc 3.2 which fails to compile our internal FAAD or want to use
504 the external library for some other reason, download the library from the
505 <ulink url="http://www.audiocoding.com/modules/mydownloads/">download page</ulink>
506 and pass <option>--enable-faad-external</option>
507 to <filename>./configure</filename>.
508 You do not need all of faad2 to decode AAC files, libfaad is enough. Build
518 Binaries are not available from audiocoding.com, but you can (apt-)get Debian
520 <ulink url="http://www.debian-multimedia.org/">Christian Marillat's homepage</ulink>,
521 Mandrake/Mandriva RPMs from the <ulink url="http://plf.zarb.org">P.L.F</ulink>
522 and Fedora RPMs from <ulink url="http://rpm.livna.org/">Livna</ulink>.
529 <title>AMR codecs</title>
532 Adaptive Multi-Rate speech codec is used in third generation (3G) mobile
534 Reference implementation is available from
535 <ulink url="http://www.3gpp.org">The 3rd Generation Partnership Project</ulink>
536 (free for private use).
537 To enable support, download and install support libraries for
538 <ulink url="http://www.penguin.cz/~utx/amr">AMR-NB and AMR-WB</ulink>
539 following the instructions on that page. Recompile MPlayer afterwards.
546 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
549 <sect1 id="codec-importing">
550 <title>Win32 codecs importing HOWTO</title>
552 <!-- TODO: a short paragraph of text would be nice here... -->
554 <sect2 id="vfw-codecs">
555 <title>VFW codecs</title>
558 VFW (Video for Windows) is the old Video API for Windows. Its codecs have
559 the <filename>.DLL</filename> or (rarely) <filename>.DRV</filename>
560 extension. If <application>MPlayer</application> fails at playing your AVI
561 with this kind of message:
562 <screen>UNKNOWN video codec: HFYU (0x55594648)</screen>
563 It means your AVI is encoded with a codec which has the HFYU fourcc (HFYU =
564 HuffYUV codec, DIV3 = DivX Low Motion, etc.). Now that you know this, you
565 have to find out which DLL Windows loads in order to play this file. In our
566 case, the <filename>system.ini</filename> contains this information in a
568 <programlisting>VIDC.HFYU=huffyuv.dll</programlisting>
572 So you need the <filename>huffyuv.dll</filename> file. Note that the audio
573 codecs are specified by the MSACM prefix:
574 <programlisting>msacm.l3acm=L3codeca.acm</programlisting>
578 This is the MP3 codec. Now that you have all the necessary information
579 (fourcc, codec file, sample AVI), submit your codec support request by
580 mail, and upload these files to the FTP site:
581 <systemitem role="url">ftp://upload.mplayerhq.hu/MPlayer/incoming/<replaceable><codecname></replaceable>/</systemitem>
585 On Windows NT/2000/XP search for this info in the registry,
586 e.g. search for "VIDC.HFYU". To find out how to do this, look at
587 the old DirectShow method below.
593 <sect2 id="dshow-codecs">
594 <title>DirectShow codecs</title>
597 DirectShow is the newer Video API, which is even worse than its predecessor.
598 Things are harder with DirectShow, since
601 <filename>system.ini</filename> does not contain the needed information,
602 instead it is stored in the registry and
605 we need the GUID of the codec.
611 <title>New Method:</title>
613 Using <application>Microsoft GraphEdit</application> (fast)
616 Get <application>GraphEdit</application> from either DirectX SDK or
617 <ulink url="http://doom9.net">doom9</ulink>.
620 Start <command>graphedit.exe</command>.
624 <menuchoice><guimenu>Graph</guimenu>
625 <guisubmenu>Insert Filters</guisubmenu></menuchoice>.
628 Expand item <systemitem>DirectShow Filters</systemitem>.
631 Select the right codec name and expand item.
634 In the entry <systemitem>DisplayName</systemitem> look at the text in
635 winged brackets after the backslash and write it down (five dash-delimited
639 The codec binary is the file specified in the
640 <systemitem>Filename</systemitem> entry.
645 If there is no <systemitem>Filename</systemitem> and
646 <systemitem>DisplayName</systemitem> contains something like
647 <systemitem>device:dmo</systemitem>, then it is a DMO-Codec.
651 <title>Old Method:</title>
653 Take a deep breath and start searching the registry...
656 Start <command>regedit</command>.
659 Press <keycombo><keycap>Ctrl</keycap><keycap>F</keycap></keycombo>, disable
660 the first two checkboxes, and enable the third. Type in the fourcc of the
661 codec (e.g. <userinput>TM20</userinput>).
664 You should see a field which contains the path and the filename (e.g.
665 <filename>C:\WINDOWS\SYSTEM\TM20DEC.AX</filename>).
668 Now that you have the file, we need the GUID. Try searching again, but
669 now search for the codec's name, not the fourcc. Its name can be acquired
670 when Media Player is playing the file, by checking
671 <menuchoice><guimenu>File</guimenu> <guisubmenu>Properties</guisubmenu>
672 <guimenuitem>Advanced</guimenuitem></menuchoice>.
673 If not, you are out of luck. Try guessing (e.g. search for TrueMotion).
676 If the GUID is found you should see a <guilabel>FriendlyName</guilabel>
677 and a <guilabel>CLSID</guilabel> field. Write down the 16 byte CLSID,
678 this is the GUID we need.
683 If searching fails, try enabling all the checkboxes. You may have
684 false hits, but you may get lucky...
688 Now that you have all the necessary information (fourcc, GUID, codec file,
689 sample AVI), submit your codec support request by mail, and upload these files
691 <systemitem role="url">ftp://upload.mplayerhq.hu/MPlayer/incoming/<replaceable><codecname></replaceable>/</systemitem>
695 If you want to add a codec yourself, read
696 <ulink url="http://www.mplayerhq.hu/MPlayer/DOCS/tech/codecs.conf.txt">DOCS/tech/codecs.conf.txt</ulink>.