ffmpeg 的 ssim 没有做它应该做的事情吗?

ffmpeg 的 ssim 没有做它应该做的事情吗?

出于好奇,我检查了两个版本的视频文件,这两个版本没有重新编码,只是重新混合。我原本预计 ssim 分数为 1.0。相反,我看到的分数小于 1.0。

如何重复:

首先,重新混合视频:

MP4Box -cat video.mp4 -new test-1.mp4

-或者-

mkvmerge -o test-2.mkv video.mp4

现在,我希望这三个文件的质量 100% 相同。但是当我使用 ffmpeg 用 ssim 检查其中任意两个文件时,我得到了如下结果:

[Parsed_ssim_0 @ 0x7413a0] SSIM Y:0.899826 U:0.994930 V:0.994679 All:0.931486 (11.642182)

那么,到底发生了什么?为什么这三个文件在相互测试时没有获得 1.0 的 ssim 分数?这对我实际重新编码的视频获得的 ssim 分数有何影响?

ffmpeg:ffmpeg version 2.8.14-0ubuntu0.16.04.1

//// 编辑:添加实际的终端命令和输出:

exiftool video.mp4
ExifTool Version Number         : 10.10
File Name                       : video.mp4
Directory                       : .
File Size                       : 10 MB
File Modification Date/Time     : 2018:07:02 02:08:41+12:00
File Access Date/Time           : 2018:07:02 02:09:09+12:00
File Inode Change Date/Time     : 2018:07:02 02:09:04+12:00
File Permissions                : rw-r--r--
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4  Base Media v1 [IS0 14496-12:2003]
Minor Version                   : 0.2.0
Compatible Brands               : isom, iso2, mp41
Movie Data Size                 : 10427101
Movie Data Offset               : 44
Movie Header Version            : 0
Create Date                     : 0000:00:00 00:00:00
Modify Date                     : 0000:00:00 00:00:00
Time Scale                      : 1000
Duration                        : 0:01:01
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 0000:00:00 00:00:00
Track Modify Date               : 0000:00:00 00:00:00
Track ID                        : 1
Track Duration                  : 0:01:01
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1920
Image Height                    : 1100
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : hev1
Source Image Width              : 1920
Source Image Height             : 1100
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Video Frame Rate                : 30
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 0000:00:00 00:00:00
Media Modify Date               : 0000:00:00 00:00:00
Media Time Scale                : 44100
Media Duration                  : 0:01:01
Media Language Code             : und
Handler Description             : SoundHandler
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Handler Type                    : Metadata
Handler Vendor ID               : Apple
Encoder                         : Lavf56.40.101
Avg Bitrate                     : 1.36 Mbps
Image Size                      : 1920x1100
Megapixels                      : 2.1
Rotation                        : 0

重新混合文件:

MP4Box -cat video.mp4 -new test-1.mp4
Appending file video.mp4                                                                                No suitable destination track found - creating new one (type vide)
No suitable destination track found - creating new one (type soun)
Saving test-1.mp4: 0.500 secs Interleaving

使用 ffmpeg/ssim 比较这两个文件:

ffmpeg -hide_banner -i video.mp4 -i test-1.mp4   -filter_complex "ssim" -f null -
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : Intro
    encoder         : Lavf56.40.101
  Duration: 00:01:01.14, start: 0.000000, bitrate: 1376 kb/s
    Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 1920x1100, 1236 kb/s, 30 fps, 30 tbr, 16k tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x24117e0] multiple edit list entries, a/v desync might occur, patch welcome
    Last message repeated 1 times
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'test-1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2018-07-01 14:09:09
  Duration: 00:01:01.14, start: 0.000000, bitrate: 1372 kb/s
    Stream #1:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 1920x1100, 1236 kb/s, 30 fps, 30 tbr, 44100 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : Intro
    encoder         : Lavf56.40.101
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1100, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc56.60.100 rawvideo
    Stream #0:1(und): Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc56.60.100 pcm_s16le
Stream mapping:
  Stream #0:0 (hevc) -> ssim:main (graph 0)
  Stream #1:0 (hevc) -> ssim:reference (graph 0)
  ssim (graph 0) -> Stream #0:0 (rawvideo)
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[null @ 0x24d47c0] Encoder did not produce proper pts, making some up.
frame= 1834 fps= 54 q=-0.0 Lsize=N/A time=00:01:01.13 bitrate=N/A
video:172kB audio:10532kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_ssim_0 @ 0x23f90c0] SSIM Y:0.893099 U:0.994654 V:0.994361 All:0.926902 (11.360919)

这是我没想到的部分: SSIM Y:0.893099 U:0.994654 V:0.994361 All:0.926902

答案1

原因如下: multiple edit list entries, a/v desync might occur, patch welcome

我建议使用

ffmpeg -hide_banner -ignore_editlist 1 -i video.mp4 -ignore_editlist 1 -i test-1.mp4
       -filter_complex "[0]setpts=N/30/TB[a];[1]setpts=N/30/TB[b];[a][b]ssim" -f null -

相关内容