<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 20183 $ -->
<chapter id="install">
<title>Installation</title>

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

<para>
In this section I'll try to guide you through the compiling and configuring
process of <application>MPlayer</application>. 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.
</para>

<para>
You need a fairly recent system. On Linux, 2.4.x kernels are recommended.
</para>

<sect1 id="softreq">
<title>Software requirements</title>

<itemizedlist>
<listitem><para>
  <emphasis role="bold">binutils</emphasis> - Recommended version is <emphasis role="bold">2.11.x</emphasis>.
  This program is responsible for generating MMX/ 3DNow!/etc instructions,
  thus very important.
</para></listitem>
<listitem><para>
  <emphasis role="bold">gcc</emphasis> - Recommended versions are 2.95
  and 3.3+. 2.96 and 3.0.x are known to generate faulty code, 3.1 and
  3.2 also had problems. On PowerPC, use 4.x+.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">XFree86</emphasis> - Recommended version is <emphasis role="bold">always the
  newest</emphasis> (4.3). Normally, everyone wants this, as starting
  with XFree86 4.0.2, it contains the <link linkend="xv">XVideo</link>
  extension (somewhere referred to as <emphasis role="bold">Xv</emphasis>)
  which is needed to enable the hardware YUV acceleration (fast image display)
  on cards that support it.
  Make sure its <emphasis role="bold">development package</emphasis> is installed,
  too, otherwise it won't work.
  For some video cards you don't need XFree86. See list below.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">make</emphasis> - Recommended version is
  <emphasis role="bold">always the newest</emphasis> (at least 3.79.x). This
  usually isn't important.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">FreeType</emphasis> 2.0.9 or later is required
  to have a font for the OSD and subtitles.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">SDL</emphasis> - 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).
  </para></listitem>
<listitem><para>
  <emphasis role="bold">libjpeg</emphasis> - optional JPEG decoder, used by the <option>-mf</option>
  option and some QT MOV files.  Useful for both <application>MPlayer</application>
  and <application>MEncoder</application> if
  you plan to work with jpeg files.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">libpng</emphasis> - recommended and default (M)PNG decoder. Required for GUI.
  Useful for both <application>MPlayer</application> and
  <application>MEncoder</application>.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">lame</emphasis> - recommended, needed for encoding MP3 audio with
  <application>MEncoder</application>, recommended version is
  <emphasis>always the newest</emphasis> (at least 3.90).
  </para></listitem>
<listitem><para>
  <emphasis role="bold">zlib</emphasis> - recommended, necessary for compressed
  MOV header and PNG support.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">libogg</emphasis> - optional, needed for playing OGG file format.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">libvorbis</emphasis> - optional, needed for playing OGG Vorbis audio.
  </para></listitem>
<listitem><para>
  <emphasis role="bold"><ulink url="http://www.live555.com/mplayer/">LIVE555 Streaming Media</ulink></emphasis>
  - optional, needed for playing RTSP/RTP streams.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">directfb</emphasis> - optional, from
  <ulink url="http://www.directfb.org"/>. At least 0.9.13 is required.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">cdparanoia</emphasis> - optional, for CDDA support
  </para></listitem>
<listitem><para>
  <emphasis role="bold">libxmms</emphasis> - optional, for XMMS input plugin
  support. At least 1.2.7 is required.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">libsmb</emphasis> - optional, for Samba support.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">ALSA</emphasis> - optional, for ALSA audio output
  support. At least 0.9.0rc4 is required.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">bio2jack</emphasis> - optional, for JACK audio output
  support, needed only in compile time. You can obtain it from
  <ulink url="http://bio2jack.sf.net/">http://bio2jack.sf.net</ulink>. Since it
  doesn't have install option you have to manually put the file
  <filename>libbio2jack.a</filename> somewhere in your library path
  (e.g. <filename>/usr/local/lib</filename>) or use the
  <option>--with-bio2jack=DIR</option> switch to tell
  <filename>./configure</filename> where that file is.
  </para></listitem>
</itemizedlist>
</sect1>


