Install ffmpeg, flvtool2, mplayer, mencoder and ffmpeg-php in cPanel, DirectAdmin, CentOS 6, RHEL 6

Install ffmpeg, flvtool2, mplayer, mencoder and ffmpeg-php in cPanel, DirectAdmin, CentOS 6, RHEL 6 – 64bit

This is by far the easiest way to get up and running with ffmpeg and assorted tools on a cPanel / DirectAdmin / RHEL 6 / CentOS 6 64bit server.

I can’t take credit for all of it, however the original site where I found it has long since been offline with nothing similar replacing it.

Hopefully these instructions help others as they have helped me.

First, install rpmforge so you don’t have to compile a bunch of components from scratch:

cd /usr/src;
rpm -ivh https://dl.dropboxusercontent.com/u/32483919/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm;

Now, edit ‘/etc/yum.conf’ and remove ‘ruby*’ from the excludes list.

This is just to get past the next step; we must restore it later.

Now, install the required packages:

yum install ffmpeg ffmpeg-devel flvtool2 mplayer mencoder lame libogg libvorbis libtheora swftools amrnb amrwb transcode x264;

Now, add ‘ruby*’ back to the excludes list in ‘/etc/yum.conf’ to keep cPanel happy. but not necessary for DirectAdmin

Install Mplayer directly from source:

wget https://dl.dropboxusercontent.com/u/32483919/essential-20071007.tar.bz2;
tar xjf essential-20071007.tar.bz2;
mv essential-20071007 /usr/lib/codec;
mkdir /usr/local/include/ffmpeg/;
/bin/cp -rvf /usr/include/lib{avcodec,avdevice,avformat,avutil,swscale} /usr/local/include/ffmpeg/;
/bin/cp -rvf /usr/include/lib{avcodec,avdevice,avformat,avutil,swscale}/*.h /usr/local/include/ffmpeg/;

 Same with the ffmpeg PHP module:

wget https://dl.dropboxusercontent.com/u/32483919/ffmpeg-php-0.6.0.tbz2;
tar xjf ffmpeg-php-0.6.0.tbz2;
cd ffmpeg-php-0.6.0;
phpize;
./configure && make;
make install;

Add after the ‘extension_dir’ and ‘zend_extension’ entries in the php.ini:

extension="ffmpeg.so"

Test your installation with the following command. I’ve included the raw shell output so you know what you should be seeing:

root@dotenterprise-demo [~]# php -i | grep ffmpeg
ffmpeg
ffmpeg-php version => 0.6.0-svn
ffmpeg-php built on => Apr 28 2010 15:40:49
ffmpeg-php gd support  => enabled
ffmpeg libavcodec version => Lavc52.20.0
ffmpeg libavformat version => Lavf52.31.0
ffmpeg swscaler version => SwS0.7.1
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0

UPDATE!!! —- 24 Jul 2014 —

I fix error in php 5.4 (remi) while building ffmpeg-php for Vesta Control Panel

sed -i 's/list_entry *le/zend_rsrc_list_entry *le/g' ffmpeg_movie.c;
sed -i 's/list_entry new_le/zend_rsrc_list_entry new_le/g' ffmpeg_movie.c;
sed -i 's/hashkey_length+1, (void *)&new_le, sizeof(list_entry)/hashkey_length+1, (void *)&new_le,sizeof(zend_rsrc_list_entry)/g' ffmpeg_movie.c;
perl -pi -e "s/PIX_FMT_RGBA32/PIX_FMT_RGB32/g" ffmpeg_frame.c;
make clean;
phpize;
./configure && make;
make install;

 

Update

In certain situations, you may end up with the following error:

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

To resolve this, search for all instance of “PIX_FMT_RGBA32″ and replace with “PIX_FMT_RGB32″ in ffmpeg_frame.c and recompile:

perl -pi -e "s/PIX_FMT_RGBA32/PIX_FMT_RGB32/g" ffmpeg_frame.c;
make clean;
phpize;
./configure && make;
make install;

Done! Hopefully this help! Later guys!

 

!!!!!Update 14 Jun 2014@ Thanks and Credit to Vinay Kb!!!!

if you face a bug like this 
"/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:311: error: (Each undeclared identifier is reported only once /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:311: error: for each function it appears in.) /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:311: error: âleâ undeclared (first use in this function) /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:346: error: expected â;â before ânew_leâ /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:356: error: ânew_leâ undeclared (first use in this function) /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_movie.c: In function âzim_ffmpeg_movie_getCommentâ: /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:531: warning: âcommentâ is deprecated (declared at /usr/local/include/l ibavformat/avformat.h:760) "

then just make these changes in ffmpeg_movie.c:

By using nano ffmpeg_movie.c command then find the exact row and make these changes 
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),

It will work without any problem now rock with your streamings 😉

UPDATE!! — 03 Jul 2014 —

If you have any problem with ffmpeg-php like any error on centos. Please try this

yum install -y git*;
cd /usr/src/;
git clone https://github.com/tony2001/ffmpeg-php;
cd ffmpeg-php;
phpize;
./configure;
make && make install;