如果环境中有conda,最简单的办法就是
conda uninstall ffmpeg
conda install ffmpeg
或者
sudo apt-get install -y libgmp3-dev pkg-config gnutls-bin libaom-dev libass-dev libbluray-dev libfdk-aac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenmpt-dev libopus-dev libshine-dev libsnappy-dev libsoxr-dev libspeex-dev libtheora-dev libtwolame-dev libvo-amrwbenc-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx265-dev libxvidcore-dev liblzma-dev
wget https://ffmpeg.org/releases/ffmpeg-4.3.tar.gz && tar zxf ffmpeg-4.3.tar.gz
cd ffmpeg-4.3
./configure --prefix=/usr/local/ffmpeg --enable-debug=3 --enable-libmp3lame --enable-gpl --disable-static --enable-shared --enable-version3 --enable-nonfree --enable-pthreads --enable-postproc --enable-ffplay --enable-libx264 --enable-libxvid --disable-x86asm
export PATH="/usr/local/ffmpeg/bin:${PATH}" # 因为编译后的可执行文件都在/usr/local/ffmpeg/bin中
export LD_LIBRARY_PATH="/usr/local/ffmpeg/lib:{LD_LIBRARY_PATH}" #共享库路径
source ~/.bashrc
vim /etc/ld.so.conf加上一行/usr/local/ffmpeg/lib/
参考:
ffmpeg推流时,可能出现错误:Unknown encoder 'libx264' - 黑色幽默2018 - 博客园 (cnblogs.com)
ffmpeg推流时报错 Unknown encoder ‘libx264‘_unknown encoder 'libx264-CSDN博客
Ubuntu 20.04源码编译ffmpeg并支持CUDA的GPU加速 - 简书 (jianshu.com)
Ubuntu20.04, 源码编译安装ffmpeg-4.3和opencv- 4.5.3_sudo apt install -y build-essential yasm nasm-CSDN博客
Ubuntu20.04 下编译安装 ffmpeg 和 ffplay_ubuntu安装ffmpeg-CSDN博客