Ffmpeg on Centos 7 and Centos 6

Login to server via SSH

Below steps are for Centos 7

yum -y install epel-release

rpm –import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro

rpm -Uvh  http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release0-5.el7.nux.noarch.rpm

yum -y install ffmpeg ffmpeg-devel

 

Below steps are for Centos 6

yum -y install epel-release

rpm –import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro

wget https://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-1.el6.nux.noarch.rpm

rpm ivh  nux-dextop-release-0-1.el6.nux.noarch.rpm

yum -y install ffmpeg ffmpeg-devel

 

now we need to install ffmpeg-php to get it working using PHP

yum -y install git
git clone https://github.com/tony2001/ffmpeg-php.git

cd ffmpeg-php
/usr/local/cpanel/3rdparty/php/56/bin/phpize
/opt/cpanel/ea-php56/root/usr/bin/phpize
./configure –with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config

If you want to install on PHP 7 use

/opt/cpanel/ea-php7/root/usr/bin/phpize

 

[Usually before easyapache 4 only phpize would work] now as there are multiple version of PHP there is need to  phpize from above path.

The path would changes based on php version

if you are using PHP 7 path will be /opt/cpanel/ea-php70/root/usr/bin/phpize and

/opt/cpanel/ea-php70/root/usr/bin/php-config

You can find path using find command

[root@server ffmpeg-php]# find / -iname phpize
/opt/cpanel/ea-php55/root/usr/bin/phpize

/opt/cpanel/ea-php56/root/usr/bin/phpize

/opt/cpanel/ea-php70/root/usr/bin/phpize

 

Do not use path ./usr/local/cpanel/3rdparty/bin/phpize

 

Before compiling ffmpegphp

need to make sure all need files are in   /usr/include

When you install ffmpeg and ffmpeg-devel files get stored in  /usr/include/ffmpeg however ffmpeg while compiling looks for files in /usr/include/ so need to copy files to /usr/include using below command

scp -r /usr/include/ffmpeg/* /usr/include/

Now you can go ahead and compile

./configure –with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config

Note [Path /opt/cpanel/ea-php56/root/usr/bin/php-config will changed on which version you are installing ffmpeg]

[root@server ffmpeg-php]# find / -iname php-config

/opt/cpanel/ea-php55/root/usr/bin/php-config
/opt/cpanel/ea-php56/root/usr/bin/php-config
/opt/cpanel/ea-php70/root/usr/bin/php-config

 

now before making make and make install few things need to be modified.

mv /usr/include/libavutil/time.h /usr/include/libavutil/time.h_

now go ahead with make and make install

now   again need to rename the above file

mv  /usr/include/libavutil/time.h_    /usr/include/libavutil/time.h

 

 

ffmpeg modules will be installed in below path

root@server ffmpeg-php]# ls -al /opt/cpanel/ea-php56/root/usr/lib64/php/modules/
total 2712
drwxr-xr-x 2 root root 4096 Dec 7 07:07 .
drwxr-xr-x 4 root root 4096 Feb 22 2017 ..
-rwxr-xr-x 1 root root 32608 Feb 22 2017 bcmath.so
-rwxr-xr-x 1 root root 33792 Feb 22 2017 calendar.so
-rwxr-xr-x 1 root root 15584 Feb 22 2017 ctype.so
-rwxr-xr-x 1 root root 86928 Feb 22 2017 curl.so
-rwxr-xr-x 1 root root 180728 Feb 22 2017 dom.so
-rwxr-xr-x 1 root root 281640 Dec 7 07:07 ffmpeg.so
-rwxr-xr-x 1 root root 57792 Feb 22 2017 ftp.so

 

Now go ahead and add extension=ffmpeg.so to php.ini for the PHP version you need and restart apache