How To Install FFmpeg and FFmpeg-PHP Extension on CentOS

Install FFmpeg and FFmpeg-PHP Extension on CentOS

For those of you who didn’t know, FFmpeg is a cross-platform solution for streaming audio and video as well as recording and conversion. There’s also a great PHP package called ffmpeg-php that allows for easy use of FFmpeg from inside PHP scripts. In this tutorial i will show you the easy way to install ffmpeg and ffmpeg-php (PHP extension).

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges.

Install FFmpeg on CentOS

Step 1. First, let’s start by ensuring your system is up-to-date.

sudo yum clean all
sudo yum update
sudo yum install php-gd php-devel

Step 2. To install, first you must add the DAG yum repository information corresponding to your CentOS/RHEL version to yum:

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

Add the following text to the file and save:

name=DAG RPM Repository

After add Dag repository, Use yum to install FFmpeg using following command.

#rpm --import #yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc

 Install FFmpeg and FFmpeg-PHP Extension on CentOS

FFmpeg Basic Commands

#ffmpeg -version:            show version
#ffmpeg -formats:            show available formats
#ffmpeg -codecs:             show available codecs
#ffmpeg -decoders:           show available decoders
#ffmpeg -encoders:           show available encoders
#ffmpeg -bsfs:               show available bit stream filters
#ffmpeg -protocols:          show available protocols
#ffmpeg -pix_fmts:           show available pixel formats
#ffmpeg -layouts:            show standard channel layouts
#ffmpeg -sample_fmts:        show available audio sample formats
#ffmpeg -filters:            show available filters

 Install FFmpeg-PHP Extension on CentOS

Step 1. Download the latest ffmpeg-php release

tar -xjf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
make install

If you get  [ffmpeg_movie.lo] Error 1 when compiling ffmpeg-php, then you will need to do:

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

Install FFmpeg on CentOS and FFmpeg-PHP Extension 

Copy the module in PHP default module location. Now you have to edit php.ini file to enable FFmpeg-php support in it by using module.

#nano /etc/php.ini

Put the below two lines at the end of the php.ini file


FFmpeg-PHP extension should now be installed. You can check by creating a file called info.php in /var/www/html/ with the following content:


FFmpeg Install Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “FFmpeg” installation, starting from $10 (Paypal payment). Please contact us to get a best deal!