This article describe how to install ffmpeg, mplayer, mencoder, flvtool2, ffmpeg-php with all supported codecs to convert / manipulate videos easily on CentOS 5.x. If you want to run sites like youtube, this article will help you to install the base for your software.

1. Setting-up RPMForge respository.

RPMForge repository (http://dag.wieers.com) is the biggest rpm respository for RHEL, CentOS for all versions. Setup the RPMForge repository as mentioned here.

2. Install ffmpeg, mplayer, mencoder with all supported modules. Now we have rpmforge repository, so we will use yum to install ffmpeg, mplayer, mencoder as well as all dependent software.

yum -y install ffmpeg ffmpeg-devel mplayer mencoder flvtool2

This command will some time to download and install all packages depends on your internet speed.

3. Install FFMPEG-PHP

ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. ffmpeg-devel and php-devel is needed to compile ffmpeg-php from source code. Use following steps to install ffmpeg-php

cd /usr/src
wget http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-x.x.x.tbz2
tar jxvf ffmpeg-php-x.x.x.tbz2
cd ffmpeg-php-x.x.x
make install

It will copy the ffmpeg.so module in php default module location. Now you have to edit php.ini file to enable ffmpeg-php support in it by using ffmpeg.so module.

vi /etc/php.ini

and append following line


Restart apache service to take effect of php.ini

/etc/init.d/httpd restart

If you are getting the following error while compiling the latest release of ffmpeg-php-0.6.0, follow the below steps.


/usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function âzim_ffmpeg_frame_toGDImageâ:
/usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: âPIX_FMT_RGBA32â undeclared (first use in this function)
/usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once
/usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.)
/usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function âzim_ffmpeg_frame_ffmpeg_frameâ:
/usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: âPIX_FMT_RGBA32â undeclared (first use in this function)
make: *** [ffmpeg_frame.lo] Error 1


Under the ffmpeg-php-0.6.0 directory modify the file: ffmpeg_frame.c with nano or vi editor and replace every instance of PIX_FMT_RGBA32 with PIX_FMT_RGB32

1. vi ffmpeg_frame.c

2. Search for PIX_FMT_RGBA32 and replace it with PIX_FMT_RGB32

3. Exit from the editor

Then run the following commands:

cd /usr/local/src/ffmpeg-php-0.6.0
cp -aP ffmpeg_frame.loT ffmpeg_frame.lo
make clean
make install

This should fix the errors given above. Finally add the ffmpeg.so extension in php.ini and check phpinfo for the server you should see ffmpeg listed.

Run following command to ffmpeg module listing in php.

php -m | grep ffmpeg

Enjoy streaming!!