为什么FFMPEG SSIM会根据这些未压缩视频中的哪个是第一/第二来产生不同的比较结果?

时间:2018-11-11 21:40:13

标签: ffmpeg

ffmpeg的ssim指令说参考应该排第二,当我按这些顺序比较这些视频时(其中“ copy.avi”应该是“ original.avi”的无损H.264副本),SSIM和PSNR返回无损结果。但是,如果我取消订单,性能并不是无损的。

为什么会这样?

先复制,然后再复制原始

> ffmpeg -hide_banner -i copy.avi -i original.avi -lavfi "ssim;[0:v][1:v]psnr" -f null –


[avi @ 0x7ffdee002000] decoding for stream 0 failed
Input #0, avi, from 'copy.avi':
  Metadata:
    encoder         : Lavf58.20.100
  Duration: 00:00:10.67, start: 0.000000, bitrate: 644937 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive) (H264 / 0x34363248), yuv420p(progressive), 2048x1536, 645930 kb/s, 60 fps, 60 tbr, 60 tbn, 120 tbc
Input #1, avi, from 'original.avi':
  Metadata:
    encoder         : Lavf54.35.100
  Duration: 00:00:10.67, start: 0.000000, bitrate: 1509965 kb/s
    Stream #1:0: Video: rawvideo (Y800 / 0x30303859), gray, 2048x1536, 1512312 kb/s, 60 fps, 60 tbr, 60 tbn, 60 tbc
Stream mapping:
  Stream #0:0 (h264) -> ssim:main
  Stream #0:0 (h264) -> psnr:main
  Stream #1:0 (rawvideo) -> ssim:reference
  Stream #1:0 (rawvideo) -> psnr:reference
  ssim -> Stream #0:0 (wrapped_avframe)
  psnr -> Stream #0:1 (wrapped_avframe)
Press [q] to stop, [?] for help
Output #0, null, to '–':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: wrapped_avframe, yuv420p(progressive), 2048x1536, q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.35.100 wrapped_avframe
    Stream #0:1: Video: wrapped_avframe, yuv420p, 2048x1536, q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.35.100 wrapped_avframe
frame=  640 fps= 72 q=-0.0 Lq=-0.0 size=N/A time=00:00:10.66 bitrate=N/A speed=1.21x    
video:670kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_ssim_0 @ 0x7ffdef8024c0] SSIM Y:1.000000 (inf) U:1.000000 (inf) V:1.000000 (inf) All:1.000000 (inf)
[Parsed_psnr_1 @ 0x7ffdef802940] PSNR y:inf u:inf v:inf average:inf min:inf max:inf

原始第一,第二复制

> ffmpeg -hide_banner -i original.avi -i copy.avi -lavfi "ssim;[0:v][1:v]psnr" -f null –


Input #0, avi, from 'original.avi':
  Metadata:
    encoder         : Lavf54.35.100
  Duration: 00:00:10.67, start: 0.000000, bitrate: 1509965 kb/s
    Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 2048x1536, 1512312 kb/s, 60 fps, 60 tbr, 60 tbn, 60 tbc
[avi @ 0x7fb74680d600] decoding for stream 0 failed
Input #1, avi, from 'copy.avi':
  Metadata:
    encoder         : Lavf58.20.100
  Duration: 00:00:10.67, start: 0.000000, bitrate: 644937 kb/s
    Stream #1:0: Video: h264 (High 4:4:4 Predictive) (H264 / 0x34363248), yuv420p(progressive), 2048x1536, 645930 kb/s, 60 fps, 60 tbr, 60 tbn, 120 tbc
Stream mapping:
  Stream #0:0 (rawvideo) -> ssim:main
  Stream #0:0 (rawvideo) -> psnr:main
  Stream #1:0 (h264) -> ssim:reference
  Stream #1:0 (h264) -> psnr:reference
  ssim -> Stream #0:0 (wrapped_avframe)
  psnr -> Stream #0:1 (wrapped_avframe)
Press [q] to stop, [?] for help
Output #0, null, to '–':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: wrapped_avframe, gray(progressive), 2048x1536, q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.35.100 wrapped_avframe
    Stream #0:1: Video: wrapped_avframe, gray, 2048x1536, q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.35.100 wrapped_avframe
frame=  640 fps= 72 q=-0.0 Lq=-0.0 size=N/A time=00:00:10.66 bitrate=N/A speed=1.19x    
video:670kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_ssim_0 @ 0x7fb748101780] SSIM Y:0.998296 (27.684975) All:0.998296 (27.684975)
[Parsed_psnr_1 @ 0x7fb748101c40] PSNR y:56.840774 average:56.840774 min:56.812125 max:56.871584

1 个答案:

答案 0 :(得分:1)

一种格式是yuv420p,另一种格式是灰色。因此,为了进行比较,可以将灰色转换为yuv420p或将yuv420p转换为灰色。如您所见,此操作并非总是无损的。要仅比较Y平面,请在调用psnr / ssim之前使用extractplanes = y过滤器。