EZ Linux Admin random header image

Install FFMPEG from source

December 22nd, 2009 by EZ linux · 1 Comment

Do you prefer to manually install everything? Here is a article for you on installing FFMPEG on a Linux server.

For the automated people check this article out for FFMPEG Installation

FFmpeg is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library.

NOTE:
- This guide is designed for a Linux i386 powered server .

- If you experience any problems installing FFmpeg on your server and need help, we suggest you sign up for the xPress Plan. Our engineers are ready to fix any installation problems you might have with your server.

To install FFmpeg from source, SSH to the server and run the commands below (in that order). Before you start working on this project, make sure the following binary packages are installed on your server:

gcc, gcc4, gcc4-c++, gcc4-gfortran, gd, gd-devel, gmake, ImageMagick, ImageMagick-devel, libcpp, libgcc, libstdc++, make, ncurses, ncurses-devel, ruby, subversion

If any of these packages are missing, install them using Yum . For example:

  • /usr/bin/yum install PACKAGE

- Caution
The following binary packages are always updated with newer versions. You might experience technical issues if you download a newer version for one or two of these applications.

Follow these steps (in that order):

  1. Let’s create a directory to do our work in:
    • mkdir /usr/local/src
    • cd /usr/local/src
  2. Download source binary packages
    • /usr/bin/wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz
    • /usr/bin/wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2
    • /usr/bin/wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.2.tar.bz2
    • /usr/bin/wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-ppc-20071007.tar.bz2
    • /usr/bin/wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.bz2
    • /usr/bin/wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
    • /usr/bin/wget http://biznetnetworks.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
    • /usr/bin/wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
    • /usr/bin/wget http://www.sfr-fresh.com/unix/misc/lame-398-2.tar.gz
    • /usr/bin/wget http://downloads.xiph.org/releases/ogg/libogg-1.1.4.tar.gz
    • /usr/bin/wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
    • /usr/bin/wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2.tar.gz
    • /usr/bin/wget http://downloads.sourceforge.net/project/re2c/re2c/0.13.5/re2c-0.13.5.tar.gz
    • /usr/bin/wget http://download.m0k.org/handbrake/contrib/xvidcore-1.1.3.tar.gz
    • /usr/bin/wget http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc1.tar.bz2
    • /usr/bin/wget http://downloads.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20080324-2245.tar.bz2
  3. Extract source binary packages
    • /bin/tar xzf a52dec-0.7.4.tar.gz
    • /bin/tar jxvf amrnb-7.0.0.2.tar.bz2
    • /bin/tar jxvf amrwb-7.0.0.2.tar.bz2
    • /bin/tar jxvf essential-ppc-20071007.tar.bz2
    • /bin/tar jxvf faac-1.28.tar.bz2
    • /bin/tar xzf faad2-2.7.tar.gz
    • /bin/tar jxvf ffmpeg-php-0.6.0.tbz2
    • /bin/tar zxvf flvtool2_1.0.5_rc6.tgz
    • /bin/tar xzf lame-398-2.tar.gz
    • /bin/tar xzf libogg-1.1.4.tar.gz
    • /bin/tar jxvf libtheora-1.1.1.tar.bz2
    • /bin/tar xzf libvorbis-1.2.2.tar.gz
    • /bin/tar xzf re2c-0.13.5.tar.gz
    • /bin/tar jxvf MPlayer-1.0rc2.tar.bz2
    • /bin/tar xzf xvidcore-1.1.3.tar.gz
    • /bin/tar jxvf x264-snapshot-20080324-2245.tar.bz2
  4. Create the codecs directory & import them
    • mkdir /usr/local/lib/codecs
    • mv /usr/local/src/essential-ppc-20071007/* /usr/local/lib/codecs
    • chmod -R 755 /usr/local/lib/codecs
  5. Install SVN/Ruby (this is for RedHat/CentOS v5.x)
    • /usr/bin/yum install subversion
    • /usr/bin/yum install ruby
      OR (if you are using the cPanel control panel )

      • /scripts/installruby
      • /usr/local/cpanel/bin/ror_setup
    • /usr/bin/yum install ncurses-devel
  6. Compile and install FLVtool2
    • cd /usr/local/src/flvtool2_1.0.5_rc6/
    • /usr/bin/ruby setup.rb config
    • /usr/bin/ruby setup.rb setup
    • /usr/bin/ruby setup.rb install
  7. Compile and install LAME
    • cd /usr/local/src/lame-398-2
    • ./configure
    • make
    • make install
  8. Compile and install libOGG
    • cd /usr/local/src/libogg-1.1.4
    • ./configure
    • make
    • make install
    • PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
    • export PKG_CONFIG_PATH
  9. Compile and install LibVorbis
    • cd /usr/local/src/libvorbis-1.2.2
    • ./configure
    • make
    • make install
  10. Compile and install Libtheora
    • cd /usr/local/src/libtheora-1.1.1
    • ./configure –with-ogg-libraries=/usr/local/lib/
    • make
    • make install
  11. Compile and install AMRNB
    • cd /usr/local/src/amrnb-7.0.0.2
    • ./configure
    • make
    • make install
  12. Compile and install AMRWB
    • cd /usr/local/src/amrwb-7.0.0.2
    • ./configure
    • make
    • make install
  13. Compile and install Liba52
    • cd /usr/local/src/a52dec-0.7.4
    • ./bootstrap
    • ARCh=’arch’
    • ./configure –enable-shared
    • make
    • make install
  14. Compile and install FAAC
    • cd /usr/local/src/faac-1.28
    • ./bootstrap
    • ./configure –with-mp4v2
    • make
    • make install
  15. Compile and install FAAD
    • cd /usr/local/src/faad2-2.7
    • ./configure –with-mpeg4ip
    • make
    • make install
  16. Compile and install XVIDCore
    • cd /usr/local/src/xvidcore/build/generic/
    • ./configure
    • make
    • make install
  17. Download the latest X264 Snapshot from the subversion
    • cd /usr/local/src/x264-snapshot-20080324-2245
    • ./configure –enable-shared
    • make
    • make install
  18. Compile and install RE2C
    • cd /usr/local/src/re2c-0.13.5
    • ./configure
    • make
    • make install
    • cp -aP /usr/local/bin/re2c /usr/bin/
  19. Download the latest FFmpeg/MPlayer from the subversion
    • /usr/bin/svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg -r15336
    • /usr/bin/svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
    • cd /usr/local/src
    • /usr/bin/svn update
  20. Compile and install MPlayer
    • cd /usr/local/src/mplayer
    • ./configure
    • make
    • make install
  21. Compile and install FFmpeg
    • cd /usr/local/src/ffmpeg/
      This command is one single line:
    • ./configure –enable-shared –enable-nonfree –enable-gpl –enable-pthreads –enable-liba52 –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libmp3lame –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid –enable-cross-compile
    • make
    • make install
    • export LD_LIBRARY_PATH=/usr/local/lib/
  22. Finalize the codec setups:
    (Make sure these libraries exist on your server in their respective directories. FYI: the number which comes after the extension *.so might differe from one server to another.)

    • ln -s /usr/local/lib/libavformat.so.52.18.0 /usr/lib/libavformat.so.50
    • ln -s /usr/local/lib/libavcodec.so.51.62.0 /usr/lib/libavcodec.so.51
    • ln -s /usr/local/lib/libavutil.so.49.7.0 /usr/lib/libavutil.so.49
    • ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
    • /sbin/ldconfig
  23. Compile and install FFmpeg-Php
    • cd /usr/local/src/ffmpeg-php-0.6.0/
    • /usr/bin/phpize
    • ./configure
    • make
    • make install
      Check and see if ffmpeg-php module is saved in
    • ls -al /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so
  24. Install FFmpeg-Php (make sure the local path to your php.ini is correct.)
    • /bin/echo ‘extension=ffmpeg.so’ >> /usr/local/lib/php.ini
  25. Restart Apache to load FFmpeg-Php (This is for RedHat/CentOS v5.x)
    • /sbin/service httpd restart

Let’s see if FFmpeg is working. Run the following command:

  • php -r ‘phpinfo();’ | grep ffmpeg

If you get a few lines similar to the following:

ffmpeg
ffmpeg-php version => 0.6.0-svn
ffmpeg-php built on => Dec  5 2009 15:31:45
ffmpeg-php gd support  => enabled
ffmpeg libavcodec version => Lavc51.62.0
ffmpeg libavformat version => Lavf52.18.0
ffmpeg swscaler => disabled
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0

That means FFmpeg, FFmpeg-Php, MPlayer, MEncoder, FLV2tool, LAME MP3 encoder & libOGG are working.

Tags: Linux Software / Scripts

1 response so far ↓

  • 1 Install FFMPEG from source | LUGIE // Dec 23, 2009 at 8:50 am

    [...] the original post here: Install FFMPEG from source This entry was posted on Tuesday, December 22nd, 2009 at 4:08 pm and is filed under news. You [...]

Leave a Comment