I know you’ve provably seen a lot of guides on how to install ffMPEG, but I’ve noticed that most of them are incomplete and don’t cover the possible issues that can arise during installation. I’ve installed ffMPEG on dozens of servers and have devised a standardized procedure on what I feel is the best way to perform this installation.
This walkthrough has been tested on systems running Redhat 9, RHEL 4, and CentOS 4.5 and it may also work on other distributions and versions. Our servers also run cPanel 11, but this is in no way required in order to install ffMPEG. I assume at this point that you have root access and that yum (or another similar package manager) is installed.
ffMPEG commonly consists of and includes the following software:
– Essential / MPlayer
– FLVtool2 (Requires a Ruby Core)
– LAME MP3 Encoder
To start out, enter into a temporary source directory and download all the binaries:
*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:
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
./configure && make && make install
Install libOgg and libVorbis:
yum install libogg.i386
yum install libvorbis.i386
yum install libvorbis-devel.i386
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
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
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.
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:
or in most cases where the extension_dir variable is set, just do:
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:
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
then save and exit.
Now run this command to reload the library cache:
You’re all done…enjoy!
./configure && make && make install