Install ffmpeg-php on CentOS 6 with DirectAdmin

install-ffmpeg-php-on-a-centos-6-with-directadminIn this post, we will show you how to install ffmpeg and ffmpeg-php on a CentOS 6 VPS with a DirectAdmin control panel. 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.

This guide should work on other Linux VPS systems with DirectAdmin installed as well but was tested and written for CentOS 6 VPS.

Install FFmpeg

First of all download and install RPMForge repository using the following commands:

user@myVPS:~# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.$(arch).rpm
user@myVPS:~# rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.$(arch).rpm

Now you can install FFmpeg and some additional packages using yum.

user@myVPS:~# yum -y install ffmpeg ffmpeg-devel libogg libvorbis lame flvtool2 mencoder

Install ffmpeg-php

To download and extract the ffmpeg-php tarball, run:

user@myVPS:~# wget https://centos.googlecode.com/files/ffmpeg-php-0.6.0.tbz2
user@myVPS:~# tar -xjf ffmpeg-php-0.6.0.tbz2 
user@myVPS:~# cd ffmpeg-php-0.6.0

Run ‘phpize’ to create the necessary build scripts

user@myVPS:~# phpize

If you get an error message “phpize: command not found”, It means that phpize is not in the system PATH. In our case, using PHP FPM version 5.6 the full path to the phpize is ‘/usr/local/php56/bin/phpize’, so we need to run:

user@myVPS:~# /usr/local/php56/bin/phpize

Run “configure” to set the installation options, in our case the command is as follows:

user@myVPS:~# ./configure --with-php-config=/usr/local/php56/bin/php-config

You can find the locations of phpize and php-config binaries using the find command:

user@myVPS:~# find /usr/local/ -type f -name
user@myVPS:~# phpize find /usr/local/ -type f -name php-config

Run make to start the compilation:

user@myVPS:~# make

If you get an error message like make: *** [ffmpeg_movie.lo] Error 1 open the ffmpeg_movie.c file and make the following changes:

user@myVPS:~# vim ffmpeg_movie.c

Change list_entry *le; to zend_rsrc_list_entry *le;
Change list_entry new_le; to zend_rsrc_list_entry new_le;
Change hashkey_length+1, (void *)&new_le, sizeof(list_entry), to hashkey_length+1, (void *)&new_le,sizeof(zend_rsrc_list_entry),

and restart the compilation:

user@myVPS:~# make

to install the binaries run:

user@myVPS:~# make install

Once the installation is complete, open the php.ini file

user@myVPS:~# vim /usr/local/php56/lib/php.ini

change the extension_dir to point to the extension directory, in our case :

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

and append the following line to enable the ffmpeg extension

extension="ffmpeg.so"

Finally restart php-fpm for changes to take effect.

user@myVPS:~# service php-fpm56 restart

If you’re running PHP as an Apache module, then restart apache with the command below:

user@myVPS:~# service httpd restart

That’s it. You have successfully installed the ffmpeg-php extension.


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment