centos 安裝ffmpeg 及h264編碼打包
切記刪除原有ffmpeg
1、編譯yasm。
./configure --prefix=/usr/local/yasm
make
make install
2、解壓x264,進入目錄,輸入:
./configure --prefix=/usr/local/x264 --enable-shared --enable-static --enable-yasm
make
make install
3、解壓ffmpeg,進入目錄,輸入:
./configure --prefix=/usr/local/ffmpeg --enable-shared --enable-yasm --enable-libx264 --enable-gpl --enable-pthreads --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib
make
make install
編譯完成後,修改環境編譯,我在/etc/profile文件下增加如下字段:
FFMPEG=/usr/local/ffmpeg
X264=/usr/local/x264
YASM=/usr/local/yasm
export FFMPEG X264 YASM
export PATH=$PATH:$FFMPEG/bin:$X264/bin:$YASM/bin
export LD_LIBRARY_PATH=$YASM/lib:$X264/lib:$FFMPEG/lib:$LD_LIBRARY_PATH
測試
進入/usr/local/ffmpeg/bin目錄;
./ffmpeg -v
如果無異常則安裝成功;
異常
錯誤信息:
ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory
此情況是因為ffmpeg未找到相關依賴包,可以通過以下方法解決
先 find / -name libavdevice.so.56 得到該文件的目錄地址,我找到的是在ffmpeg安裝目錄的lib目錄下;
然後 vim /etc/ld.so.conf 將上述目錄添加到最後一行並保存退出;
再 ldconfig 使配置生效
附 ld.son.conf
/usr/local/ffmpeg/lib
/usr/local/lib
輔助
http://blog.csdn.net/defonds/article/details/9698959
centos 安裝ffmpeg 及h264編碼打包