让ffmpeg工具支持h264格式转码 linux ffmpeg Unknown encoder 'h264'
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 install2.重新编译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
make
make install
在编译带lib-idk-aac、x264、x265的FFMPEG时出现
WARNING: using libfdk without pkg-config
WARNING: using libx264 without pkg-config
ERROR: x265 not found using pig-config
原因是需要设置 PKG_CONFIG_PATH,通过pkg-config去指定路径自动寻找需要链接的依赖库,同时,就不需要使用
--extra-cflags=-I、
--extra-cxxflags=-I、
--extra-ldflags=-L来指定依赖库路径
使用方法:在./configure之前执行
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH(此路径为.pc文件所在路径),之后可使用 echo $PKG_CONFIG_PATH 查看
安装选项参考:https://blog.csdn.net/momo0853/article/details/78043903
安装完执行 ffmpeg 命令时报错:
ffmpeg: error while loading shared libraries: libpostproc.so.55: cannot open shared object file: No such file or directory
ffmpeg: error while loading shared libraries: libx264.so.157: cannot open shared object file: No such file or directory
解决方法:
find / -name 'libpostproc.so.55'
vim /etc/ld.so.conf
#将上面找到的目录添加到/etc/ld.so.conf 最后一行并保存退出,执行下面的命令更新配置;
/sbin/ldconfig版权属于:Joyber
本文链接:https://blog.qqvbc.com/default/135.html
转载时须注明出处及本声明
顶顶顶!!!学习了~