Reputation: 386
I have 2 rgb48le tif images that I want to compare with ffmpeg to compute the PSNR
ffmpeg automatically computes the PSNR on YUV channels instead of RGB. This is the command that I'm using on "ffmpeg-20160119-git-cc83177-win64-static":
ffmpeg -y -an -i image1.tif -i image2.tif -filter_complex "psnr" output.tif
and this is the output:
[tiff_pipe @ 045b36a0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, tiff_pipe, from 'image1.tif':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: tiff, rgb48le, 7680x4320 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
[tiff_pipe @ 045c53a0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #1, tiff_pipe, from 'image2.tif':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: tiff, rgb48le, 7680x4320 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'output.tif':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: tiff, rgb48le, 7680x4320 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
Metadata:
encoder : Lavc56.60.100 tiff
Stream mapping:
Stream #0:0 (tiff) -> psnr:main
Stream #1:0 (tiff) -> psnr:reference
psnr -> Stream #0:0 (tiff)
Press [q] to stop, [?] for help
frame= 1 fps=0.3 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:195568kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_psnr_0 @ 045cf760] PSNR y:46.00 u:49.32 v:50.34 average:48.14 min:48.14 max:48.14
Is this normal? Is there a way to force the PSNR to compute on RGB48 each channel?
Upvotes: 1
Views: 1250
Reputation: 11174
vf_psnr.c does not support rgb48, so you need to convert to some supported format. The easiest (lossless) conversion is probably to gbrp16; this is essentially the same pixel data, just planar instead of packed (i.e. GGGG[..] BBBB[..] RRRR[..] instead of RGBRGBRGBRGB[..]).
Unfortunately, libswscale only supports output (in GBRP) up to 14bpp, not 16bpp, so you need to convert to gbr14p until that is fixed:
ffmpeg -i image1.tif -i image2.tif \
-lavfi '[0:v]format=gbrp14[o1];[1:v]format=gbrp14[o2];[o1][o2]psnr' \
-f null -nostats -
This will actually do PSNR in 14bpp RGB. The output still claims YUV, because of a bug in drawutils.c, which doesn't recognize GBRP14 as actually being RGB. I'll submit a patch for that. So even though the output on the console says 'y', 'u', 'v', the channel order is actually 'g', 'b', 'r'.
Upvotes: 2