ffmpeg推流时报错 Unknown encoder 'libx264'
一、问题描述
在调试VoicePuppet开源项目时候,需要安装ffmpeg。但在安装前未按照libx264库,导致在生成mp4视频的时候出错。
二、解决方案
安装libx264
1、下载libx264(官网)
git clone https://code.videolan.org/videolan/x264.git
2、切到x264根目录
cd x264
3、生成 Makefile
./configure --prefix=/usr/softinstall/x264/ --includedir=/usr/local/include --libdir=/usr/local/lib --enable-shared
4、注意可能报如下错误:
[root@localhost x264]# ./configure --prefix=/usr/softinstall/x264/ --enable-static --enable-shared
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官网):
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.gz
./configure
make
make install
5、make
6、make install
7、重新编译安装ffmpeg(已安装先卸载)
重新安装步骤 https://www.cnblogs.com/fjsdjsj/p/14304049.html
需要注意的是libx264要与ffmpeg版本要一一对应,目前ffmpeg版本是4.3.1,否则在编译的时候会出错。