Compile FFmpeg with SVT-AV1 Support

This guide provides a step-by-step walkthrough on how to compile FFmpeg from source with the SVT-AV1 (Scalable Video Technology AV1) encoder enabled. By building FFmpeg with SVT-AV1 support, you can leverage high-performance, open-source AV1 video encoding directly within your command-line media workflows.

Step 1: Install Build Dependencies

First, update your package manager and install the necessary build tools, compilers, and libraries.

On Debian/Ubuntu-based systems, run:

sudo apt update
sudo apt install -y autoconf automake build-essential cmake git libtool pkg-config yasm nasm

Note: Ensure your nasm version is 2.15 or higher, as SVT-AV1 requires a modern assembler for optimizations.

Step 2: Build and Install SVT-AV1

To enable SVT-AV1 in FFmpeg, you must first compile and install the SVT-AV1 library (libsvtav1) on your system.

  1. Clone the official SVT-AV1 repository:

    git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git
    cd SVT-AV1
  2. Create a build directory and navigate into it:

    mkdir build && cd build
  3. Configure the build using CMake:

    cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF

    (Setting BUILD_SHARED_LIBS=OFF compiles it as a static library, which is easier to link into FFmpeg).

  4. Compile and install the library:

    make -j$(nproc)
    sudo make install
  5. Update the shared library cache:

    sudo ldconfig

Step 3: Download and Compile FFmpeg

Now you can compile FFmpeg and link it with the newly installed libsvtav1.

  1. Clone the FFmpeg source code:

    git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg-source
    cd ffmpeg-source
  2. Configure the build. You must include the --enable-libsvtav1 flag along with --enable-gpl and --enable-nonfree (required for certain dependencies):

    ./configure \
      --pkg-config-flags="--static" \
      --enable-gpl \
      --enable-nonfree \
      --enable-libsvtav1

    If you installed SVT-AV1 to a custom path, you may need to export the PKG_CONFIG_PATH variable before running the configure script (e.g., export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig").

  3. Compile FFmpeg using all available CPU cores:

    make -j$(nproc)
  4. Install the newly compiled FFmpeg binary:

    sudo make install

Step 4: Verify the Installation

To verify that FFmpeg has been successfully compiled with SVT-AV1 support, check the available encoders using the following command:

ffmpeg -encoders | grep svt

If the installation was successful, the output will display the SVT-AV1 encoder:

V..... libsvtav1             SVT-AV1(Scalable Video Technology for AV1) encoder (codec av1)