<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../../general.ent">
  %general-entities;

  <!ENTITY ffmpeg-download-http "http://ffmpeg.org/releases/ffmpeg-&ffmpeg-version;.tar.xz">
  <!ENTITY ffmpeg-download-ftp  " ">
  <!ENTITY ffmpeg-md5sum        "dcc20dd2682ea01c678b7b8324339d43">
  <!ENTITY ffmpeg-size          "8.5 MB">
  <!ENTITY ffmpeg-buildsize     "156 MB (add 3.2 GB for the FATE suite/tests, add 643 MB for docs)">
  <!ENTITY ffmpeg-time          "1.4 SBU (using parallelism=4; add 3.8 SBU (with THREADS=4) to run the FATE suite after sample files are downloaded; add 0.6 SBU for docs)">
]>

<sect1 id="ffmpeg" xreflabel="FFmpeg-&ffmpeg-version;">
  <?dbhtml filename="ffmpeg.html"?>

  <sect1info>
    <othername>$LastChangedBy$</othername>
    <date>$Date$</date>
  </sect1info>

  <title>FFmpeg-&ffmpeg-version;</title>

  <indexterm zone="ffmpeg">
    <primary sortas="a-FFmpeg">FFmpeg</primary>
  </indexterm>

  <sect2 role="package">
    <title>Introduction to FFmpeg</title>

    <para>
      <application>FFmpeg</application> is a solution to record, convert and
      stream audio and video. It is a very fast video and audio converter and it
      can also acquire from a live audio/video source. Designed to be intuitive,
      the command-line interface (<command>ffmpeg</command>) tries to figure out
      all the parameters, when possible. <application>FFmpeg</application> can
      also convert from any sample rate to any other, and resize video on the
      fly with a high quality polyphase filter.
      <application>FFmpeg</application> can use a Video4Linux compatible video
      source and any Open Sound System audio source.
    </para>

    &lfs84_checked;

    <bridgehead renderas="sect3">Package Information</bridgehead>
    <itemizedlist spacing="compact">
      <listitem>
        <para>
          Download (HTTP): <ulink url="&ffmpeg-download-http;"/>
        </para>
      </listitem>
      <listitem>
        <para>
          Download (FTP): <ulink url="&ffmpeg-download-ftp;"/>
        </para>
      </listitem>
      <listitem>
        <para>
          Download MD5 sum: &ffmpeg-md5sum;
        </para>
      </listitem>
      <listitem>
        <para>
          Download size: &ffmpeg-size;
        </para>
      </listitem>
      <listitem>
        <para>
          Estimated disk space required: &ffmpeg-buildsize;
        </para>
      </listitem>
      <listitem>
        <para>
          Estimated build time: &ffmpeg-time;
        </para>
      </listitem>
    </itemizedlist>

    <bridgehead renderas="sect3">FFmpeg Dependencies</bridgehead>

    <bridgehead renderas="sect4">Recommended</bridgehead>
    <para role="recommended">
      <xref linkend="libass"/>,
      <xref linkend="fdk-aac"/>,
      <xref linkend="freetype2"/>,
      <xref linkend="lame"/>,
      <xref linkend="libtheora"/>,
      <xref linkend="libvorbis"/>,
      <xref linkend="libvpx"/>,
      <xref linkend="opus"/>,
      <xref linkend="x264"/>,
      <xref linkend="x265"/>, and
      <xref linkend="yasm"/>
    </para>

    <bridgehead renderas="sect4">Recommended for desktop use</bridgehead>
    <para role="recommended">
      <xref linkend="alsa-lib"/>,
      <xref linkend="libva"/>,
      <xref linkend="libvdpau"/> (with the corresponding driver package), and
      <xref linkend="sdl2"/>,
    </para>

    <bridgehead renderas="sect4">Optional</bridgehead>
    <para role="optional">
      <xref linkend="fontconfig"/>,
      <xref linkend="frei0r"/>,
      <xref linkend="libcdio"/> (to identify and play CDs),
      <xref linkend="libwebp"/>,
      <xref linkend="opencv"/>,
      <xref linkend="openjpeg2"/>,
      <xref linkend="gnutls"/>,
      <xref linkend="pulseaudio"/>,
      <xref linkend="speex"/>,
      <xref linkend="texlive"/>
         (or <xref linkend="tl-installer"/>) for PDF and PS documentation,
      <xref linkend="v4l-utils"/>,
      <xref linkend="xvid"/>,
      <xref linkend="x-window-system"/>,
      <ulink url="http://www.speech.cs.cmu.edu/flite/">Flite</ulink>,
      <ulink url="http://www.quut.com/gsm/">GSM</ulink>,
      <!--<ulink url="http://xhevc.com/en/hevc/decoder/download.jsp">HEVC/H.265</ulink>,-->
      <!--<ulink url="http://www.ladspa.org/">LADSPA</ulink>,-->
      <ulink url="http://tipok.org.ua/node/17">libaacplus</ulink>,
      <ulink url="http://www.videolan.org/developers/libbluray.html">libbluray</ulink>,
      <ulink url="http://caca.zoy.org/">libcaca</ulink>,
      <ulink url="http://www.celt-codec.org/">libcelt</ulink>,
      <ulink url="http://sourceforge.net/projects/libdc1394">libdc1394</ulink>,
      <ulink url="https://www.videolan.org/developers/libdca.html">libdca</ulink>,
      <ulink url="https://ieee1394.wiki.kernel.org/index.php/Libraries">libiec61883</ulink>,
      <ulink url="https://github.com/dekkers/libilbc">libilbc</ulink>,
      <ulink url="http://sourceforge.net/projects/modplug-xmms/">libmodplug</ulink>,
      <ulink url="https://github.com/Distrotech/libnut">libnut</ulink> (Git checkout),
      <ulink url="http://rtmpdump.mplayerhq.hu/">librtmp</ulink>,
      <ulink url="http://www.libssh.org/">libssh</ulink>,
      <!--<ulink url="http://xavs.sourceforge.net/">libxavs</ulink> (SVN checkout),-->
      <ulink url="http://kcat.strangesoft.net/openal-releases/">OpenAL</ulink>,
      <ulink url="http://sourceforge.net/projects/opencore-amr">OpenCore AMR</ulink>,
      <!--<ulink url="http://diracvideo.org/">Schroedinger</ulink>,-->
      <ulink url="http://sourceforge.net/projects/schrodinger/">Schroedinger</ulink>,
      <ulink url="http://www.twolame.org/">TwoLAME</ulink>,
      <ulink url="http://sourceforge.net/projects/opencore-amr/files/vo-aacenc/">vo-aaenc</ulink>,
      <ulink url="http://sourceforge.net/projects/opencore-amr/files/vo-amrwbenc/">vo-amrwbenc</ulink>, and
      <!--<ulink url="http://www.videolan.org/developers/x265.html">x265 (H.265/MPEG-H HEVC)</ulink>, and-->
      <ulink url="http://zapping.sourceforge.net/ZVBI/">ZVBI</ulink>
    </para>

    <para condition="html" role="usernotes">
      User Notes: <ulink url="&blfs-wiki;/ffmpeg"/>
    </para>
  </sect2>

  <sect2 role="installation">
    <title>Installation of FFmpeg</title>

    <para>
      Install <application>FFmpeg</application> by running the following
      commands:
    </para>

