How to Measure Video Quality with FFmpeg VMAF

This article provides a straightforward guide on how to use the VMAF (Video Multi-Method Assessment Fusion) filter in FFmpeg to evaluate video quality. You will learn how to set up the necessary components, run the comparison command between a processed video and its original reference, and export the results into a readable format to analyze the visual quality scores.

Prerequisites

To use the VMAF filter, your FFmpeg installation must be compiled with libvmaf support. You can verify this by running ffmpeg -filters in your terminal and checking if libvmaf is listed.

Additionally, you need to download the VMAF model files (usually in .json format) from the official Netflix VMAF repository. The standard model for 1080p desktop viewing is vmaf_v0.6.1.json.

Basic VMAF Command

The VMAF filter compares a distorted (processed/compressed) video against a reference (original) video. Both videos must have the same resolution and frame rate for an accurate comparison.

Here is the basic command structure:

ffmpeg -i distorted.mp4 -i reference.mp4 -filter_complex "[0:v][1:v]libvmaf=model_path=vmaf_v0.6.1.json" -f null -

Command breakdown: * -i distorted.mp4: The first input is the compressed or processed video you want to test. * -i reference.mp4: The second input is the original, uncompressed source video. * -filter_complex "[0:v][1:v]libvmaf...": This maps the video stream of the first input [0:v] and the second input [1:v] into the libvmaf filter. * model_path=vmaf_v0.6.1.json: Specifies the path to the downloaded VMAF model file. * -f null -: Tells FFmpeg not to write an output video file, as we only need the console output containing the VMAF score.

Exporting Results to a Log File

To save the frame-by-frame scores and the final average score to a file for later analysis, you can specify a log path and format (XML, JSON, or CSV) directly within the filter parameters:

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 -

Handling Different Resolutions or Frame Rates

If your distorted video has a different resolution than the reference video, you must upscale or downscale them to match before passing them to the VMAF filter. You can do this inline using FFmpeg’s scale filter:

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 -

Interpreting VMAF Scores

Once the execution completes, FFmpeg will output a final mean VMAF score in the terminal. VMAF scores range from 0 to 100: * 93 to 100: Excellent quality, virtually indistinguishable from the reference source. * 70 to 90: Good quality, acceptable for most streaming platforms. * Below 70: Noticeable distortion and loss of quality.