使用时如果出现
Failed to resolve hostname :xxx.com Temporary failure in name resolution错误
vim /etc/resolv.conf
添加域名解析服务器
nameserver 114.114.114.114
nameserver 8.8.8.8
unknow encoder 'libx264'
下载安装x264
cd x264
生成makefile
./configure --prefix=/home/x264 --includedir=/user/local/include --libdir=/usr/local/lib --enable-shared
如果不将include和lib安装在/usr/local目录,之后运行ffmpeg推流命令时可能仍然报ERROR:libx264 not found错误。如果已经安装x264了发现报错,则需要将x264.h这个文件要放在/usr/local/include下,libx264的库文件拷贝到/usr/local/lib下,而不是指定其它目录安装存放。推荐安装时直接运行以上命令。
可能报错:
Unknown option --enable-share, ignored Found no assembler Minimum > version is nasm-2.13
If you really want to compile without asm, configure with --disable-asm.
解决方案:
下载更新安装nasm新版本(nasm官网)或者通过yum/apt-get安装:
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.gz
编译
make && make install
重新编译安装ffmpeg
./configure --enable-shared --enable-openssl --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --enable-nonfree
编译
make && make install
如果出现ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory
vim /etc/ld.so.conf
添加下述文件
/usr/local/ffmpeg/lib/
输入ldconfig
使修改生效