Compile FFmpeg with VMAF Support

This guide provides a step-by-step walkthrough on how to compile FFmpeg with support for Netflix’s Video Multi-Method Assessment Fusion (VMAF) library. You will learn how to install the necessary build dependencies, compile and install the libvmaf library from source, configure and compile FFmpeg with VMAF enabled, and verify that the installation was successful.

Step 1: Install Build Dependencies

Before compiling, you need to install the essential compilation tools, libraries, and package managers. On a Debian/Ubuntu-based system, run the following command:

sudo apt update
sudo apt install -y build-essential git meson ninja-build yasm nasm pkg-config

Step 2: Compile and Install libvmaf

FFmpeg requires the libvmaf library to be installed on your system. You can build it directly from the official Netflix repository.

  1. Clone the VMAF repository:

    git clone --depth 1 https://github.com/Netflix/vmaf.git
    cd vmaf/libvmaf
  2. Configure the build using Meson:

    meson build --buildtype release
  3. Compile and install the library:

    ninja -v -C build
    sudo ninja -v -C build install
  4. Update the shared library cache so the system recognizes the newly installed library:

    sudo ldconfig

Step 3: Configure PKG_CONFIG_PATH

FFmpeg needs to locate the libvmaf installation using pkg-config. Ensure the path where libvmaf.pc was installed is in your environment variables.

Typically, it is installed in /usr/local/lib/x86_64-linux-gnu/pkgconfig or /usr/local/lib/pkgconfig. Add it to your path:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH

Step 4: Download and Compile FFmpeg

With libvmaf installed, you can now compile FFmpeg.

  1. Clone the FFmpeg source code:

    git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git
    cd ffmpeg
  2. Configure the FFmpeg build. You must include the --enable-gpl and --enable-libvmaf flags:

    ./configure --enable-gpl --enable-libvmaf --enable-version3
  3. Compile FFmpeg utilizing all available CPU cores:

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

    sudo make install

Step 5: Verify the Installation

To confirm that FFmpeg has been successfully compiled with VMAF support, check if the VMAF filter is available by running:

ffmpeg -filters | grep vmaf

If the installation was successful, the output will display the libvmaf filter.