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: 3894

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.

ffmpeg


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

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el5/en/x86_64/dag
gpgcheck=1
enabled=1

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 ld.so.conf as follows:

echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf

Note: be sure the following line is included in /etc/ld.so.conf:
include ld.so.conf.d/*.conf

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 http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-1.el5.rf.x86_64.rpm

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


ffmpeg-php


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

~# wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2

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

./configure

./make

./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 "extension=ffmpeg.so" 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


pecl


This is super easy:

$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar


ImageMagick


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 "extension=imagick.so" > /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

RSS