Netflix / vmaf

Perceptual video quality assessment based on multi-method fusion.
Other
4.67k stars 755 forks source link

Incorrect framerate in `resource/doc/ffmpeg.md`? #1395

Closed CrypticSignal closed 4 weeks ago

CrypticSignal commented 4 weeks ago

In the Using VMAF with FFmpeg section, we have the following example:

ffmpeg \
    -r 24 -i Seeking_30_480_1050.mp4 \
    -r 24 -i Seeking_10_288_375.mp4 \
    -lavfi "[0:v]setpts=PTS-STARTPTS[reference]; \
            [1:v]scale=720:480:flags=bicubic,setpts=PTS-STARTPTS[distorted]; \
            [distorted][reference]libvmaf=log_fmt=xml:log_path=/dev/stdout:model_path={your_vmaf_dir}/model/vmaf_v0.6.1.json:n_threads=4" \
    -f null -

We have -r 24 in the command but the framerate of Seeking_30_480_1050.mp4 and Seeking_10_288_375.mp4 is 25, so shouldn't the framerate be set to 25 with -r 25? If so, I am happy to open a PR.

nilfm99 commented 4 weeks ago

Hi, thanks for the heads up. I think we can change both to 25 no problem, and if you open a PR we'll welcome it.

For more detail on what's going on, that -r sets the input framerate, which tells ffmpeg how to interpret the timestamps in the input file. In this case it doesn't really matter what we set it to, as long as we set both to the same number - that will make the timestamps match and ffmpeg's framesync mechanism will feed both frames to libvmaf correctly. The VMAF results are the same whether you set both to -r 24 or -r 25.

CrypticSignal commented 4 weeks ago

@nilfm99 So the value of -r doesn't need to match the framerate of the input video? We can pick any value for the framerate, as long as the same value is used for both the reference and distorted file?

If that's the case, it's fine to leave the documentation as-is.

I'm wondering if there is a benefit to picking a particular framerate value in terms of how quickly the ffmpeg vmaf calculation process takes to complete, or does the value of the input framerates have no effect on this?

nilfm99 commented 4 weeks ago

I don't think it has any impact on speed at all - if the two inputs have the same number of frames, any value will do as long as it's the same. The frames will get matched up and passed to libvmaf, where the bulk of the computation happens. The same frames will be passed regardless of the -r value.

There are cases where you may want to have different values - for example, if the reference has twice as many frames as the distorted, which can happen if you encode e.g. a 60fps source into a 30fps bitstream, you could use something like -r 2 -i <source> -r 1 -i <encode>, or -r 60 -i <source> -r 30 -i <encode> to control the decimation of frames.

CrypticSignal commented 4 weeks ago

I see. Let's leave the documentation as-is then as it's won't yield incorrect VMAF scores. Thank you for the the information and have a wonderful remainder of your day 🙂