Install FFmpeg and FFmpeg-PHP on Cpanel

[Total: 3    Average: 3.7/5]

How To Install FFmpeg and FFmpeg-PHP on Cpanel Server ?

Install FFmpeg and FFmpeg-PHP on Cpanel

Install FFmpeg and FFmpeg-PHP on Cpanel

FFMPEG is a fantastic tool if you’re developing a video content-based website like YouTube, Vimeo, or any other website that relies on uploaded videos. FFMPEG allows developers to decode, encode, transcode, mux, demux, stream, filter and play almost any kind of video ever created. It’s very compatible with old videos and also with the latest edge formats.

Sometimes this installation process may be difficult or you may find lot of errors while compiling if you are using source code, however we will use rpm files for the ffmpeg installation and will compile only the php-ffmpeg extension. Let’s begin.

Install the ATRPM repo

rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
rpm -ivh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm

Install package libdc1394:

yum install libdc1394-devel

Install ffmpeg and ffmpeg-devel packages:

yum -y --enablerepo=atrpms install ffmpeg ffmpeg-devel

Test FFMPEG

You should see this kind of output

[root@server:~]ffmpeg -version
ffmpeg version 2.2.1
built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100

Now let’s begin with php-ffmpeg extension, which will allow you to manipulate video and audio via PHP programming laguage:

Backup your current php.ini file

cp /usr/local/lib/php.ini /usr/local/lib/php.ini.backup

Install Git

yum -y install git

Download and compile

cd /root/
git clone https://github.com/tony2001/ffmpeg-php.git
cd ffmpeg-php
phpize
./configure
make
make install

Edit your php.ini

nano -w /usr/local/lib/php.ini

At the end of the file, add the extension so PHP can load it:

extension="ffmpeg.so"

Save your file and restart httpd to apply changes:

service httpd restart
php -i | grep ffmpeg

That should give you a big output like this:

[root@server:~]php -i | grep ffmpeg
ffmpeg
ffmpeg-php version => 0.7.0
ffmpeg-php built on => Aug 4 2015 23:38:38
ffmpeg-php gd support => disabled
ffmpeg libavcodec version => Lavc55.52.102
ffmpeg libavcodec license => GPL version 3 or later
ffmpeg libavformat version => Lavf55.33.100
ffmpeg libavformat license => GPL version 3 or later
ffmpeg swscaler version => SwS2.5.102
ffmpeg swscaler license => GPL version 3 or later

How can I convert a video file?

It’s pretty easy in fact, just like this:

[root@server:~] ffmpeg -i input.mp4 output.avi