For EL6:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
Install FFMpeg from ATRPMS Repository:
yum -y install ffmpeg ffmpeg-devel
How to check if FFMPEG is working?
Verify the ffmpeg version:
ffmpeg -version
[[email protected]:~]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 -formats
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 as below:
Let’s download the RPM file for CentOS 5.x and CentOS 6.x:
EPEL repo for Centos 5.x
wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm rpm -Uvh epel-release-5*.rpm
EPEL repo for Centos 6.x
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh epel-release-6*.rpm
EPEL repo for Centos 7.x
wget http://download.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm rpm -Uvh epel-release-6*.rpm
That command will install the EPEL repo inside your /etc/yum.repos.d directory.
then
Manually, install FFmpeg-Php cd /usr/local/src wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2 tar jxvf ffmpeg-php-0.6.0.tbz2 cd ffmpeg-php-0.6.0 phpize ./configure make If you get (error make: *** [ffmpeg_frame.lo] Error 1) do this commands.
sed -i 's/PIX_FMT_RGBA32/PIX_FMT_RGB32/g' ffmpeg_frame.c OR vi ffmpeg_frame.c :%s/PIX_FMT_RGBA32/PIX_FMT_RGB32 :wq
Then rerun "./configure && make" and if all went fine make install make install If no error skil to step 5. Step 5. Now adding to php.ini echo 'extension=ffmpeg.so' >> /usr/local/lib/php.ini Step 6. Now test php with ffmpeg php -r 'phpinfo();' | grep ffmpeg
-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
When you run command ./configure if you get error: configure: error: ffmpeg headers not found. Make sure ffmpeg is compiled as shared libraries using the –enable-shared option. Check some library with command:
rpm -ql ffmpeg-devel
In On CentOS 6/7 with nux-dextop installed ffmpeg-devel
locate avio.h avformat.h avcodec.h /usr/include/ffmpeg/libavcodec/avcodec.h /usr/include/ffmpeg/libavfilter/avcodec.h /usr/include/ffmpeg/libavformat/avformat.h /usr/include/ffmpeg/libavformat/avio.h /usr/share/doc/ffmpeg/libavcodec.html /usr/share/doc/ffmpeg/libavformat.html
Now do command:
[[email protected] ffmpeg-php-0.6.0]# strace -f -o /ffmpeg-strace ./configure --with-php-config=/usr/bin/php-config --with-ffmpeg=/usr --includedir=/usr/include/ffmpeg
Then:
cat /ffmpeg-strace | egrep 'avio.h|avformat.h|avcodec.h'
Looks like ffmpeg-devel installed headers at
-
/usr/include/ffmpeg/libavcodec/avcodec.h
-
/usr/include/ffmpeg/libavfilter/avcodec.h
-
/usr/include/ffmpeg/libavformat/libavformat.h
-
/usr/include/ffmpeg/libavformat/avio.h
Problem is specific to avcodec.h, avformat.h, avio.h and swscale.h – so what about symlinking them
ln -s /usr/include/ffmpeg/libavcodec/avcodec.h /usr/include/ffmpeg/avcodec.h
ln -s /usr/include/ffmpeg/libavformat/libavformat.h /usr/include/ffmpeg/libavformat.h
ln -s /usr/include/ffmpeg/libavformat/libavformat.h /usr/include/ffmpeg/libavformat.h
ln -s /usr/include/ffmpeg/libswscale/swscale.h /usr/include/ffmpeg/swscale.h
Then configure and make again:
./configure && make