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
[dag]
name=DAG RPM Repository
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
# end of dag.repo file
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
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
#wget http://nchc.dl.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
#tar -xjf ffmpeg-php-0.6.0.tbz2
#cd ffmpeg-php-0.6.0
#phpize
#./configure

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

/usr/include/libavcodec/avcodec.h:3452)
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
#make install

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

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

Add below lines at the end of php.ini
[ffmpeg]
extension=ffmpeg.so

## 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

  • 45 Users Found This Useful
Was this answer helpful?
Related Articles
Copyright © 2019 Temok IT Services. All Rights Reserved.
Positive SSL