2

I have a HEVC video. I converted it to VP8 and VP9 by using the FFmpeg commands below:

ffmpeg -i ./hevc.mp4 -vcodec libvpx -crf 18 -b:v 0 -speed 1 ./vp8.webm

ffmpeg -i ./hevc.mp4 -vcodec libvpx-vp9 -crf 18 -b:v 0 -speed 1 ./vp9.webm

The conversion was very successful. But the ssim value I calculated via FFmpeg commands below:

ffmpeg -y -i hevc.mp4 -i vp8.webm -filter_complex "ssim" -f hevc /dev/null

ffmpeg -y -i hevc.mp4 -i vp9.webm -filter_complex "ssim" -f hevc /dev/null

Both of the VP8 and VP9 videos got the ssim values that were smaller than 0.99. These were bad results that I didn't expect.

If I convert the HEVC video to x264, the ssim values will be normal.

Are there any problems among my commands?

user3032481
  • 548
  • 6
  • 18
  • The reference video should be the 2nd input. – Gyan Feb 21 '16 at 14:48
  • You mean I should enter the command like this ffmpeg -y -i vp8.webm -i hevc.mp4 -filter_complex "ssim" -f hevc /dev/null ? I tried, it was the same. – user3032481 Feb 21 '16 at 16:06
  • Do encodes with lower CRFs show higher scores? – Gyan Feb 21 '16 at 16:17
  • The ssim grow very tiny with lower CRF. The ssim value is still low(< 0.99). But I found another way. VP9 can be lossless. So, I convert HEVC to VP9 lossless, then convert VP9 lossless to VP9(loosy, using crf 18), and compute the ssim value between VP9 lossless and VP9(loosy), the ssim value is bigger than 0.993, that is the number that I expect. But VP8 has the same problem even the source is VP9 lossless instead of hevc. Maybe this is a timestamp problem? – user3032481 Feb 21 '16 at 16:57
  • Is the source constant framerate? Is the pixel format the same for HEVC and WebM videos? Try `setpts=PTS-STARTPTS` for both. – Gyan Feb 21 '16 at 17:11
  • How to check my framerate? The pixel format is the same that is yuv420p. How to use `setpts=PTS-STARTPTS` correctly? My command is `ffmpeg -y -i vp8.webm -i hevc.mp4 -filter_complex "ssim; [0:v] setpts=PTS-STARTPTS;[1:v] setpts=PTS-STARTPTS" -f webm /dev/null` . Am I right? – user3032481 Feb 21 '16 at 17:43
  • No. `ffmpeg -y -i vp8.webm -i hevc.mp4 -filter_complex "[0:v]setpts=PTS-STARTPTS[v0];[1:v] setpts=PTS-STARTPTS[v1];[v0][v1]ssim" -f webm /dev/null` – Gyan Feb 21 '16 at 17:47
  • It works! Thank you very much, @Mulvya – user3032481 Feb 21 '16 at 18:14
  • When you calculate SSIM "after the fact" (i.e. you have both video files), you don't need `-f hevc`, especially for `/dev/null` output. (This reencodes something, burning electricity). Just use `-f null`. – Tomasz Gandor Jun 14 '17 at 10:28

1 Answers1

2

To perform SSIM only on a reference and comparison file as of FFMPEG 4.0 and later:

ffmpeg -i test.mp4 -i reference.mp4 -lavfi libvmaf="[0:v][1:v]ssim" -f null -

Requires the VMAF filter be compiled into FFMPEG.

See the FFMPEG docs section on SSIM for more info: https://ffmpeg.org/ffmpeg-filters.html#ssim

bitkid
  • 41
  • 5