How to Calculate VMAF Score with FFmpeg

This guide explains how to calculate the Video Multi-Method Assessment Fusion (VMAF) score using FFmpeg's libvmaf filter. You will learn the required FFmpeg configuration, the core command syntax to compare an encoded video against a pristine reference video, how to align mismatched resolutions or frame rates, and how to export the resulting scores to a file for analysis.

Prerequisites

To use VMAF, your FFmpeg installation must be compiled with the --enable-libvmaf flag. You can verify this by running:

ffmpeg -filters | grep libvmaf

If the output lists libvmaf, your installation is ready.

Basic VMAF Calculation Command

Calculating a VMAF score requires two inputs: the distorted (encoded) video and the original reference video. In modern versions of FFmpeg, the standard VMAF model is often built-in or loaded via a model file.

Run the following command to compute the score:

ffmpeg -i distorted.mp4 -i reference.mp4 -filter_complex "[0:v][1:v]libvmaf=model='version=vmaf_v0.6.1'" -f null -
  • -i distorted.mp4: The first input ([0:v]), representing the encoded file.
  • -i reference.mp4: The second input ([1:v]), representing the original file.
  • -filter_complex "[0:v][1:v]libvmaf=...": Feeds both video streams into the libvmaf filter.
  • -f null -: Discards the video output and runs the operation at maximum processing speed.

At the end of the process, FFmpeg prints the final pooled VMAF score (ranging from 0 to 100, where 100 represents identical visual quality) directly to your terminal.

Using an External Model File

If you want to use a specific model, such as the 4K model or a custom JSON model file, define the path using the path argument:

ffmpeg -i distorted.mp4 -i reference.mp4 -filter_complex "[0:v][1:v]libvmaf=model='path=/usr/local/share/model/vmaf_4k_v0.6.1.json'" -f null -

Handling Resolution and Frame Rate Mismatches

VMAF requires both videos to have identical dimensions and synchronized frame rates. If your encoded video was downscaled (for example, from 4K to 1080p), you must upscale the distorted video to match the reference resolution before passing it to the filter:

ffmpeg -i distorted_1080p.mp4 -i reference_4k.mp4 -filter_complex "[0:v]scale=3840:2160:flags=bicubic[dist];[dist][1:v]libvmaf=model='version=vmaf_v0.6.1'" -f null -

If the frame rates do not align, use the fps filter to synchronize them prior to running the VMAF comparison.

Exporting Results to a File

To analyze frame-by-frame scores, you can export the log to formats such as JSON, XML, or CSV. Add the log_fmt and log_path options:

ffmpeg -i distorted.mp4 -i reference.mp4 -filter_complex "[0:v][1:v]libvmaf=model='version=vmaf_v0.6.1':log_fmt=json:log_path=vmaf_report.json" -f null -

This generates vmaf_report.json, containing per-frame VMAF metrics along with summary statistics including the mean, harmonic mean, and percentile scores.