fifonik / FFMetrics

Visualizes Video Quality Metrics (PSNR, SSIM & VMAF) calculated by ffmpeg.exe
562 stars 22 forks source link

AV1_AMF encoded video giving incorrect VMAF scores #123

Open Immrspy opened 8 months ago

Immrspy commented 8 months ago

Because AV1_AMF encodes to an even 64x16 grid, padding the rest with black pixels, video needs to be cropped before an accurate VMAF score can be achieved. For 1080p video, this means cropping off the bottom two rows (the video is 1920x1082, with 2 rows of null information). Without cropping off the bottom two rows, VMAF scores are calculated using scaled video, which gives a value anywhere from the 70s to the 50s when the true value should be in the 90s. To fix this error, the ffmpeg command needs to look like this:

ffmpeg -i encoded_amf.mkv -i reference.mp4 -lavfi "[0:v]crop=1920:1080:0:0[encoded_amf];[encoded_amf][1:v]libvmaf" -f null -

Adding a crop to remove the bottom two lines before it reaches VMAF.

Because AMD's AV1 encoder is starting to become more popular, and because this tool is really helpful in comparing different encoding methods, could there be some workaround to detect 1082p video and crop it down to 1080p?

This issue is not present at 1440p and 2160p (4K) because those resolutions are a multiple of a 64x16 aspect ratio.

fifonik commented 8 months ago

Thanks. I will try to implement it.

DimkaTsv commented 6 months ago

video needs to be cropped before an accurate VMAF score can be achieved.

AMD is currently cooperating with ffmpeg to add automatic crop support for AV1 to resolve this problem.

And 1082p is already not aligned to 16p grid, it is just AMF developers did some magic trickery to make it work as close as possible. And ReLive devs said "we don't need that here", so they record 1088p video instead (1088p though IS actually aligned to 16). Which is funny, as this means that they actually set 1088p as output resolution for 1080p manually.

About workarounds. For now one of the options, at least to ensure proper playback, is to use container level aspect ratio 16:9 to force proper playback, but i don't think it will work for VMAF rating. I tried to do container level cropping, but many sources just ignore it from my experience (they present 1920x1088 as 1906x1080 instead, unless i do forced aspect ratio or forced playback resolution)

But yeah, would be really nice.