[FFmpeg-user] SSIM filter showing (small) differences in identical(?) streams

Ian Pilcher arequipeno at gmail.com
Sun Feb 28 18:30:58 EET 2021


On 2/26/21 9:52 PM, pdr0 wrote:
> Different timebase means there is potential to compare different frames.
> 
> Use settb
> 
> ffmpeg -framerate 60000/1001 -i lossless.mkv -start_number 0 -framerate
> 60000/1001 -i source/%06d.tif -t 00:01:00 -lavfi
> "[0:v]settb=1/AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=1/AVTB,setpts=PTS-STARTPTS[ref];[main][ref]ssim"
> -f null -

That seems to work.  It gets rid of the "not matching timebases"
warning.  It does cause the duration option (-t 00:01:00) to not work,
but I was able to use the "-frames:v" option instead.  (In fact, I don't
need specify the framerate of the image sequence at all.)

  $ ffmpeg -i lossless.mkv -start_number 0 -i source/%06d.tif -frames:v 
3596 -lavfi 
"[0:v]settb=1/AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=1/AVTB,setpts=PTS-STARTPTS[ref];[main][ref]ssim" 
-f null -
  ...
  Input #0, matroska,webm, from 'lossless.mkv':
    Metadata:
      ENCODER         : Lavf58.45.100
    Duration: 00:00:59.99, start: 0.000000, bitrate: 1223104 kb/s
      Stream #0:0: Video: huffyuv (HFYU / 0x55594648), bgr0, 1440x1080, 
59.94 fps, 59.94 tbr, 1k tbn, 1k tbc (default)
      Metadata:
        ENCODER         : Lavc58.91.100 huffyuv
        DURATION        : 00:00:59.994000000
  Input #1, image2, from 'source/%06d.tif':
    Duration: 04:17:10.96, start: 0.000000, bitrate: N/A
      Stream #1:0: Video: tiff, rgb24, 1440x1080, 25 tbr, 25 tbn, 25 tbc
  ...
  [Parsed_ssim_4 @ 0x562a600ac780] SSIM R:0.999888 (39.506142) 
G:0.999889 (39.531716) B:0.999887 (39.466715) All:0.999888 (39.501442)

So this gets me to the same result that I got when I compared the
derived PNG image sequence to the original TIFF sequence.

  $ ffmpeg -start_number 0 -i lossless/%06d.png -start_number 0 -i 
source/%06d.tif -frames:v 3596 -filter_complex ssim -f null -
  ...
  [Parsed_ssim_0 @ 0x5630c77ad440] SSIM R:0.999888 (39.506142) 
G:0.999889 (39.531716) B:0.999887 (39.466715) All:0.999888 (39.501442)

Now that I know about the -frames:v option, I decided to try omitting
the last frame from the comparison.

  $ ffmpeg -start_number 0 -i lossless/%06d.png -start_number 0 -i 
source/%06d.tif -frames:v 3595 -filter_complex ssim -f null -
  ...
  [Parsed_ssim_0 @ 0x560797482440] SSIM R:1.000000 (inf) G:1.000000 
(inf) B:1.000000 (inf) All:1.000000 (inf)

  $ ffmpeg -i lossless.mkv -start_number 0 -i source/%06d.tif -frames:v 
3595 -lavfi 
"[0:v]settb=1/AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=1/AVTB,setpts=PTS-STARTPTS[ref];[main][ref]ssim" 
-f null -
  ...
  [Parsed_ssim_4 @ 0x5571f0a97780] SSIM R:1.000000 (inf) G:1.000000 
(inf) B:1.000000 (inf) All:1.000000 (inf)

That gets me the expected score.

I don't understand why I have to omit the final frame.  Both ImageMagick
and ffmpeg show the images as identical.

  $ compare -metric AE lossless/003595.png source/003595.tif /tmp/diff.png
  0

  $ ffmpeg -i lossless/003595.png -i source/003595.tif -filter_complex 
ssim -f null -
  ...
  [Parsed_ssim_0 @ 0x561a6aae1540] SSIM R:1.000000 (inf) G:1.000000 
(inf) B:1.000000 (inf) All:1.000000 (inf)

This is definitely good enough for my purposes, however.  I'm going to
declare victory and move on.

Thanks for your help!

-- 
========================================================================
                  In Soviet Russia, Google searches you!
========================================================================



More information about the ffmpeg-user mailing list