一、簡介
FFmpeg是一套可以用來記錄、轉(zhuǎn)換數(shù)字音頻、視頻,并能將其轉(zhuǎn)化為流的開源計算機程序。采用LGPL或GPL許可證。它提供了錄制、轉(zhuǎn)換以及流化音視頻的完整解決方案。它包含了非常先進的音頻/視頻編解碼庫libavcodec,為了保證高可移植性和編解碼質(zhì)量,libavcodec里很多code都是從頭開發(fā)的。
FFmpeg在Linux平臺下開發(fā),但它同樣也可以在其它操作系統(tǒng)環(huán)境中編譯運行,包括Windows、Mac OS X等。這個項目最早由Fabrice Bellard發(fā)起,2004年至2015年間由Michael Niedermayer主要負責維護。許多FFmpeg的開發(fā)人員都來自MPlayer項目,而且當前FFmpeg也是放在MPlayer項目組的服務器上。項目的名稱來自MPEG視頻編碼標準,前面的”FF”代表”Fast Forward”。 [1] FFmpeg編碼庫可以使用GPU加速。
二、安裝
前提需要安裝yasm、libx264、pkg-config
1.安裝yasm編譯器
yum install yasm -y
如果沒有安裝yasm,在執(zhí)行./configure –enable-libx264 –enable-gpl –prefix=/usr/local/ffmpeg會提示如下錯誤:
nasm/yasm not found or too old. Use –disable-x86asm for a crippled build.If you think configure made a mistake, make sure you are using the latestversion from Git. If the latest version fails, report the problem to theffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.Include the log file “ffbuild/config.log” produced by configure as this will helpsolve the problem.
2.安裝libx264
下載地址
https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar
解壓X624
# tar jxvf x264-master.tar
進入解壓目錄
# cd x264-master
編譯和安裝
# ./configure –enable-shared# make && make install
如果沒有安裝libx264,在使用ffmpeg會提示:Unknown encoder ‘libx264’
3.安裝pkg-config
下載地址
https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
解壓X624
# tar jxvf pkg-config-0.29.2.tar.gz
進入解壓目錄
# cd pkg-config-0.29.2
編譯和安裝
# ./configure –with-internal-glib# make# make check# make install
安裝ffmpeg
下載解壓
wget http://www.ffmpeg.org/releases/ffmpeg-5.0.tar.gztar -zxvf ffmpeg-5.0.tar.gz
解壓后目錄,輸入如下命令:/usr/local/ffmpeg為自己指定的安裝目錄
# ./configure –enable-libx264 –enable-gpl –prefix=/usr/local/ffmpeg
安裝,這個操作時間會比較長點
# make && make install
修改文件/etc/ld.so.conf
# vim /etc/ld.so.conf
添加兩行:
/usr/local/ffmpeg/lib//usr/local/lib/
使修改的文件/etc/ld.so.conf生效
# ldconfig
查看安裝結果
# ./ffmpeg -version
配置環(huán)境變量
# vim /etc/profileexport PATH=$PATH:/usr/local/ffmpeg/bin
使環(huán)境變量生效
# source /etc/profile
查看ffmpeg版本
# ffmpeg -version