How to Compile FFmpeg with VMAF

This guide provides a straightforward, step-by-step walkthrough on how to compile and install FFmpeg with support for Netflix’s Video Multi-Method Assessment Fusion (VMAF) library. You will learn how to install the necessary build dependencies, compile the libvmaf library from source, and configure FFmpeg to enable this video quality measurement tool on a Linux-based system (such as Ubuntu or Debian).

Step 1: Install Build Dependencies

Before compiling, you must install the required build tools, compilers, and packages. Run the following command in your terminal:

sudo apt update && sudo apt install -y \
  build-essential \
  git \
  cmake \
  nasm \
  yasm \
  pkg-config \
  ninja-build \
  python3 \
  python3-pip \
  python3-setuptools \
  python3-wheel

Next, install meson, which is the build system used by the VMAF repository:

pip3 install meson

Step 2: Compile and Install libvmaf

Now you need to clone the official Netflix VMAF repository, configure the build directory using Meson, and compile the library.

  1. Clone the repository and navigate to the libvmaf directory:

    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 using Ninja:

    ninja -C build
    sudo ninja -C build install
  4. Update the run-time linker bindings so your system recognizes the newly installed library:

    sudo ldconfig

Step 3: Configure and Compile FFmpeg

With libvmaf installed, you can now download and compile FFmpeg.

  1. Navigate out of the VMAF directory and clone the FFmpeg source code:

    cd ../..
    git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git
    cd ffmpeg
  2. Configure FFmpeg with VMAF support. You must explicitly enable both --enable-gpl and --enable-libvmaf:

    ./configure --enable-gpl --enable-version3 --enable-libvmaf

    Note: If your system has trouble finding the VMAF library during configuration, you may need to define the path to your pkg-config files:

    export PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
  3. Compile FFmpeg using all available CPU cores:

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

    sudo make install

Step 4: Verify the Installation

To confirm that FFmpeg has been successfully installed and includes the VMAF filter, run the following command:

ffmpeg -filters | grep vmaf

If the installation was successful, the terminal will output the details of the libvmaf filter, indicating that FFmpeg is ready to perform video quality analysis.