How to Compile FFmpeg with SVT-AV1
This guide provides a step-by-step walkthrough for compiling FFmpeg
from source with SVT-AV1 support enabled. By building the latest SVT-AV1
encoder and integrating it into FFmpeg via the
--enable-libsvtav1 flag, you can take full advantage of
high-performance, multi-threaded AV1 video encoding on Linux-based
systems.
Step 1: Install Build Dependencies
Update your system packages and install the necessary compilers, build tools, and development libraries.
sudo apt update
sudo apt install -y \
build-essential \
cmake \
git \
nasm \
yasm \
pkg-config \
libtool \
ninja-buildNote: SVT-AV1 requires cmake (version 3.16 or newer)
and nasm (version 2.14 or newer).
Step 2: Build and Install SVT-AV1
Clone the official SVT-AV1 repository, configure it, and compile the static/shared libraries.
# Create a workspace directory
mkdir -p ~/ffmpeg_build && cd ~/ffmpeg_build
# Clone the SVT-AV1 source repository
git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git
cd SVT-AV1/Build/linux
# Build the library in Release mode
./build.sh release
# Install the library onto the system
cd Release
sudo make install
sudo ldconfigBy default, this installs the header files into
/usr/local/include/svt-av1 and the library into
/usr/local/lib.
Step 3: Export PKG_CONFIG_PATH
FFmpeg relies on pkg-config to detect the SVT-AV1
library. Ensure the path to SvtAv1Enc.pc is exposed to your
environment:
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"Verify that pkg-config can locate the library:
pkg-config --modversion SvtAv1EncStep 4: Download and Configure FFmpeg
Download the FFmpeg source code and configure the build to include SVT-AV1.
cd ~/ffmpeg_build
# Clone FFmpeg source code
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
# Configure FFmpeg with SVT-AV1
./configure \
--prefix="/usr/local" \
--pkg-config-flags="--static" \
--extra-cflags="-I/usr/local/include" \
--extra-ldflags="-L/usr/local/lib" \
--extra-libs="-lpthread -lm" \
--enable-gpl \
--enable-libsvtav1 \
--enable-nonfreeStep 5: Compile and Install FFmpeg
Compile FFmpeg using all available CPU cores, then install the binary.
make -j$(nproc)
sudo make installStep 6: Verify the Installation
Confirm that the newly compiled FFmpeg binary is available and that
the libsvtav1 encoder is recognized.
ffmpeg -encoders | grep svtav1You should see output similar to:
V..... libsvtav1 SVT-AV1(Scalable Video Technology for AV1) encoder (codec av1)
You can now encode video using SVT-AV1:
ffmpeg -i input.mp4 -c:v libsvtav1 -preset 6 -crf 28 -c:a copy output.mp4