CentOS下安裝FFmpeg

1.安裝依賴包

  1. 安裝autoconf
cd /root/source
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz    
tar xvf autoconf-2.69.tar.xz
cd autoconf-2.69
./configure
make
make install
  1. 安裝automake
cd /root/source
wget http://ftp.gnu.org/gnu/automake/automake-1.15.tar.xz  
tar xvf automake-1.15.tar.xz
cd automake-1.15
./configure
make
make install
  1. 安裝libtool(FAAC需要)
cd /root/source
wget http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xz
tar xvf libtool-2.4.6.tar.xz
cd libtool-2.4.6
./configure
make
make install
  1. 安裝yasm支持匯編優化(FFmpeg需要)
cd /root/source
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make
make install
  1. 安裝MP3支持庫LAME
cd /root/source
wget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz  
tar xvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
make install
  1. 安裝AAC支持庫FAAC
    make時報錯:mpeg4ip.h:126: 錯誤:對‘char* strcasestr(const char, const char)’的新聲明
    需要修改common/mp4v2/mpeg4ip.h第123行至129行內容:
#ifdef __cplusplus
extern "C" {
#endif
char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif

修改為:

#ifdef __cplusplus
extern "C++" {
#endif
const char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif

編譯

cd /root/source
wget http://jaist.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.bz2 
tar xvf faac-1.28.tar.bz2
cd faac-1.28
./bootstrap
./configure --with-mp4v2 
#按前文修改mpeg4ip.h內容
make
make install
主要提示:可能受限于FFmpeg版本的緣故,安裝了AAC庫,在ffmpeg-3.2.4版本下編譯ffmpeg,使用--enable-libfaac選項時,會報找不到libfaac錯誤。百度了一番,看了FFmpeg的WiKi百科,發現它使用libfdk-aac庫替代libfaac庫,安裝后測試果然解決問題。
cd /root/source
wget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master
tar xzvf fdk-aac.tar.gz
cd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --disable-shared --with-pic
#--with-pic 很重要,一定要帶上,不然在編譯FFmpeg時會報錯
make
make install
  1. 安裝AMR支持庫opencore-amr
cd /root/source
wget http://jaist.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz
tar xvf opencore-amr-0.1.3.tar.gz
cd opencore-amr-0.1.3
./configure
make
make install
  1. 安裝通用音樂音頻編碼格式支持庫libvorbis
支持庫libvorbis需要依賴libogg,先安裝libogg庫
cd /root/source
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz
tar xvf libogg-1.3.2.tar.xz
cd libogg-1.3.2
./configure
make
make install
再安裝libvorbis庫
cd /root/source
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz
tar xvf libvorbis-1.3.5.tar.xz
cd libvorbis-1.3.5
./configure
make
make install
  1. 安裝x264庫支持H.264視頻轉碼
cd /root/source
git clone git://git.videolan.org/x264.git
cd x264
./configure --enable-shared
make
make install
  1. 安裝Xvid庫支持MPEG-4轉碼
cd /root/source
wget http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.bz2
tar xvf xvidcore-1.3.3.tar.bz2
cd xvidcore/build/generic
./configure
make
make install
  1. 安裝Theora視頻壓縮支持庫
cd /root/source
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.xz
tar xvf libtheora-1.1.1.tar.xz
cd libtheora-1.1.1
./configure
make
make install
  1. 安裝NUT支持庫
該軟件需要用svn獲取源代碼,svn可以直接用yum install svn來裝。

安裝時64位Linux系統需要修改文件config.mak

# 在最后一個CFLAGS下一行增加:
CFLAGS += -fPIC

否則安裝FFmpeg make時報錯:

/usr/local/lib/libnut.a: could not read symbols: Bad value
cd /root/source
svn co svn://svn.mplayerhq.hu/nut/src/trunk libnut
cd libnut
./configure
#configure后修改上述的config.mak
make
make install
  1. 安裝VP8/VP9編解碼支持庫
cd /root/source
#git clone http://git.chromium.org/webm/libvpx.git
#直接獲取比較好,沒裝git
wget -O libvpx.zip https://codeload.github.com/webmproject/libvpx/zip/master
unzip libvpx.zip
cd libvpx
./configure --enable-shared
make
make install
  1. 安裝FFmpeg最新版
cd /root/source
wget http://ffmpeg.org/releases/ffmpeg-3.2.4.tar.bz2
tar xvf ffmpeg-3.2.4.tar.bz2
cd ffmpeg-3.2.4
#老版本的--enable-libfaac,已替換為--enable-libfdk-aac
./configure --enable-version3 --enable-libvpx --enable-libfdk-aac --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads --enable-libnut --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-shared
make
#若出現下述錯誤,在此修改config.mak文件,然后再make,切記別重新configure
make install

若make的時候,報以下錯誤

/usr/bin/ld: libavcodec/mqc.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
libavcodec/mqc.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

解決方法是:

#config.mak L75加入 -fPIC,然后重新編譯
#直接替換,順序可能不一樣
HOSTCFLAGS=-O3 -g -std=c99 -Wall -fPIC
  1. 添加動態鏈接庫配置
echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf
#更新緩存
ldconfig
安裝到這里就大功告成啦,一路安裝真心不容易,查看下版本:
[root@localhost djnj]# ffmpeg -version
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
configuration: --enable-version3 --enable-libvpx --enable-libfdk-aac --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads --enable-libnut --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-shared
libavutil      55. 34.101 / 55. 34.101
libavcodec     57. 64.101 / 57. 64.101
libavformat    57. 56.101 / 57. 56.101
libavdevice    57.  1.100 / 57.  1.100
libavfilter     6. 65.100 /  6. 65.100
libswscale      4.  2.100 /  4.  2.100
libswresample   2.  3.100 /  2.  3.100
libpostproc    54.  1.100 / 54.  1.100

看到這個滿滿的幸福和成就感。


參考文檔:

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,363評論 6 532
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,497評論 3 416
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,305評論 0 374
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,962評論 1 311
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,727評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,193評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,257評論 3 441
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,411評論 0 288
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,945評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,777評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,978評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,519評論 5 359
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,216評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,642評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,878評論 1 286
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,657評論 3 391
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,960評論 2 373

推薦閱讀更多精彩內容