I have an ffmpeg version built with VMAF library. I can use it to calculate the VMAF scores of a distorted video against a reference video using commands like this:
ffmpeg -i distorted.mp4 -i original.mp4 -filter_complex "[0:v]scale=640:480:flags=bicubic[main];[main][1:v]libvmaf=model_path=model/vmaf_v0.6.1.json:log_path=log.json" -f null -
Now, I remember there was a way to get VMAF scores while performing regular ffmpeg encoding. How can I do that at the same time?
I want to encode a video like this, while also calulate the VMAF of the output file:
ffmpeg -i original.mp4 -crf 27 -s 640x480 out.mp4
[edited]
Alright, scratch what I said earlier...
You should be able to use [the `tee` muxer](http://ffmpeg.org/ffmpeg-formats.html#tee-1) to save the file and pipe the encoded frames to another ffmpeg process. Something like this should work for you:(make them into 2 lines and remove
\for Windows)Here is what works on my Windows PC (thanks to @Rotem for his help)
The main issue that @Rotem and I missed is that we need to terminate the
libvmaf's output. Also,h264raw format does not carry header info, and using `nut alleviates that issue.There are a couple caveats:
testing with the
testsrcexample that @Rotem suggested in the comment below does not produce anylibvmaflog, at least as far as I can see, but indebugmode, you can see the filter is getting initialized.You'll likely see
[nut @ 0000026b123afb80] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)message in the log. This just means that the frames are piped in faster than the 2nd ffmpeg is processing. FFmpeg does block on both ends, so no info should be lost.For the full disclosure, I posted my Python test script on GitHub. It just runs the shell command, so it should be easy to follow even if you don't do Python.