CentOS 6 安裝 ffmpeg 及 php-ffmpeg
CentOS 6 or 7 安裝ffmpeg
安裝 GPG key
rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
安裝 ATRPMS Repo:
rpm -ivh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
[root@nginxtips.com:~]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%]
安裝 FFMpeg
yum -y --enablerepo=atrpms install ffmpeg ffmpeg-devel
輸出
[root@nginxtips.com:~]yum --enablerepo=atrpms install ffmpeg ffmpeg-devel
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
.....
.....
.....
===============================================
Package Arch Version Repository Size
===============================================
Installing:
ffmpeg x86_64 2.2.1-65.el6 atrpms 2.6 M
ffmpeg-devel x86_64 2.2.1-65.el6 atrpms 5.7 M
.....
.....
.....
驗證 FFMPEG 是否啟用
Verify the ffmpeg version:
ffmpeg -version
[root@nginxtips.com:~]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
檢查格式
ffmpeg -formats
簡單測試將 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
你應該可以看到一個 H264 檔案:
-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
安裝 php-ffmpeg
yum install php-ffmpeg
Verify ffmpeg is loading from PHP:
確認是否有安裝成功
php -i | grep ffmpeg -i
[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
但在安裝 php-ffmpeg 的過程中肯定出錯
提供另一種方式安裝
yum install git
git clone https://github.com/tony2001/ffmpeg-php.git
cd ffmpeg-php
phpize
./configure
make && make install
開啟php.ini 新增 extension = ffmpeg.so
service httpd restart
留言
張貼留言