How to install ffmpeg and ffmpeg-php on Linux server

FFmpeg is the leading multimedia framework capable of decoding, encoding, transcoding, recording, converting and streaming digital audio and video in various formats. ffmpeg-php is a PHP extension which is used for accessing and retrieving information from video and audio files from within PHP scripts. Please follow steps below to install ffmpeg and ffmpeg-php on your VPS / dedicated server:

nano /etc/yum.repos.d/dag.repo
# add below entries in file
name=DAG RPM Repository
# end of dag.repo file
rpm --import
yum -y install ffmpeg ffmpeg-devel libogg libvorbis flvtool2 ffmpeg-libpostproc
yum install php-gd php-devel
yum install libogg.x86_64 libogg-devel.x86_64
yum install libvorbis.x86_64 libvorbis-devel.x86_64

mkdir /srv/build
cd /srv/build
#tar -xjf ffmpeg-php-0.6.0.tbz2
#cd ffmpeg-php-0.6.0

If you get below error
/srv/build/ffmpeg-php-0.6.0/ffmpeg_movie.c:1215: warning: ‘avcodec_decode_video’ is deprecated (declared at

make: *** [ffmpeg_movie.lo] Error 1

apply below changes

# nano 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),

Please also replace PIX_FMT_RGBA32 to PIX_FMT_RGB32 in ffmpeg_frame.c, to replace
nano ffmpeg_frame.c        # search for PIX_FMT_RGBA32 and replace it with PIX_FMT_RGB32

./configure --prefix=/usr --enable-shared

#make install

## copy extenstion under php extensions directory
cp /srv/build/ffmpeg-php-0.6.0/.libs/  /path/to/php/extemsionmodules/

## Add to php.ini # you can find this extension under ./lib/
nano /path/to/php.ini

Add below lines at the end of php.ini

## Now open yum.conf nano /etc/yum.conf and add ffmpeg* in exclude line.
nano /etc/yum.conf
exclue= ffmpeg*

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

php -i | grep ffmpeg

php -m | grep ffmpeg
Was this answer helpful? 51 Users Found This Useful (56 Votes)