<sect1 id="video-cards">
<title>Video cards</title>

<para>
There are generally two kind of video cards. One kind (the newer cards) has
<emphasis role="bold">hardware scaling and YUV acceleration</emphasis> support,
the other cards don't.
</para>


<sect2 id="yuv-cards">
<title>YUV cards</title>

<para>
They can display and scale (zoom) the picture to any size that fits in
their memory, with <emphasis role="bold">small CPU usage</emphasis> (even when
zooming), thus fullscreen is nice and very fast.

<itemizedlist>
<listitem><para>
  <emphasis role="bold">Matrox G200/G400/G450/G550 cards</emphasis>: although a
  <link linkend="vidix">Vidix driver</link> is provided, it is recommended to
  use the mga_vid module instead, for it works much better.
  Please see the <link linkend="mga_vid">mga_vid</link> section about its
  installation and usage. It is important to do these steps
  <emphasis>before</emphasis> compiling <application>MPlayer</application>,
  otherwise no mga_vid support will be built. Also check out the
  <link linkend="tvout-mga-g400">Matrox TV-out</link> section.
  <emphasis role="bold"> If you don't use Linux</emphasis>, your only
  possibility is the VIDIX driver: read the <link linkend="vidix">VIDIX</link> section.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">3Dfx Voodoo3/Banshee cards</emphasis>: please see
  <link linkend="tdfxfb">tdfxfb</link> section in order to gain big speedup.
  It is important to do these steps <emphasis role="bold">before</emphasis>
  compiling <application>MPlayer</application>, otherwise no 3Dfx support will be
  built.
  If you use X, use at least <emphasis role="bold">4.2.0</emphasis>, as 3dfx Xv
  driver was broken in 4.1.0, and earlier releases.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">ATI cards</emphasis>: <link linkend="vidix">VIDIX</link>
  driver is provided for the following cards:
  <emphasis role="bold">Radeon, Rage128, Mach64</emphasis> (Rage XL/Mobility, Xpert98).
  Also see the <link linkend="tvout-ati">ATI cards</link> section of the TV-out documentation,
  to know if you card's TV-out is supported under Linux/<application>MPlayer</application>.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">S3 cards</emphasis>: 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 <link linkend="s3">S3 Xv</link>
  section for details. Older, Trio cards have no, or slow hardware support.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">nVidia cards</emphasis>: 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.
  <emphasis role="bold">the built-in nVidia driver in XFree86 does not support
  hardware YUV acceleration on all nVidia cards.</emphasis> You have
  to download nVidia's closed-source drivers from <ulink url="http://nvidia.com">nVidia.com</ulink>.
  See the <link linkend="nvidia">nVidia Xv driver</link> section for details. Please also check
  the <link linkend="tvout-nvidia">nVidia TV-out</link> section if you wish to
  use a TV.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">3DLabs GLINT R3 and Permedia3</emphasis>: a VIDIX driver
  is provided (pm3_vid). Please see the <link linkend="vidix">VIDIX</link> section
  for details.
  </para></listitem>
<listitem><para>
  <emphasis role="bold">Other cards</emphasis>: none of the above?
  <itemizedlist>
  <listitem><simpara>
    Try if the XFree86 driver (and your card) supports hardware
    acceleration. See the <link linkend="xv">Xv</link> section for details.
    </simpara></listitem>
  <listitem><simpara>
    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 <xref linkend="non-yuv-cards"/>.
    </simpara></listitem>
  </itemizedlist>
  </para></listitem>
</itemizedlist>
</para>
</sect2>


<sect2 id="non-yuv-cards" xreflabel="Non-YUV cards">
<title>Non-YUV cards</title>

