How to Use VMAF Filter in FFmpeg
This article provides a straightforward guide on how to use the Video Multi-Method Assessment Fusion (VMAF) filter in FFmpeg to measure video quality. You will learn how to prepare your input files, acquire the necessary VMAF model, and execute the FFmpeg command to compare a distorted video against a reference video to obtain an accurate quality score.
To use the VMAF filter, your version of FFmpeg must be compiled with
the --enable-libvmaf flag. You also need two video files:
the distorted video (the compressed or processed version) and the
reference video (the original source). Both videos must have the same
resolution, frame rate, and duration for an accurate frame-by-frame
comparison.
Step 1: Download the VMAF Model
VMAF relies on machine learning models to predict quality. You must
download the appropriate model file (usually in .json
format) from the official Netflix VMAF repository. The standard model
for 1080p viewing is typically named vmaf_v0.6.1.json. Save
this file to your working directory.
Step 2: Run the Basic Comparison Command
Use the libvmaf filter inside a
-filter_complex graph to map and compare the two videos.
Run the following 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 -In this command: * -i distorted.mp4 is the first input
([0:v]). * -i reference.mp4 is the second
input ([1:v]). * [0:v][1:v]libvmaf feeds the
distorted video and reference video into the VMAF filter. *
model_path points to the location of your downloaded VMAF
model file. * -f null - runs the process without rendering
an output video file, displaying the final VMAF score directly in the
terminal console.
Step 3: Export Results to a Log File
To save the detailed frame-by-frame metrics and the final overall score to a file, add the log parameters to the filter configuration:
ffmpeg -i distorted.mp4 -i reference.mp4 -filter_complex "[0:v][1:v]libvmaf=model_path=vmaf_v0.6.1.json:log_path=results.xml:log_fmt=xml" -f null -This command generates an XML file named results.xml
containing the VMAF scores. The score ranges from 0 (poor quality) to
100 (identical to the reference).