Installing FFMpeg and FFMpeg-PHP

/* This article can possibly be re-written using the RPMs available from RPMForge. */

Below is a step-by-step how-to on installing ffmpeg and ffmpeg-php on CentOS 5.3. The reason we (or anyone really) have not published a script to automate the process is due to the complexity of the installation and the fact that it is very prone to failures along the way, almost always requiring some sort of human intervention. We have attempted to address the most common of issues in this article, but if you find that you're stuck at one that is not mentioned, please feel free to send support an email.

We have also used very explicit versions of each of the libraries/codecs/software in this guide as we have found these to have the highest rate of success. If you need the additional functionality provided by a newer version of any of these, please note that doing so may break other parts of the installation; caveat emptor!
  1. First start out by downloading the necessary sources. These versions are subject to change so you may want to browse each repo to find the latest version (again caveat emptor!). This also installs Ruby, which is a pre-requisite for installing Flvtool; if you already have Ruby, skip the second line in this step and the first three lines in step 7:
    cd /usr/local/src; \
    wget; \
    wget; \
    wget; \
  2. Extract the files you just downloaded.
    tar xjvf essential-20061022.tar.bz2; \
    tar xzvf flvtool2_1.0.5_rc6.tgz; \
    tar xzvf lame-3.98.4.tar.gz; \
    tar xzvf ruby-1.9.1-p0.tar.gz
  3. Next you'll want to create a codec location and import the codecs there:
    mkdir /usr/local/lib/codecs/
    mv essential-20061022/* /usr/local/lib/codecs/
    chmod -R 755 /usr/local/lib/codecs/
  4. Next we'll need to satisfy some other pre-requisites:
    yum install subversion ncurses-devel automake autoconf libtool* neon neon-devel
    • You may encounter an error saying that no suitable perl(URI) was found for subversion. If so, run the following and then re-run the yum command above without subversion:
      tar xjvf subversion-1.5.9.tar.bz2
      cd subversion-1.5.9 && ./configure --with-apr=/usr/local/apache/bin/ --with-apr-util=/usr/local/apache/bin/ --with-ssl --disable-mod-activation
      make && make install
      cd ..
    • NOTE: You may need to change the APR paths to reflect your own Apache installation (e.g. /etc/httpd/bin/).
  5. Get the latest FFMpeg and Mplayer via Subversion:
    svn checkout svn:// ffmpeg
    svn checkout svn:// mplayer
  6. Edit /etc/ and add /usr/local/lib then run:
    ldconfig -v
  7. Let's compile all the codecs and libraries (& pre-reqs!) at once:
    cd /usr/local/src/ruby-1.9.1-p0
    make && make install
    cd /usr/local/src/lame-3.98.4
    make && make install
    cd /usr/local/src/flvtool2_1.0.5_rc6
    ruby setup.rb config && ruby setup.rb setup && ruby setup.rb install
    cd /usr/local/src/mplayer
    ./configure --yasm=''
    make && make install
    • As of this writing, the latest version of Mplayer now requires Git to download it's own copy of the FFMpeg source. CentOS' default repos don't include the RPMs (if yours does, then lucky you!), so here's how to install the needed RPMs manually. Re-run the configure step after you've done this.
      rpm -ivh \ \
  8. Install FFMpeg:
    cd /usr/local/src/ffmpeg
    ./configure --enable-libmp3lame --disable-mmx --enable-shared
    make && make install
    • Use ./configure --help if you'd like to enable additional libraries/codecs. Many will require additional downloads & builds like those above. Note that after each library/codec install, you'll need to run ldconfig -v.
  9. Set up links to the codecs:
    ln -s /usr/local/lib/ /usr/lib/; \
    ln -s /usr/local/lib/ /usr/lib/; \
    ln -s /usr/local/lib/ /usr/lib/; \
    ln -s /usr/local/lib/ /usr/lib/; \
    ln -s /usr/local/lib/ /usr/lib/; \
    ln -s /usr/local/lib/ /usr/lib/; \
    ln -s /usr/local/lib/ /usr/lib/
  10. Let's finish the compilation of FFMpeg-PHP now:
    cd /usr/local/src/
    wget ""
    tar xjvf ffmpeg-php-0.6.0.tbz2
    cd ffmpeg-php-0.6.0
    make && make install
    • If ./configure fails saying it cannot find ffmpeg headers, you need to perform the following:
      cp /usr/local/include/libavcodec/* /usr/local/include/ffmpeg; \
      cp /usr/local/include/libavutil/* /usr/local/include/ffmpeg; \
      cp /usr/local/include/libavformat/* /usr/local/include/ffmpeg; \
      cp /usr/local/include/libavdevice/* /usr/local/include/ffmpeg; \
      cp /usr/local/include/libswscale/* /usr/local/include/ffmpeg
  11. Add the extension for in your php.ini:
    ;ffmpeg-php extension
  12. Restart Apache:
    /etc/init.d/httpd restart
  13. Check to make sure it started okay:
    ps auxf|grep http
    root      5684  0.0  0.0  66064  5052 ?        Ss   Sep15   0:49 /usr/local/apache/bin/httpd -k start -DSSL
    nobody   17175  0.0  0.0  66340  4836 ?        S    15:32   0:00  \_ /usr/local/apache/bin/httpd -k start -DSSL
    nobody   17176  0.0  0.0  66344  4768 ?        S    15:32   0:00  \_ /usr/local/apache/bin/httpd -k start -DSSL
  14. Check to ensure ffmpeg is loaded into PHP:
    php -i|grep ffmpeg
    ffmpegffmpeg support (ffmpeg-php) => enabled
    ffmpeg-php version => 0.6.0
    ffmpeg.allow_persistent => 0 => 0

That's it! Your PHP installation will not have the ability to use ffmpeg functions!