linux ffmpeg Unknown encoder h264

linux執行命令:
ffmpeg -y -i v_test.avi -vcodec h264 -strict -2 v_test.mp4

報錯:Unknown encoder ‘h264’

錯誤原因:當前ffmpeg沒有h264視頻編碼器

解決方案:
1.安裝x264

git clone git://git.videolan.org/x264.git
cd x264
#查看幫助信息
./configure --help
#我們需要的是x264以.so or .a的形式來支援ffmpeg,所以一般就關注shared和static關鍵詞就可以了
./configure --enable-shared --enable-static
make
make install


2.重新編譯ffmpeg
下載最新版本ffmpeg-4.1.tar.bz2
http://ffmpeg.org/download.html

tar xjf ffmpeg-4.1.tar.bz2
cd ffmpeg-4.1
./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 
#報錯,根據提示加上--disable-x86asm
./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 --disable-x86asm
make
make install

錯誤信息:

error while loading shared libraries: libavdevice.so.58: cannot open
shared object file: No such file or directory
error while loading shared libraries: libx264.so.157: cannot open
shared object file: No such file or directory
 

find / -name libavdevice.so.58
#find / -name libx264.so.157
vim /etc/ld.so.conf 
#將上述目錄添加到最後一行並保存退出;
/sbin/ldconfig

 

https://blog.csdn.net/weixin_33127753/article/details/84637351

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章