How to install FFMPEG and FFMPEG-PHP install on CentOS 5.X

To install FFMPEG please follow the below steps.

Create a new file called /etc/yum.repos.d/dag.repo

nano /etc/yum.repos.d/dag.repo

Add the following text to the file.

[dag]
name=DAG RPM Repository
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1

Run the following in the command line.

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Now you are ready to install FFMPEG

First run

yum update

then

yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc

Now FFMPEG should have been installed.

Now let's prepare to installing FFMPEG-PHP

Download the latest FFMPEG-PHP package:

cd /usr/local/src
wget http://downloads.sourceforge.net/ffmpeg-php/ffmpeg-php-0.6.0.tbz2

Extract the package then build and install it. Use following commands to do that.

tar xjf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
sed -i 's/PIX_FMT_RGBA32/PIX_FMT_RGB32/g' ffmpeg_frame.c
phpize
./configure
make
make install

The make install command will show PHP extensions path where ffmpeg PHP extension is installed.

root@server [~/ffmpeg-php-0.6.0]# make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

Now edit php.ini file. Nano editor can be used to do this.

nano /usr/local/lib/php.ini

Make sure that value of extension_dir is set to PHP extension directory as given by above make install command.

extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"

Add following line just below extension_dir and this will enable ffmpeg PHP extension.

extension="ffmpeg.so"

Restart Apache to make this change in effect. apachectl restart 

or /sbin/service httpd restart

Verify the status of ffmpeg extension on a PHP info web page or from command line as given below.

root@server [~]# php -i | grep ffmpeg
ffmpeg
ffmpeg-php version => 0.6.0-svn
ffmpeg-php built on => Jun 2 2012 20:48:04
ffmpeg-php gd support => enabled
ffmpeg libavcodec version => Lavc52.123.0
ffmpeg libavformat version => Lavf52.111.0
ffmpeg swscaler version => SwS0.14.1
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0
OLDPWD => /root/ffmpeg-php-0.6.0
_SERVER["OLDPWD"] => /root/ffmpeg-php-0.6.0
_ENV["OLDPWD"] => /root/ffmpeg-php-0.6.0

Check the installation Paths Following are the file system paths of tools that have been installed. ffmpeg:/usr/bin/ffmpeg

Now open yum.conf nano /etc/yum.conf

and add ffmpeg* in exclude line.

Some Errors here /root/ffmpeg/ffmpeg-php-0.7.0/ffmpeg_movie.c: In function 'zim_ffmpeg_movie___construct':
/root/ffmpeg/ffmpeg-php-0.7.0/ffmpeg_movie.c:318: error: 'list_entry' undeclared (first use in this function)
/root/ffmpeg/ffmpeg-php-0.7.0/ffmpeg_movie.c:318: error: (Each undeclared identifier is reported only once
/root/ffmpeg/ffmpeg-php-0.7.0/ffmpeg_movie.c:318: error: for each function it appears in.)
/root/ffmpeg/ffmpeg-php-0.7.0/ffmpeg_movie.c:318: error: 'le' undeclared (first use in this function)
/root/ffmpeg/ffmpeg-php-0.7.0/ffmpeg_movie.c:353: error: expected ';' before 'new_le'
/root/ffmpeg/ffmpeg-php-0.7.0/ffmpeg_movie.c:363: error: 'new_le' undeclared (first use in this function)

Solution: Changes in ffmpeg_movie.c:
row 311: list_entry *le; TO zend_rsrc_list_entry *le;
row 346: list_entry new_le; TO zend_rsrc_list_entry new_le;
row 360: hashkey_length+1, (void *)&new_le, sizeof(list_entry), TO
hashkey_length+1, (void *)&new_le,sizeof(zend_rsrc_list_entry)

Was this answer helpful? 148 Users Found This Useful (253 Votes)