<screen><userinput>sed -i 's/-lflite"/-lflite -lasound"/' configure &amp;&amp;

./configure --prefix=/usr        \
            --enable-gpl         \
            --enable-version3    \
            --enable-nonfree     \
            --disable-static     \
            --enable-shared      \
            --disable-debug      \
            --enable-avresample  \
            --enable-libass      \
            --enable-libfdk-aac  \
            --enable-libfreetype \
            --enable-libmp3lame  \
            --enable-libopus     \
            --enable-libtheora   \
            --enable-libvorbis   \
            --enable-libvpx      \
            --enable-libx264     \
            --enable-libx265     \
            --docdir=/usr/share/doc/ffmpeg-&ffmpeg-version; &amp;&amp;

make &amp;&amp;

gcc tools/qt-faststart.c -o tools/qt-faststart</userinput></screen>

    <para>
      HTML documentation was built in the previous step. If  you have
      <xref linkend="texlive"/> installed and wish to build PDF and
      Postscript versions of the documentation, issue the following commands:
    </para>

<!-- sed -i '$s/$/\n\n@bye/' doc/{git-howto,nut,fate}.texi             &amp;&amp;
sed -i '/machine:i386/ s/\\/@backslashchar{}/g' doc/platform.texi &amp;&amp; -->
<screen remap="doc"><userinput>pushd doc &amp;&amp;
for DOCNAME in `basename -s .html *.html`
do
    texi2pdf -b $DOCNAME.texi &amp;&amp;
    texi2dvi -b $DOCNAME.texi &amp;&amp;

    dvips    -o $DOCNAME.ps   \
                $DOCNAME.dvi
