How to Calculate VMAF Score Using FFmpeg
This article provides a quick and practical guide on how to use the
libvmaf filter in FFmpeg to calculate the Visual
Multi-Method Assessment Fusion (VMAF) score. You will learn the system
prerequisites, the exact command-line syntax required to compare a
distorted video against a reference video, how to export the results to
a log file, and how to interpret the final score.
Prerequisites
To calculate VMAF scores, you need: 1. FFmpeg
compiled with VMAF support (the --enable-libvmaf flag must
be enabled). You can check this by running
ffmpeg -filters | grep vmaf. 2. VMAF Model
Files (typically .json format), which are trained
models representing different viewing conditions (e.g., 1080p phone/TV
screens). You can download these models from the official Netflix VMAF
GitHub repository.
Basic FFmpeg Command
To calculate the VMAF score, you must pass both the distorted
(processed) video and the original reference video into FFmpeg. The
distorted video is typically passed as the first input
(-i), and the reference video as the second.
Run the following basic command in your terminal:
ffmpeg -i distorted.mp4 -i reference.mp4 -filter_complex "[0:v][1:v]libvmaf=model=path=vmaf_v0.6.1.json" -f null -[0:v][1:v]maps the video streams of the first input (distorted) and second input (reference) into the filter.libvmafis the filter name.model=path=vmaf_v0.6.1.jsonspecifies the path to your downloaded VMAF model file.-f null -tells FFmpeg not to write an output video file, as we only want to analyze the quality metrics.
Exporting Scores to a Log File
To save frame-by-frame scores and the final mean score to a file for
analysis, use the log_path and log_fmt
options. You can export the log as XML, JSON, CSV, or sub (text
format).
ffmpeg -i distorted.mp4 -i reference.mp4 -filter_complex "[0:v][1:v]libvmaf=model=path=vmaf_v0.6.1.json:log_path=vmaf_output.json:log_fmt=json" -f null -Dealing with Different Resolutions or Framerates
VMAF requires both input videos to have the exact same resolution and framerate. If your distorted video has a different resolution than your reference video, you must scale one of them within the filtergraph.
To upscale a distorted 720p video to match a
1080p reference video:
ffmpeg -i distorted_720p.mp4 -i reference_1080p.mp4 -filter_complex "[0:v]scale=1920:1080[distorted_scaled]; [distorted_scaled][1:v]libvmaf=model=path=vmaf_v0.6.1.json" -f null -Understanding the VMAF Score
Once the process finishes, FFmpeg will print the VMAF score in the terminal output.
- Score Range: VMAF scores range from 0 to 100, where 0 represents the lowest possible quality and 100 represents identical quality to the reference.
- Interpretation: A score of 93 to 95 is generally considered the threshold for “broadcast quality” or “visually lossless,” meaning the average viewer cannot distinguish the compressed video from the source.