Installing ffMPEG and Audio Binaries
Categories: Third-Party Software.
Source: v-nessa.net
ffMPEG commonly consists of and includes the following software:
- Essential / MPlayer
- FLVtool2 (Requires a Ruby Core)
- LAME MP3 Encoder
- php-ffMPEG
- ffMPEG
- libOgg
- libvorbis
To start out, enter into a temporary source directory and download all the binaries:
cd /usr/src wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2 wget http://www4.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2 wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
*These are the latest stable versions at the time this article was written. If you are unable to download any of the above, you’ll need to visit the distributor’s site and download the latest stable version available.
Now extract everything:
bunzip2 essential-20061022.tar.bz2; tar xvf essential-20061022.tar tar zxvf flvtool2-1.0.6.tgz tar zxvf lame-3.97.tar.gz bunzip2 ffmpeg-php-0.5.0.tbz2; tar xvf ffmpeg-php-0.5.0.tar bunzip2 MPlayer-1.0rc2.tar.bz2 ; tar -xvf MPlayer-1.0rc2.tar
Create and import the Codecs directory:
mkdir /usr/local/lib/codecs/ mv essential-20061022/* /usr/local/lib/codecs/ chmod -Rf 755 /usr/local/lib/codecs/
Install Subversion and Ruby
yum install subversion yum install ruby (If you’re on cPanel you can alternatively use /scripts/installruby) yum install ncurses-devel
Get ffMPEG and MPlayer from SVN:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
Install LAME:
cd /usr/src/lame-3.97 ./configure && make && make install
Install libOgg and libVorbis:
yum install libogg.i386 yum install libvorbis.i386 yum install libvorbis-devel.i386
Install flvtool2
cd /usr/src/flvtool2-1.0.6/ ruby setup.rb config ruby setup.rb setup ruby setup.rb install
Install MPlayer:
cd /usr/src/MPlayer-1.0rc2 ./configure && make && make install
Install ffMPEG:
cd /usr/src/ffmpeg/ ./configure –enable-libmp3lame –enable-libvorbis –disable-mmx –enable-shared make && make install
This is the typical configure line that I use, but you can customize this to what you need. For available configure options, type ./configure –help. Your custom configuration may require the installation of additional software on the server.
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50 ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51 ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49 ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0 ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
You may get an error about a library path not being found, if so, run
export LD_LIBRARY_PATH=/usr/local/lib
If this is being installed on a dedicated server, you might also get an error about the /tmp directory not be executable, which is common when installing on a dedicated server with a separate /tmp partition mounted noexec. In this case, you will need to create a tmp dir in the ffmpeg folder and use that as the tmp disk for now:
mkdir tmp chmod 777 tmp export TMPDIR=./tmp
Then run the configure command and set the TMPDIR variable back.
export TMPDIR=/tmp
Install ffMPEG-php
cd /usr/src/ffmpeg-php-0.5.0/ phpize ./configure && make && make install
ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg ln -s /usr/local/bin/mplayer /usr/bin/mplayer
When the installation is complete, it will give you a long path to the shared libraries. This needs to be copied to the php.ini as so:
[ffmpeg] extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so
or in most cases where the extension_dir variable is set, just do:
extension=”/ffmpeg.so”
The ‘no-debug-non-zts-xxxxxxxx’ directory will be the one provided during installation. When this is done, restart Apache and check that the module is loaded in PHP:
/etc/init.d/httpd restart php -r ‘phpinfo();’ | grep ffmpeg
Look for this:
ffmpeg fmpeg support (ffmpeg-php) => enabled ffmpeg-php version => 0.5.0 ffmpeg.allow_persistent => 0 => 0
If you only get output for the ‘PWD’ variables, make sure that the extension_dir path is correct in the phpinfo file. Sometimes there are two specified, and if that is the case then the incorrect one should be commented out.
Test out ffmpeg for errors just by typing ffmpeg at the command line. The most common error is:
ffmpeg: error while loading shared libraries: libavformat.so.51: cannot open…
To correct this, edit /etc/ld.so.conf and add the line
/usr/local/lib
then save and exit.
Now run this command to reload the library cache:
ldconfig -v
You’re all done…enjoy!