Reese Knowledgebase

How to install ffmpeg, ffmpeg-php, pecl, and ImageMagick

View Kristian Reese's profile on LinkedIn

If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 138
by: Reese K.
Posted: 21 Oct, 2013
Last updated: 21 Oct, 2013
Views: 3435

How to install ffmpeg, ffmpeg-php, pecl, and ImageMagick

The process below was tested on a CentOS 5.6 64bit system on 10/21/2013.  As long as the Internet based repositories listed within this kb article are online, this process will work.


Using your favorite editor, create an rpm repository file for DAG in /etc/yum.repos.d/ and insert the following text:

~# vi /etc/yum.repos.d/dag.repo

name=Dag RPM Repository for Red Hat Enterprise Linux

ffmpeg libraries will be installed in /usr/local/lib.  To ensure the libraries are in the search path of the run-time linker, add /usr/local/lib to as follows:

echo "/usr/local/lib" > /etc/

Note: be sure the following line is included in /etc/

Next, run the following command to create the necessary links and cache to the most recent shared libraries defined in the newly created ffmpeg.conf file.

~# ldconfig -v

In the final preparation step, setup a repository to RPMforge (click link for more info pertaining to this repo)

~# rpm -Uvh

Install ffmpeg and ffmpeg-devel

~# yum install ffmpeg ffmpeg-devel

In my installation, 59 packages were downloaded and installed.  To verify the installation, you can run this command:

~# ffmpeg -formats


Download ffmpeg-php source code from sourceforge and extract the contents

~# wget

~# tar -xvjf ffmpeg-php-0.6.0.tbz2

Next, prepare PHP extension for compiling using phpize.  cd into the directory of extracted contents and run phpize.  If phpize is not installed, then install the appropriate php-devel package for your php version.  In my case, php53 is installed so using yum.

~# yum install php53-devel.x86_64

~# phpize

At this point, you will need a compiler such as gcc installed.  If gcc or another compiler is not installed, the configure script will fail.  Install a compiler, or if already installed, proceed to the next step:



./make install

If, during the configure step, you encounter this error:

/root/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function 'zim_ffmpeg_frame_toGDImage':
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: 'PIX_FMT_RGBA32' undeclared (first use in this function)
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.)
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function 'zim_ffmpeg_frame_ffmpeg_frame':
/root/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

Run this command to change ffmpeg_frame.c source code and rerun the configure, make, make install:

~# sed -i -e 's/PIX_FMT_RGBA32/PIX_FMT_RGB32/g' ffmpeg_frame.c

Finally, edit php.ini and include "" in the Dynamic Extensions section and restart apache

-bash-3.1# /etc/init.d/httpd restart

To verify a successfull install:

-bash-3.1# php -r 'phpinfo();' | grep ffmpeg

-bash-3.1# php -m | grep ffmpeg


This is super easy:

$ wget
$ php go-pear.phar


Installing ImageMagick with the imagick php extension is as easy as following these steps:

~# yum install ImageMagick
~# yum install ImageMagick-devel
~# pecl install imagick

~# echo "" > /etc/php.d/imagick.ini
~# /etc/init.d/httpd restart

~# php -m | grep imagick

This article was:   Helpful | Not Helpful
Prev   Next
How to add a new LUN using EMC powerpath     Create a Logical Volume using Linux LVM