1、yum安裝FFmpegnode
1. 最偷懶的方式就是yum安裝了,自動解決依賴。不過CentOS系統默認無FFmpeg源,企業版 Linux 附加軟件包EPEL源也不包含,須要手動添加yum源配置/etc/yum.repos.d/dag.repo:git
[dag] name=Dag RPM Repository for Red Hat Enterprise Linux baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag gpgcheck=0 enabled=1
2. 在線安裝FFmpeg
github
yum -y install ffmpeg
2、編譯安裝FFmpeg
web
yum安裝FFmpeg比源碼編譯安裝省時省力,但缺點也很明顯,版本過老,爲0.6.5版,最新版已爲2.6.3,新舊版不少參數有所差別,舊版支持的格式也沒有新版豐富。shell
源碼編譯安裝FFmpeg很是須要耐心,每添加一種須要支持的格式就須要有相應的多媒體格式開發庫。文中所使用的軟件版本皆爲最新版。
bootstrap
1. 安裝autoconfide
cd /App/src 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
2. 安裝automake
svn
cd /App/src 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
3. 安裝libtool(FAAC須要)post
cd /App/src 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
4. 安裝yasm支持彙編優化(FFmpeg須要)優化
cd /App/src 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
5. 添加動態連接庫配置
echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf
6. 安裝MP3支持庫LAME
cd /App/src 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
7. 安裝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 /App/src 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
8. 安裝AMR支持庫opencore-amr
cd /App/src 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
9. 安裝通用音樂音頻編碼格式支持庫libvorbis
# libvorbis須要libogg,先安裝libogg庫 cd /App/src 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 cd /App/src 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
10. 安裝x264庫支持H.264視頻轉碼
cd /App/src git clone git://git.videolan.org/x264.git cd x264 ./configure --enable-shared make make install
11. 安裝Xvid庫支持MPEG-4轉碼
cd /App/src 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
12. 安裝Theora視頻壓縮支持庫
cd /App/src 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
13. 安裝NUT支持庫
安裝時64位Linux系統須要修改文件config.mak
在最後一個CFLAGS下一行增長:
CFLAGS += -fPIC
不然安裝FFmpeg make時報錯:
/usr/local/lib/libnut.a: could not read symbols: Bad value
cd /App/src svn co svn://svn.mplayerhq.hu/nut/src/trunk libnut cd libnut ./configure make make install
14. 安裝VP8/VP9編解碼支持庫
cd /App/src git clone http://git.chromium.org/webm/libvpx.git cd libvpx ./configure --enable-shared make make install
15. 安裝FFmpeg最新版
cd /App/src wget http://ffmpeg.org/releases/ffmpeg-2.6.3.tar.bz2 tar xvf ffmpeg-2.6.3.tar.bz2 cd ffmpeg-2.6.3 ./configure --enable-version3 --enable-libvpx --enable-libfaac --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 make install ldconfig
16. 安裝segmenter
git clone https://github.com/johnf/m3u8-segmenter cd m3u8-segmenter PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure make make install ln -s /usr/local/bin/m3u8-segmenter /usr/local/bin/segmenter
3、 編譯安裝注意事項
1. 可能發現編譯FFmpeg或者其餘支持庫時,即便相關的全部依賴也編譯安裝上了,仍然make報錯,主要的緣由仍是因爲依賴的庫版本衝突,編譯時調用的是yum安裝時自動下載安裝的舊版本依賴庫。此時的方法就是卸掉全部yum安裝的舊版本FFmpeg和相關的依賴軟件包或者從新找臺新的純淨的系統從新開始安裝,或者使用Ubuntu Server最新版,通常Ubuntu Server最新版FFmpeg版本仍是比較新的,直接執行命令 sudo apt-get install ffmpeg 會自動安裝FFmpeg和相關依賴。
2. 有愛專研的或者受制於手頭無多餘機器的,只能老老實實得卸載舊軟件,從頭開始編譯安裝。如何去除舊版本yum安裝的相關軟件。咱們能夠藉助yum deplist命令先找出全部相關軟件包,而後卸載除了公共軟件包外的全部軟件包。此方法也適用於安裝其它軟件時遇到相似一樣的問題。
yum deplist ffmpeg | grep -v ffmpeg | grep provider | awk '{print $2}' | sort -u
圖示:
從中挑出非公共軟件包的軟件包名卸載:
rpm -e --nodeps a52dec dirac dirac-libs faac gsm lame libtheora opencore-amr SDL x264 rpm -e --nodeps $(rpm -qa | grep -i ffmpeg)
本文出自 「鬆鬆」 博客,請務必保留此出處http://dongsong.blog.51cto.com/916653/1653835