编译 FFmpeg 以支持 AV1 编解码器以及其他硬件加速选项(如 NVENC、VAAPI 等)
步骤 1: 安装必要的依赖
sudo apt update
sudo apt install -y \
autoconf automake build-essential cmake git libass-dev libfreetype6-dev \
libsdl2-dev libtool libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev nasm yasm \
libx264-dev libx265-dev libnuma-dev libvpx-dev libfdk-aac-dev libmp3lame-dev \
libopus-dev libaom-dev libdav1d-dev
其中libaom-dev、 libdav1d-dev以及libfdk-aac-dev可能需要源码安装
libaom-dev源码安装
git clone https://aomedia.googlesource.com/aom
cd build/
cmake .. -DENABLE_NASM=on -DCMAKE_INSTALL_PREFIX=/usr/local
make -j$(nproc)
sudo make install
libdav1d-dev 源码安装
git clone https://salsa.debian.org/multimedia-team/dav1d.git
sudo apt install meson
meson setup ..
ninja
ninja install
libfdk-aac-dev源码安装
git clone https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac/
autoreconf -fiv
./configure --prefix=/usr/local
make -j$(nproc)
sudo make install
步骤2 编译安装ffmpeg
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure \
--prefix=/usr/local \
--enable-gpl \
--enable-nonfree \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libfdk-aac \
--enable-libmp3lame \
--enable-libopus \
--enable-libdav1d \
--enable-libaom \
--enable-nvenc \
--enable-vaapi \
--enable-libass \
--enable-libfreetype \
--enable-libxcb \
--enable-libdrm
make -j$(nproc)
sudo make install
- AV1 支持:–enable-libdav1d(解码)和 --enable-libaom(编码)
- NVENC:–enable-nvenc 用于 NVIDIA 的硬件加速
- VAAPI:–enable-vaapi 用于 Intel 和 AMD 的硬件加速
步骤 3: 验证安装
ffmpeg -encoders | grep av1
ffmpeg -encoders | grep nvenc
ffmpeg -decoders | grep vaapi
设置.bashrc
打开.bashrc 添加export LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu:/usr/local/lib/:$LD_LIBRARY_PATH