Add ffmpeg

Import the GPG key from the repo:


# rpm -ivh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
Retrieving http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:atrpms-repo            ########################################### [100%]

Install the ATRPMS Repo:


#rpm -ivh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm

Install

 # yum -y --enablerepo=atrpms install ffmpeg ffmpeg-devel
]# 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

Check the supported formats:


ffmpeg -format

Test converting videos. Here’s an example from mp4 to h264:


cd /usr/local/src
wget https://archive.org/download/WoodstockFestivalTrailer/Woodstock_Festival_Trailer.avi
ffmpeg -i Woodstock_Festival_Trailer.avi -vcodec libx264 Woodstock_Festival_Trailer-H264.avi
After done, you should see the new H264 file:

-rw-r--r-- 1 root root 20M May 4 2006 Woodstock_Festival_Trailer.avi
-rw-r--r-- 1 root root 15M Jan 30 10:01 Woodstock_Festival_Trailer-H264.avi

How can I work with ffmpeg using PHP?

Simple. Just install php-ffmpeg extension. First, install REMI repo in order to get your php-ffmpeg package, then type:


yum install php-ffmpeg
Verify ffmpeg is loading from PHP:

php -i | grep ffmpeg -i

If you see this, it’s working:


[root@nginxtips.com:~]php -i | grep ffmpeg -i
/etc/php.d/ffmpeg.ini,
ffmpeg
ffmpeg-php version => 0.7.0
ffmpeg-php built on => Jan  1 2013 09:50:55
ffmpeg-php gd support  => enabled
ffmpeg libavcodec version => Lavc53.61.100
ffmpeg libavcodec license => GPL version 3 or later
ffmpeg libavformat version => Lavf53.32.100
ffmpeg libavformat license => GPL version 3 or later
ffmpeg swscaler version => SwS2.1.100
ffmpeg swscaler license => GPL version 3 or later

Examples

# ffmpeg -i source.wmv -s 500x400 -vcodec libx264 -strict -2 destination.mp4
# ffmpeg -i source.wmv -strict -2 destination.mp4

Resources:

http://www.nginxtips.com/ffmpeg-php-ffmpeg-centos-6-7/

https://trac.ffmpeg.org/wiki/CompilationGuide/Centos

http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat

https://chrisjean.com/install-ffmpeg-and-ffmpeg-php-on-centos-easily/

http://www.cpanelkb.net/ffmpeg-auto-install-shell-script/

Leave a Comment