FFMetrics icon indicating copy to clipboard operation
FFMetrics copied to clipboard

Add xpsnr metric

Open esator opened this issue 1 year ago • 5 comments

Recently xpsnr has been added to ffmpeg with similar options as psnr, so it shouldn't be very difficult https://ffmpeg.org/ffmpeg-filters.html#xpsnr-1

It's a relatively new and fast metric that is widely used by Fraunhofer and some encoding groups, by subjective evaluation to human perception might be better or comparable to VMAF depends on the content and measured quality https://github.com/fraunhoferhhi/xpsnr

esator avatar Nov 07 '24 11:11 esator

I wanted to add the metric support into FFMetrics, however looks like its implementation has some issues: I'm unable to make it work with setpts=PTS-STARTPTS:

This does not work: ffmpeg -hide_banner -nostdin -r 50 -i C:/Vegas/MainconceptBug2/VP15_x264AVC_crf21.mp4 -r 50 -i C:/Vegas/MainconceptBug2/2012-11-22_095841.m2ts -lavfi [0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=STARTPTS[ref];[main][ref]xpsnr=eof_action=endall:stats_file='-' -f null -

This works fine: ffmpeg -hide_banner -nostdin -r 50 -i C:/Vegas/MainconceptBug2/VP15_x264AVC_crf21.mp4 -r 50 -i C:/Vegas/MainconceptBug2/2012-11-22_095841.m2ts -lavfi [0:v]settb=AVTB[main];[1:v]settb=AVTB[ref];[main][ref]xpsnr=eof_action=endall:stats_file='-' -f null -

The option is used by FFMetrics for synchronizing frames. So at this stage I'm unable to support the metric. Sorry.

fifonik avatar Dec 03 '24 08:12 fifonik

In addition, I do not see it returns anything like 'average' for frames and for file as other metrics returning. I can only Y V U values.

fifonik avatar Dec 03 '24 08:12 fifonik

Hi!

I've managed to find (1, 2, 3) the following formula for the average value: (4*Y + U + V) / 6.

As for setpts=PTS-STARTPTS, it is somehow related to commit 6da82b link. My ffmpeg 7.1.1 was crashing silently, too. Then I've found the root cause with strace. It was division by zero exception. Applying this commit on top of the current release branch fixed the problem for me. Next release will contain this patch, hopefully, so this is a temporary measure.

Hope this helps.

uuwaan avatar Aug 03 '25 20:08 uuwaan

Thanks for the info, I will have a look at this metric again

Unfortunately, at this stage ffmpeg builds after 7.1.1 looks quite broken: https://github.com/fifonik/FFMetrics/issues/182#issuecomment-3144369777

fifonik avatar Aug 03 '25 21:08 fifonik

FYI, work in progress: Image

On my gunea pig files I see xpsnr frame metrics dropped near frames 520 & 570. Other metrics do not show anything like this. Not sure if this is expected.

fifonik avatar Aug 05 '25 13:08 fifonik