done &amp;&amp;
popd &amp;&amp;
unset DOCNAME</userinput></screen>

    <para>
      If you have <xref linkend="doxygen"/> installed 
      and you wish to build (if --disable-doc was
      used) or rebuild the html documentation, issue:
    </para>

<screen remap="doc"><userinput>doxygen doc/Doxyfile</userinput></screen>

    <para>
      The fate-suite tests include comparisons with installed files, and should
      not be run before the package is installed. Therefore, if you desire to
      run them, instructions are given further below.
    </para>

    <para>
      Now, as the <systemitem class="username">root</systemitem> user:
    </para>

<screen role="root"><userinput>make install &amp;&amp;

install -v -m755    tools/qt-faststart /usr/bin &amp;&amp;
install -v -m755 -d           /usr/share/doc/ffmpeg-&ffmpeg-version; &amp;&amp;
install -v -m644    doc/*.txt /usr/share/doc/ffmpeg-&ffmpeg-version;</userinput></screen>

    <para>
      If the PDF and Postscript documentation was built, issue the following
      commands, as the <systemitem class="username">root</systemitem> user, to
      install them:
    </para>

<screen role="root"
        remap="doc"><userinput>install -v -m644 doc/*.pdf /usr/share/doc/ffmpeg-&ffmpeg-version; &amp;&amp;
install -v -m644 doc/*.ps  /usr/share/doc/ffmpeg-&ffmpeg-version;</userinput></screen>

    <para>
      If you used <command>doxygen</command> to manually create the API 
      documentation, install it by issuing the following commands
      as the <systemitem class="username">root</systemitem> user:
    </para>

<screen role="root"
        remap="doc"><userinput>install -v -m755 -d /usr/share/doc/ffmpeg-&ffmpeg-version;/api                     &amp;&amp;
cp -vr doc/doxy/html/* /usr/share/doc/ffmpeg-&ffmpeg-version;/api                  &amp;&amp;
find /usr/share/doc/ffmpeg-&ffmpeg-version;/api -type f -exec chmod -c 0644 \{} \; &amp;&amp;
find /usr/share/doc/ffmpeg-&ffmpeg-version;/api -type d -exec chmod -c 0755 \{} \;</userinput></screen>

    <para>
      To properly test the installation you must have <xref linkend="rsync"/>
      installed and follow the instructions for the <ulink
      url="http://www.ffmpeg.org/fate.html"> FFmpeg Automated Testing
      Environment</ulink> (FATE). First, about 1 GB of sample files used to
      run FATE are downloaded with the command:
    </para>

<screen remap="test"><userinput>make fate-rsync SAMPLES=fate-suite/</userinput></screen>

    <para>
      The <filename class="directory">fate-suite</filename> directory is
      created and the files are downloaded there. That command actually runs an
      rsync command, to obtain the sample files.  You may want to compress and
      keep this directory for testing again, in another system, or when a new
      version of ffmpeg is launched. Then, you unpack the sample files in the
      source directory, and run, again, the <command>make fate-rsync
      ...</command> command above, to sync with the repository. Now, the
      download size and time are drastically reduced.  Estimated values in
      "Package Information" do not include the download SBU. Some samples may
      have been removed, in the new version, so, in order to be sure local and
      server fate samples are identical, when you use previously saved samples,
      run the following command:
    </para>

<screen role="nodump"><userinput><command>rsync -vrltLW  --delete --timeout=60 --contimeout=60 \
      rsync://fate-suite.ffmpeg.org/fate-suite/ fate-suite/</command></userinput></screen>

    <para>
      Next, FATE is executed, with the commands (you obtain a number of tests
      larger than 3000):
    </para>

<screen remap="test"><userinput>make fate THREADS=<replaceable>N</replaceable> SAMPLES=fate-suite/ | tee ../fate.log &amp;&amp;
grep ^TEST ../fate.log | wc -l</userinput></screen>

    <para>
      where <replaceable>N</replaceable> is an integer,
      <replaceable>N</replaceable> &le; number of cores in the system.
    </para>

  </sect2>

  <sect2 role="commands">
    <title>Command Explanations</title>

    <para>
      <command>sed -i ... configure</command>: This command adds the
      <application>ALSA</application> library to the
      <application>Flite</application> <envar>LDFLAGS</envar> variable and
      enables the discovery of <application>Flite</application>.
    </para>

    <para>
      <command>find ... ;</command>: Fix permissions of documentation files
      and directories.
    </para>

    <para>
      <parameter>--enable-libfreetype</parameter>: Enables
      <application>Freetype</application> support.
    </para>

    <para>
      <parameter>--enable-gpl</parameter>: Enables the use of GPL code and
      permits support for postprocessing, swscale and many other features.
    </para>

    <para>
      <parameter>--enable-version3</parameter>: Enables the use of (L)GPL
      version 3 code.
    </para>

    <para>
      <parameter>--enable-nonfree</parameter>: Enables the use of nonfree code.
      Note that the resulting libraries and binaries will be unredistributable.
    </para>

    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
      href="../../xincludes/static-libraries.xml"/>

    <para>
      <parameter>--enable-shared</parameter>: Enables building shared
      libraries, otherwise only static libraries are built and installed.
    </para>

    <para>
      <parameter>--disable-debug</parameter>: Disables building debugging
      symbols into the programs and libraries.
    </para>

    <para>
      <parameter>--enable-avresample</parameter>: Enables
      <xref linkend="transcode"/> to be compiled.
    </para>

    <para>
      <parameter>--enable-libass</parameter>: Enables ASS/SSA subtitle format
      rendering via <filename class="libraryfile">libass</filename>.
    </para>

    <para>
      <parameter>--enable-libfdk-aac</parameter>: Enables currently the
      highest-quality AAC audio encoding via <filename
      class="libraryfile">libfdk-aac</filename>.
    </para>

    <para>
      <parameter>--enable-libmp3lame</parameter>: Enables MP3 audio encoding
      via <filename class="libraryfile">libmp3lame</filename>.
    </para>

    <para>
      <parameter>--enable-libvorbis --enable-libtheora</parameter>: Enables
      Theora video encoding via <filename
      class="libraryfile">libvorbis</filename> and <filename
      class="libraryfile">libtheora</filename>.
    </para>

    <para>
      <parameter>--enable-libvorbis --enable-libvpx</parameter>: Enables WebM
      encoding via <filename class="libraryfile">libvorbis</filename> and
      <filename class="libraryfile">libvpx</filename>.
    </para>

    <para>
      <parameter>--enable-libx264</parameter>: Enables high-quality
      H.264/MPEG-4 AVC encoding via <filename
      class="libraryfile">libx264</filename>.
    </para>

    <para>
      <parameter>--enable-libx265</parameter>: Enables high-quality
      H.265/HEVC encoding via <filename
      class="libraryfile">libx265</filename>.
    </para>

    <para>
      <option>--enable-openssl</option> or <option>--enable-gnutls</option>:
      Enables HTTPS protocol for network streams.
    </para>

    <para>
      <option>--disable-doc</option>: Disables building html documentation.
      This is only needed if <xref linkend="doxygen"/> is installed and you 
      do not want to build the html documentation.
    </para>

    <para>
      <command>gcc tools/qt-faststart.c -o tools/qt-faststart</command>: This
      builds the <command>qt-faststart</command> program which can modify
      QuickTime formatted movies (<filename class="extension">.mov</filename>
      or <filename class="extension">.mp4</filename>) so that the header
      information is located at the beginning of the file instead of the end.
      This allows the movie file to begin playing before the entire file has
      been downloaded.
    </para>

    <note>
      <para>
        Support for most of the dependency packages requires using options
        passed to the <command>configure</command> script. View the output
        from <command>./configure --help</command> for complete information
        about enabling dependency packages.
      </para>
    </note>

  </sect2>

  <sect2 role="configuration">
    <title>Configuring FFmpeg</title>

    <sect3 id="ffmpeg-config">
      <title>Config Files</title>

      <para>
        <filename>/etc/ffserver.conf</filename> and
        <filename>~/.ffmpeg/ffserver-config</filename>
      </para>

      <indexterm zone="ffmpeg ffmpeg-config">
        <primary
        sortas="e-AA.ffmpeg-ffserver-config">~/.ffmpeg/ffserver-config</primary>
      </indexterm>

      <indexterm zone="ffmpeg ffmpeg-config">
        <primary sortas="e-etc-ffserver.conf">/etc/ffserver.conf</primary>
      </indexterm>

      <para>
        You'll find a sample <command>ffserver</command> configuration file at
        <filename>doc/ffserver.conf</filename> in the source tree.
      </para>

    </sect3>

  </sect2>

  <sect2 role="content">
    <title>Contents</title>

    <segmentedlist>
      <segtitle>Installed Programs</segtitle>
      <segtitle>Installed Libraries</segtitle>
      <segtitle>Installed Directories</segtitle>

      <seglistitem>
        <seg>
          ffmpeg, ffplay, ffprobe, ffserver, and qt-faststart
        </seg>
        <seg>
          libavcodec.so, libavdevice.so, libavfilter.so,
          libavformat.so, libavutil.so, libpostproc.so,
          libswresample.so, and libswscale.so
        </seg>
        <seg>
          /usr/include/libav{codec,device,filter,format,util},
          /usr/include/libpostproc,
          /usr/include/libsw{resample,scale},
          /usr/share/doc/ffmpeg-&ffmpeg-version;, and
          /usr/share/ffmpeg
        </seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="ffmpeg-prog">
        <term><command>ffmpeg</command></term>
        <listitem>
          <para>
            is a command-line tool to convert video files, network streams and
            input from a TV card to several video formats.
          </para>
          <indexterm zone="ffmpeg ffmpeg-prog">
            <primary sortas="b-ffmpeg">ffmpeg</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="ffplay">
        <term><command>ffplay</command></term>
        <listitem>
          <para>
            is a very simple and portable media player using the
            <filename>ffmpeg</filename> libraries and the SDL library.
          </para>
          <indexterm zone="ffmpeg ffplay">
            <primary sortas="b-ffplay">ffplay</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="ffprobe">
        <term><command>ffprobe</command></term>
        <listitem>
          <para>
            gathers information from multimedia streams and prints it in a human
            and machine-readable fashion.
          </para>
          <indexterm zone="ffmpeg ffprobe">
            <primary sortas="b-ffprobe">ffprobe</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="ffserver">
        <term><command>ffserver</command></term>
        <listitem>
          <para>
            is a streaming server for everything that <command>ffmpeg</command>
            could use as input (files, streams, TV card input, webcam, etc).
          </para>
          <indexterm zone="ffmpeg ffserver">
            <primary sortas="b-ffserver">ffserver</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="qt-faststart">
        <term><command>qt-faststart</command></term>
        <listitem>
          <para>
            moves the index file to the front of quicktime (mov/mp4) videos.
          </para>
          <indexterm zone="ffmpeg qt-faststart">
            <primary sortas="b-qt-faststart">qt-faststart</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libavcodec">
        <term><filename class="libraryfile">libavcodec.so</filename></term>
        <listitem>
          <para>
            is a library containing the <application>FFmpeg</application> codecs
            (both encoding and decoding).
          </para>
          <indexterm zone="ffmpeg libavcodec">
            <primary sortas="c-libavcodec">libavcodec.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libavdevice">
        <term><filename class="libraryfile">libavdevice.so</filename></term>
        <listitem>
          <para>
            is the <application>FFmpeg</application> device handling library.
          </para>
          <indexterm zone="ffmpeg libavdevice">
            <primary sortas="c-libavdevice">libavdevice.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libavfilter">
        <term><filename class="libraryfile">libavfilter.so</filename></term>
        <listitem>
          <para>
            is a library of filters that can alter video or audio between the
            decoder and the encoder (or output).
          </para>
          <indexterm zone="ffmpeg libavfilter">
            <primary sortas="c-libavfilter">libavfilter.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libavformat">
        <term><filename class="libraryfile">libavformat.so</filename></term>
        <listitem>
          <para>
            is a library containing the file formats handling (mux and demux
            code for several formats) used by <command>ffplay</command> as well
            as allowing the generation of  audio or video streams.
          </para>
          <indexterm zone="ffmpeg libavformat">
            <primary sortas="c-libavformat">libavformat.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libavutil">
        <term><filename class="libraryfile">libavutil.so</filename></term>
        <listitem>
          <para>
            is the <application>FFmpeg</application> utility library.
          </para>
          <indexterm zone="ffmpeg libavutil">
            <primary sortas="c-libavutil">libavutil.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libpostproc">
        <term><filename class="libraryfile">libpostproc.so</filename></term>
        <listitem>
          <para>
            is the <application>FFmpeg</application> post processing library.
          </para>
          <indexterm zone="ffmpeg libpostproc">
            <primary sortas="c-libpostproc">libpostproc.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libswresample">
        <term><filename class="libraryfile">libswresample.so</filename></term>
        <listitem>
          <para>
            is the <application>FFmpeg</application> audio rescaling library,
            it contains functions for converting audio sample formats.
          </para>
          <indexterm zone="ffmpeg libswresample">
            <primary sortas="c-libswresample">libswresample.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libswscale">
        <term><filename class="libraryfile">libswscale.so</filename></term>
        <listitem>
          <para>
            is the <application>FFmpeg</application> image rescaling library.
          </para>
          <indexterm zone="ffmpeg libswscale">
            <primary sortas="c-libswscale">libswscale.so</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>