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
- 安裝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
- 安裝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
- 安裝yasm支持匯編優(yōu)化(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
- 安裝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
- 安裝AAC支持庫FAAC
make時(shí)報(bào)錯(cuò):mpeg4ip.h:126: 錯(cuò)誤:對‘char* strcasestr(const char, const char)’的新聲明
需要修改common/mp4v2/mpeg4ip.h第123行至129行內(nèi)容:
#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內(nèi)容
make
make install
主要提示:可能受限于FFmpeg版本的緣故弄唧,安裝了AAC庫,在ffmpeg-3.2.4版本下編譯ffmpeg鸥鹉,使用--enable-libfaac選項(xiàng)時(shí),會報(bào)找不到libfaac錯(cuò)誤。百度了一番桥胞,看了FFmpeg的WiKi百科导俘,發(fā)現(xiàn)它使用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時(shí)會報(bào)錯(cuò)
make
make install
- 安裝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
- 安裝通用音樂音頻編碼格式支持庫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
- 安裝x264庫支持H.264視頻轉(zhuǎn)碼
cd /root/source
git clone git://git.videolan.org/x264.git
cd x264
./configure --enable-shared
make
make install
- 安裝Xvid庫支持MPEG-4轉(zhuǎn)碼
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
- 安裝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
- 安裝NUT支持庫
該軟件需要用svn獲取源代碼更卒,svn可以直接用yum install svn來裝等孵。
安裝時(shí)64位Linux系統(tǒng)需要修改文件config.mak
# 在最后一個(gè)CFLAGS下一行增加:
CFLAGS += -fPIC
否則安裝FFmpeg make時(shí)報(bào)錯(cuò):
/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
- 安裝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
- 安裝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
#若出現(xiàn)下述錯(cuò)誤俯萌,在此修改config.mak文件,然后再make上枕,切記別重新configure
make install
若make的時(shí)候咐熙,報(bào)以下錯(cuò)誤
/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
- 添加動態(tài)鏈接庫配置
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
看到這個(gè)滿滿的幸福和成就感锈玉。