<para>
Fullscreen playing can be achieved by either enabling <emphasis role="bold">
software scaling</emphasis> (use the <option>-zoom</option> or <option>-vf</option> 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 <option>-vm</option> option and
it works with the following drivers:
<itemizedlist>
<listitem><simpara>
  <emphasis role="bold">using</emphasis> XFree86: see details in <link linkend="dga">DGA driver</link> and
  <link linkend="x11">X11 driver</link> sections. DGA is recommended! Also
  try DGA via SDL, sometimes it's better.
  </simpara></listitem>
<listitem><simpara>
  <emphasis role="bold">not using</emphasis> XFree86: try the drivers in the
  following order:
  <link linkend="vesa">vesa</link>,
  <link linkend="fbdev">fbdev</link>,
  <link linkend="svgalib">svgalib</link>,
  <link linkend="aalib">aalib</link>.
  </simpara></listitem>
</itemizedlist>
</para>
</sect2>

<!-- FIXME: find a more logical organization for this section -->
<sect2 id="cirrus-logic-cards" xreflabel="Cirrus-Logic cards">
<title>Cirrus-Logic cards</title>
<itemizedlist>
<listitem><para>
  GD 7548: present on-board and tested in Compaq Armada 41xx notebook series.
  <itemizedlist>
  <listitem><simpara>
    XFree86 3: works in 8/16bpp modes. However, the driver is dramatically slow
    and buggy in 800x600@16bpp. <emphasis role="bold">Recommended: 640x480@16bpp</emphasis>
   </simpara></listitem>
  <listitem><simpara>
    XFree86 4: the Xserver freezes soon after start unless acceleration is
    disabled, but then the whole thing gets slower than XFree86 3. No XVideo.
   </simpara></listitem>
  <listitem><simpara>
    FBdev: framebuffer can be turned on with the <systemitem>clgenfb</systemitem>
    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.
   </simpara></listitem>
  <listitem><simpara>
    VESA: the card is only VBE 1.2 capable, so VESA output can't be used. Can't
    be workarounded with UniVBE.
  </simpara></listitem>
  <listitem><simpara>
    SVGAlib: detects an older Cirrus chip. Usable but slow with
    <option>-bpp 8</option>.
  </simpara></listitem>
</itemizedlist>
</para></listitem>
</itemizedlist>
</sect2>
</sect1>


<sect1 id="sound-cards">
<title>Sound cards</title>

<itemizedlist>
<listitem><simpara>
  <emphasis role="bold">Soundblaster Live!</emphasis>: with this card you can use
  4 or 6 (<emphasis role="bold">5.1</emphasis>) channels AC3 decoding instead of 2. Read the
  <link linkend="swac3">Software AC3 decoding</link> section. For hardware AC3
  passthrough you <emphasis role="bold">must</emphasis> use ALSA 0.9 with OSS emulation!
  </simpara></listitem>
<listitem><simpara>
  <emphasis role="bold">C-Media with S/PDIF out</emphasis>: hardware AC3
  passthrough is possible with these cards, see
  <link linkend="hwac3">Hardware AC3 decoding</link> section.
  </simpara></listitem>
<listitem><simpara>
  Features of <emphasis role="bold">other cards</emphasis> aren't supported by
  <application>MPlayer</application>. <emphasis role="bold">It's very recommended
  to read the <link linkend="audio">sound card</link> section!</emphasis>
  </simpara></listitem>
</itemizedlist>
</sect1>


<sect1 id="features">
<title>Features</title>

<itemizedlist>
<listitem><para>
  Decide if you need GUI. If you do, see the <link linkend="gui">GUI</link>
  section before compiling.
  </para></listitem>
<listitem><para>
  If you want to install <application>MEncoder</application> (our great
  all-purpose encoder), see the
  <link linkend="mencoder"><application>MEncoder</application></link> section.
  </para></listitem>
<listitem><para>
  If you have a V4L compatible <emphasis role="bold">TV tuner</emphasis> card,
  and wish to watch/grab and encode movies with <application>MPlayer</application>,
  read the <link linkend="tv-input">TV input</link> section.
  </para></listitem>
<listitem><para>
  If you have a V4L compatible <emphasis role="bold">radio tuner</emphasis> card,
  and wish to listen and capture sound with <application>MPlayer</application>,
  read the <link linkend="radio">radio</link> section.
  </para></listitem>
<listitem><para>
  There is a neat <emphasis role="bold">OSD Menu</emphasis> support ready to be
  used. Check the <link linkend="subosd">OSD menu</link> section.
  </para></listitem>
</itemizedlist>

<para>
Then build <application>MPlayer</application>:
<screen>
./configure
make
make install</screen>
</para>

<para>
At this point, <application>MPlayer</application> is ready to use. The
directory <filename class="directory">$PREFIX/share/mplayer</filename>
contains the <filename>codecs.conf</filename> 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
<filename>codecs.conf</filename> in your home directory
(<filename>~/.mplayer/codecs.conf</filename>) left from old
<application>MPlayer</application> versions, and remove it.
</para>

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


<para>
Debian users can build a .deb package for themselves, it's very simple.
Just exec
<screen>fakeroot debian/rules binary</screen>
in <application>MPlayer</application>'s root directory. See
<link linkend="debian">Debian packaging</link> for detailed instructions.
</para>

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

<para>
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 <application>MPlayer</application> to use it.
See the <link linkend="subosd">Subtitles and OSD</link> section for details.
</para>

</sect1>

<!-- ********** -->

<sect1 id="gui">
<title>What about the GUI?</title>

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

<para>
Currently you can't use the <option>-gui</option> option on the command
line, due to technical reasons.
</para>

<para>
As <application>MPlayer</application> doesn't have a skin included, you
have to download them if you want to use the GUI. See the <ulink
url="http://www.mplayerhq.hu/dload.html">download page</ulink>.
They should be extracted to the usual system-wide directory (<filename
class="directory">$PREFIX/share/mplayer/skins</filename>), or to <filename
class="directory">$HOME/.mplayer/skins</filename>.
<application>MPlayer</application> by default looks in these directories
for a directory named <filename class="directory">default</filename>, but
you can use the <option>-skin <replaceable>newskin</replaceable></option>
option, or the <literal>skin=newskin</literal> config file directive to use
the skin in <filename class="directory">*/skins/newskin</filename>
directory.
</para>
</sect1>

<!-- ********** -->

<sect1 id="fonts-osd">
<title>Fonts and OSD</title>

<para>
You need to tell <application>MPlayer</application> which font to use to
enjoy OSD and subtitles. Any TrueType font or special bitmap fonts will
work. However, TrueType fonts are recommended as they look far better,
can be properly scaled to the movie size and cope better with different
encodings.
</para>


<sect2 id="truetype-fonts">
<title>TrueType fonts</title>

<para>
There are two ways to get TrueType fonts to work. The first is to pass
the <option>-font</option> option to specify a TrueType font file on
the command line. This option will be a good candidate to put in your
configuration file (see the manual page for details).
The second is to create a symlink called <filename>subfont.ttf</filename>
to the font file of your choice. Either
<screen>ln -s <replaceable>/path/to/sample_font.ttf</replaceable> ~/.mplayer/subfont.ttf</screen>
for each user individually or a system-wide one:
<screen>ln -s <replaceable>/path/to/sample_font.ttf</replaceable> $PREFIX/share/mplayer/subfont.ttf</screen>
</para>

<para>
If <application>MPlayer</application> was compiled with
<systemitem class="library">fontconfig</systemitem> support, the above methods
won't work, instead <option>-font</option> expects a
<systemitem class="library">fontconfig</systemitem> font name
and defaults to the sans-serif font. To get a list of fonts known to
<systemitem class="library">fontconfig</systemitem>,
use <command>fc-list</command>. Example:

<screen>mplayer -font <replaceable>'Bitstream Vera Sans'</replaceable> <replaceable>anime.mkv</replaceable></screen>
</para>

</sect2>


<sect2 id="bitmap-fonts">
<title>bitmap fonts</title>

<para>
If for some reason you wish or need to employ bitmap fonts, download a set
from our homepage. You can choose between various
<ulink url="http://www.mplayerhq.hu/MPlayer/releases/fonts/">ISO fonts</ulink>
and some sets of fonts
<ulink url="http://www.mplayerhq.hu/MPlayer/contrib/fonts/">contributed by users</ulink>
in various encodings.
</para>

<para>
Uncompress the file you downloaded to
<filename class="directory">~/.mplayer</filename> or
<filename class="directory">$PREFIX/share/mplayer</filename>.
Then rename or symlink one of the extracted directories to
<filename class="directory">font</filename>, for example:
<screen>ln -s <replaceable>~/.mplayer/arial-24</replaceable> ~/.mplayer/font</screen>
<screen>ln -s <replaceable>$PREFIX/share/mplayer/arial-24</replaceable> $PREFIX/share/mplayer/font</screen>
</para>

<para>
Fonts should have an appropriate <filename>font.desc</filename> file
which maps unicode font positions to the actual code page of the
subtitle text. Another solution is to have UTF-8-encoded subtitles
and use the <option>-utf8</option> option or just name the subtitles
file <filename>&lt;video_name&gt;.utf</filename> and have it in the
same directory as the video file.
</para>

</sect2>


<sect2 id="osdmenu">
<title>OSD menu</title>

<para>
<application>MPlayer</application> has a completely user definiable OSD Menu interface.
</para>

<note><simpara>
the Preferences menu is currently UNIMPLEMENTED!
</simpara></note>

<orderedlist>
<title>Installation</title>
<listitem><simpara>
  compile <application>MPlayer</application> by passing the <option>--enable-menu</option>
  to <filename>./configure</filename>
  </simpara></listitem>
<listitem><simpara>
  make sure you have an OSD font installed
  </simpara></listitem>
<listitem><simpara>
  copy <filename>etc/menu.conf</filename> to your
  <filename class="directory">.mplayer</filename> directory
  </simpara></listitem>
<listitem><simpara>
  copy <filename>etc/input.conf</filename> to your
  <filename class="directory">.mplayer</filename> directory, or to the system-wide
  <application>MPlayer</application> config dir (default:
  <filename class="directory">/usr/local/etc/mplayer</filename>)
  </simpara></listitem>
<listitem><simpara>
  check and edit <filename>input.conf</filename> to enable menu movement keys
  (it is described there).
  </simpara></listitem>
<listitem><para>
  start <application>MPlayer</application> by the following example:
  <screen>$ mplayer -menu <replaceable>file.avi</replaceable></screen>
  </para></listitem>
<listitem><simpara>
  push any menu key you defined
  </simpara></listitem>
</orderedlist>

</sect2>
</sect1>

<!-- ********** -->

<sect1 id="rtc">
<title>RTC</title>
<para>
There are three timing methods in <application>MPlayer</application>.

<itemizedlist>
<listitem><simpara>
<emphasis role="bold">To use the old method</emphasis>, you don't have to do
  anything. It uses <systemitem>usleep()</systemitem> to tune
  A/V sync, with +/- 10ms accuracy. However sometimes the sync has to be
  tuned even finer.
  </simpara></listitem>
<listitem><para>
<emphasis role="bold">The new timer</emphasis> code uses the RTC (RealTime Clock)
  for this task, because it has precise 1ms timers. The <option>-rtc</option>
  option enables it, but a properly set up kernel is required.
  If you are running kernel 2.4.19pre8 or later you can adjust the maximum RTC
  frequency for normal users through the <systemitem class="systemname">/proc
  </systemitem> filesystem. Use one of the following two commands to
  enable RTC for normal users:
  <screen>echo 1024 &gt; /proc/sys/dev/rtc/max-user-freq</screen>
  <screen>sysctl dev/rtc/max-user-freq=1024</screen>
  You can make this setting permanent by adding the latter to
  <filename>/etc/sysctl.conf</filename>.
  </para>
  <para>
   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.
   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.
  </para></listitem>
<listitem><simpara>
  <emphasis role="bold">The third timer code</emphasis> is turned on with the
  <option>-softsleep</option> option. It has the efficiency of the RTC, but it
  doesn't use RTC. On the other hand, it requires more CPU.
  </simpara></listitem>
</itemizedlist>
</para>
</sect1>

</chapter>
