How to Install FFMPEG and all its modules FFMPEG-PHP

Installing FFMPEG

This guide will show you step by step how to install ffmpeg. First, you will want to connect to your server’s shell as root. Once you are connected, you will

want to ensure that your /tmp partition is writeable so you can properly compile the modules. Use this command:

mount -o defaults,remount,rw /tmp

Next we will begin installing the individual components that FFMPEG needs to operate properly. First, we will want to download and install libogg using the

following commands:

wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
tar -xzvf libogg-1.1.3.tar.gz
cd libogg-1.1.3
./configure –prefix=/usr && make
make install
cd ../
rm -rf libogg*

Next, we will be downloading and installing libvorbis:


wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz
tar -xzvf libvorbis-1.2.0.tar.gz
cd libvorbis-1.2.0
./configure –prefix=/usr && make
make install
cd ../
rm -rf libvorbis*

Next we will be downloading and installing LAME, which ffmpeg uses for handling the audio components. 

wget http://internap.dl.sourceforge.net/sourceforge/lame/lame-398.tar.gz
tar -xzvf lame-398.tar.gz
cd lame-398
./configure –enable-shared –prefix=/usr
make
make install
cd ..
rm -rf lame*

After LAME is installed, we can install ffmpeg itself by running these commands:

wget http://ffmpeg.mplayerhq.hu/releases/ffmpeg-export-snapshot.tar.bz2
tar -xjvf ffmpeg-export-snapshot.tar.bz2
cd ffmpeg-export-XXXXXXX
./configure –enable-libmp3lame –enable-libvorbis –enable-shared
make clean && make
make install
mkdir /usr/local/include/ffmpeg
cp libavformat/avio.h /usr/local/include/ffmpeg
cp libavformat/avformat.h /usr/local/include/ffmpeg
cp libavcodec/avcodec.h /usr/local/include/ffmpeg
cd ..
rm -rf ffmpeg*

The base ffmpeg component is now installed, but we arent done yet! Next up is ruby, which is required for ffmpeg to function properly. Install it with these 

commands:

wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz
tar -xzvf ruby-1.8.7.tar.gz
cd ruby-1.8.7
./configure; make; make install;
cd ..
rm -rf ruby*

After ruby we need to install FLVTool2, which lets ffmpeg interact with flash based video files.

wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
tar -xzvf flvtool2-1.0.6.tgz
cd flvtool2-1.0.6
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd ..
rm -rf flvtool2*

Next we have to download and install the ffmpeg-php module. Do so with these commands:

wget http://internap.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
tar -xjvf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
phpize
./configure && make
make install
cd ..
rm -rf ffmpeg*

!!!IMPORTANT!!! There will be a PHP extensions folder output to the screen. Save it for later. !!!IMPORTANT!!!

!!!IMPORTANT!!!
“/usr/local/lib/php/extensions/no-debug-non-zts-20060613/” <— looks something like this !!!IMPORTANT!!!

We have one more thing to install, thats thats the MPlayer/Mencoder application. Do so with these commands:

wget http://www4.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2
tar -xjvf MPlayer-1.0rc2.tar.bz2
cd MPlayer-1.0rc2
./configure && make; make install
cd ..
rm -rf MPlayer*

Now that we have all the required components installed, we need to change /tmp back to normal with this command:

mount -o defaults,remount /tmp

After that, we need to open up the global php.ini file ( /usr/local/lib/php.ini ) so we can change a couple of settings. You can use whatever text editor you

like, but I recommend nano:

nano /usr/local/lib/php.ini

You will want to scroll down until you locate these lines:

; Directory in which the loadable extensions (modules) reside.
extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-20060613″


You will want to replace the extensions_dir value with the extensions folder that we saved earlier. 

!!!IMPORTANT!!!
If you are using any other custom .so modules, you will want to copy them into this folder. !!!IMPORTANT!!!

Scroll down to the “Dynamic Extensions” section, and add this line:

extension = ffmpeg.so


Save your work, ( ctrl+O if you are using nano ) and exit. FFMPEG is now installed and ready for use.