Compute VMAF Using FFmpeg on Windows

Author’s note: When this post was written, the Zeranoe FFmpeg Windows download didn’t include VMAF, so you had to either download this version or compile your own. Now the Zeranoe version does include VMAF support; all you need to do is download the models and run the correct command strings. To learn how to do this, check out the blog post Lesson of the Week: Computing VMAF with FFmpeg on Windows. I’ll leave this post up for historical purposes, but the newer post is the one that you should use. 

One of the gaps in my online course on Video Quality Metrics and my upcoming course on metrics at Streaming Media West was the ability to compute VMAF using FFmpeg on Wind. I know it’s been possible for quite a while now but since I’m not a coder I can’t compile the version of FFmpeg necessary to make it work.

So, I reached out to friend and colleague Abharana (Abi) Bhat, Ph.D., who is the Video Architect, Video Quality at DAZN, the London-based OTT subscription sports streaming service. Abi compiled the necessary version of FFmpeg, which you can download here, and documented how to compile the codec yourself should you want to do so in the future. So, a huge thanks to Abi for her hard work and gracious contribution.

Here’s the links to Abi’s FFmpeg version (again): download
Here’s how to compile: download PDF

What I’ll do in this post is to document how to run VMAF using the compiled version of FFmpeg, which is pretty straightforward.

Basic Operation

The shortest command string that worked was this:

ffmpeg.exe -i output.mp4 -i input.mp4 -lavfi libvmaf="model_path=vmaf_v0.6.1.pkl:log_path=VMAF.txt" -report -f null -

Pretty simple stuff;

ffmpeg.exe – call the program
-i output.mp4 -i input.mp4 – list encoded file first, then source
lavfi– call librafilter
libvmaf – Identify the filter
"model_path=vmaf_v0.6.1.pkl – path to VMAF model (this is the default model)
:log_path=VMAF.txt – path and name of the file to contain scores
-report – saves the log file (not essential)
-f null - – Tells FFmpeg to output a null file

Other Options

You can find all the libvmaf options here. Here are the most relevant ones (IMHO)

model_path – Set the model path which is to be used for SVM. Default value: “vmaf_v0.6.1.pkl”

log_path – Set the file path to be used to store logs.

log_fmt – Set the format of the log file (xml or json).

phone_model – Invokes the phone model which will generate VMAF scores higher than in the regular model, which is more suitable for laptop, TV, etc. viewing conditions.

psnr – Enables computing psnr along with vmaf.

ssim – Enables computing ssim along with vmaf.

ms_ssim – Enables computing ms_ssim along with vmaf.

n_threads – Set number of threads to be used when computing vmaf.

pool – Set the pool method to be used for computing vmaf. Options are min, harmonic_mean or mean.

This string incorporates many of these options and worked for me.

ffmpeg.exe -i output.mp4 -i input.mp4 -lavfi libvmaf="model_path=vmaf_v0.6.1.pkl:log_fmt=xml:psnr=1:ssim=1:log_path=harm_mean.txt:pool=harmonic_mean" -f null -

So, it computed VMAF using the default model, as well as PSRN, SSIM, and MS_SSIM, and computed the scores via the harmonic mean, which does a better job weighing variations in the stream than the simple mean.

Here’s what the log file looked like (click the figure to see it at full resolution). You see the computed metrics and the frame scores for the first two frames. It took 13.5 seconds to compute all metrics on my HP Zbook notebook.

For those who care about these things, I checked and the VMAF scores computed via the arithmetic mean were identical to those produced by the Moscow State University Video Quality Measurement Tool, which is my go-to tool for metric computations.

These techniques will soon make their way into my course on computing and using video quality metrics depicted immediately below. For more on the course, click the course image below, or click here.

About Jan Ozer

I help companies train new technical hires in streaming media-related positions; I also help companies optimize their codec selections and encoding stacks, and evaluate new encoders and codecs.

Check Also

Take the Bitmovin Video Developer Survey

Contribute to the one of the most valuable sources of industry data by completing the …

Leave a Reply

Your email address will not be published. Required fields are marked *