his post will provide you with the instructions to download and install ffmpeg, ffmpeg-php, flvtool, lame, mplayer, libogg, libvorbis, mencoder, and other codecs used with ffmpeg. 1 # cd /usr/local/src 1 wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz 2 wget http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz 3 wget http://www.mplayerhq.hu/MPlayer/releases/mplayer-export-snapshot.tar.bz2 4 wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2 5 wget http://downloads.xiph.org/releases/ogg/libogg-1.2.0.tar.gz 6 wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.1.tar.gz 7 wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2 8 wget http://ffmpeg.org/releases/ffmpeg-1.0.tar.gz 1 tar xvzf flvtool2-1.0.6.tgz 2 tar xvzf lame-3.98.4.tar.gz 3 tar jxvf ffmpeg-php-0.6.0.tbz2 4 tar xvzf libogg-1.2.0.tar.gz 5 tar xvzf libvorbis-1.3.1.tar.gz 6 tar jxvf essential-20071007.tar.bz2 7 tar jxvf mplayer-export-snapshot.tar.bz2 8 tar xvzf ffmpeg-0.6.tar.gz
Make a directory to store all the codecs: 1 # mkdir /usr/local/lib/codecs/
Install any necessary packages: 1 yum install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++ ncurses-devel
Installing Lame: 1 cd /usr/local/src/lame-3.98.4 2 ./configure 3 make && make install
Installing Libogg: 1 cd /usr/local/src/libogg* 2 ./configure && make && make install 3 Installing libvorbis: 1 cd /usr/local/src/libvorbis* 2 ./configure && make && make install
Installing flvtool2: 1 cd /usr/local/src/flvtool* 2 ruby setup.rb config 3 ruby setup.rb setup 4 ruby setup.rb install 1 # cd /usr/local/src/mplayer* 2 ./configure && make && make install
(If you need to customize your install, run “./configure –help” to see a complete list of the available flags) 1 make && make install 1 ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50 2 ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51 3 ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49 4 ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0 5 ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
Installing ffmpeg-php: 1 # cd /usr/local/src/ffmpeg-php* 2 phpize 3 ./configure
There’s a small issue in this version of ffmpeg-php which, when “make” is run, will cause the following error: 1 gcc -I. -I/usr/local/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/local/src/ffmpeg-php-0.6.0/include -I/usr/local/src/ffmpeg-php-0.6.0/main -I/usr/local/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include/libavcodec/ -I/usr/local/include/libavformat/ -I/usr/local/include/libavutil/ -I/usr/local/include/libswscale/ -I/usr/local/include/libavfilter/ -I/usr/local/include/libavdevice/ -I/usr/include/php -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c -fPIC -DPIC -o .libs/ffmpeg_frame.o 2 /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function 'zim_ffmpeg_frame_toGDImage': 3 /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: 'PIX_FMT_RGBA32' undeclared (first use in this function) 4 /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once 5 /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.) 6 /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function 'zim_ffmpeg_frame_ffmpeg_frame': 7 /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: 'PIX_FMT_RGBA32' undeclared (first use in this function) 8 make: *** [ffmpeg_frame.lo] Error 1
To correct this issue, we’ll update ffmpeg_frame.c and replace every instance of PIX_FMT_RGBA32 with PIX_FMT_RGB32 1 vi ffmpeg_frame.c 1 :%s/PIX_FMT_RGBA32/PIX_FMT_RGB32 2 3 :w :q!
Now we can proceed with compiling: 1 make 2 make install
Now that we’ve compiled, let’s make sure that ffmpeg.so is in the proper extensions directory: 1 php -i | grep extensions 2 /usr/local/lib/php/extensions/no-debug-non-zts-20060613
Now we’ll tell PHP that it needs to load our module: 1 echo 'extension=ffmpeg.so' >> /usr/local/lib/php.ini
Restart apache: 1 service httpd restart
Now we’ll do a quick list of the modules to ensure that ffmpeg-php is loaded: 1 php -m | grep ffmpeg 2 ffmpeg
All done!
if you get [root@server ~]# ffmpeg ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory