Opened 4 years ago

Last modified 4 years ago

#8328 new defect

QSV gives much worse PSNR/SSIM for HEVC transcode than VA-API or MediaSDK

Reported by: eero-t Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: linjie.fu@intel.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

PSNR & SSIM values for transcoded HEVC files are much worse with QSV than when the same transcoding is done with VA-API or MediaSDK sample application.

(I haven't seen any significant difference in PSNR & SSIM between QSV and VA-API / MediaSDK with 8-bit AVC transcode.)

Setup:

  • Ubuntu 18.04
  • drm-tip kernel
  • yesterday's git build of FFmpeg, MediaSDK and media-driver

How to reproduce:

  • Transcode 4K 10-bit HEVC file [1] to smaller bitrate with QSV:
    $ ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v hevc_qsv -i Netflix_FoodMarket_4096x2160_10bit_420_100mbs_600.h265 -c:v hevc_qsv -b:v 20M -frames 300 output.h265
    
  • with VA-API:
    $ ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwacel_output_format vaapi -i Netflix_FoodMarket_4096x2160_10bit_420_100mbs_600.h265 -c:v hevc_vaapi -b:v 20M -frames 300 output.h265
    
  • And with MediaSDK:
    $ sample_multi_transcode -i::h265 Netflix_FoodMarket_4096x2160_10bit_420_100mbs_600.h265 -o::h265 output.h265 -b 20000 -u 4 -n 300 -async 4 -hw
    
  • Calculate PSNR & SSIM for each of the output files with FFmpeg:
    $ ffmpeg -i Netflix_FoodMarket_4096x2160_10bit_420_100mbs_600.h265 -i output.h265 -lavfi 'ssim;[0:v][1:v]psnr' -frames 300 -f null -
    

Result:

  • QSV: PSNR = 25
  • VA-API: PSNR = 40.7
  • MediaSDK: PSNR = 40.7

Notes:

  • Above QSV HEVC transcode has had bad PSNR at least since April (didn't try any older Media stacks), so if it's a regression, it's not a recent one
  • I've downloaded few other HEVC videos from net, and see similar PSNR value differences with them too
  • Unlike with VA-API, changing bitrate doesn't change PSNR/SSIM for QSV significantly with the above given transcode

[1] I'm using this, converted to 100Mbit/s with libx265 2-pass ABR:
https://media.xiph.org/video/derf/ElFuente/Netflix_FoodMarket_4096x2160_60fps_10bit_420.y4m

PS. FFmpeg PSNR calculation has a huge memory leak / loop with some input files. When doing above metrics calculation with problematic input videos, somewhat after passing halfway frame, frame number output freezes and FFmpeg starts eating GBs of memory until kernel OOM-kills it.

Attachments (1)

Netflix_FoodMarket_4096x2160_10bit_420_100mbs_60fps_7.h265 (2.4 MB ) - added by eero-t 4 years ago.
7 first frames from the 10-bit 4K HEVC test video

Change History (12)

comment:1 by eero-t, 4 years ago

This is on KBL GT2 & GT3e (I don't have newer HW to test).

comment:2 by Linjie.Fu, 4 years ago

Cc: linjie.fu@intel.com added

Hi eero-t,

Would you please help to bisect the regression commit?

comment:3 by eero-t, 4 years ago

Earliest media-driver and FFmpeg git builds I could find were from 2018 (media-driver & MediaSDK from start of November, FFmpeg from end of it). That year old version gives same bad PSNR with QSV => I would say that this QSV issue isn't a regression.

FYI: Transcoding the same 10-bit 4K HEVC file didn't work with VA-API in that old Nov 2018 FFmpeg/media-driver version, but that was fixed in Dec 2018, and at that point VA-API already had good PSNR.

Can you reproduce the issue?

PS. older versions of FFmpeg / media driver showed following warnings during encoding, which aren't shown anymore with the latest git versions (output below is from 2019 May git version):

...
[AVHWDeviceContext @ 0x55c7a5566340] VAAPI driver: Intel iHD driver - 1.0.0.
[AVHWDeviceContext @ 0x55c7a5566340] Driver not found in known nonstandard list, using standard behaviour.
[AVHWDeviceContext @ 0x55c7a5517f80] Initialize MFX session: API version is 1.29, implementation version is 1.29
[AVHWDeviceContext @ 0x55c7a5517f80] MFX compile/runtime API: 1.29/1.29
[AVHWDeviceContext @ 0x55c7a5771dc0] VAAPI driver: Intel iHD driver - 1.0.0.
[AVHWDeviceContext @ 0x55c7a5771dc0] Driver not found in known nonstandard list, using standard behaviour.
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1
    Last message repeated 1 times
[hevc_qsv @ 0x55c7a5520300] A decode call did not consume any data: expect more data at input (-10)
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1
[hevc_qsv @ 0x55c7a5520300] A decode call did not consume any data: expect more data at input (-10)
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1
[hevc_qsv @ 0x55c7a5520300] A decode call did not consume any data: expect more data at input (-10)
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1
    Last message repeated 2 times
[graph 0 input from stream 0:0 @ 0x55c7a5b8c540] w:4096 h:2160 pixfmt:qsv tb:1/1200000 fr:60/1 sar:0/1 sws_param:flags=2
[hevc_qsv @ 0x55c7a55332c0] Using the variable bitrate (VBR) ratecontrol method
[AVHWDeviceContext @ 0x55c7a5b8bb80] VAAPI driver: Intel iHD driver - 1.0.0.
[AVHWDeviceContext @ 0x55c7a5b8bb80] Driver not found in known nonstandard list, using standard behaviour.
[hevc_qsv @ 0x55c7a55332c0] profile: main10; level: 51
[hevc_qsv @ 0x55c7a55332c0] GopPicSize: 248; GopRefDist: 9; GopOptFlag: closed ; IdrInterval: 1
[hevc_qsv @ 0x55c7a55332c0] TargetUsage: 4; RateControlMethod: VBR
[hevc_qsv @ 0x55c7a55332c0] BufferSizeInKB: 5000; InitialDelayInKB: 2500; TargetKbps: 20000; MaxKbps: 20000; BRCParamMultiplier: 1
[hevc_qsv @ 0x55c7a55332c0] NumSlice: 1; NumRefFrame: 5
[hevc_qsv @ 0x55c7a55332c0] RateDistortionOpt: unknown
[hevc_qsv @ 0x55c7a55332c0] RecoveryPointSEI: unknown IntRefType: 0; IntRefCycleSize: 0; IntRefQPDelta: 0
[hevc_qsv @ 0x55c7a55332c0] MaxFrameSize: 0; MaxSliceSize: 0; 
[hevc_qsv @ 0x55c7a55332c0] BitrateLimit: unknown; MBBRC: unknown; ExtBRC: OFF
[hevc_qsv @ 0x55c7a55332c0] Trellis: auto
[hevc_qsv @ 0x55c7a55332c0] VDENC: OFF
[hevc_qsv @ 0x55c7a55332c0] RepeatPPS: OFF; NumMbPerSlice: 0; LookAheadDS: unknown
[hevc_qsv @ 0x55c7a55332c0] AdaptiveI: unknown; AdaptiveB: unknown; BRefType: pyramid
[hevc_qsv @ 0x55c7a55332c0] MinQPI: 0; MaxQPI: 0; MinQPP: 0; MaxQPP: 0; MinQPB: 0; MaxQPB: 0
[hevc_qsv @ 0x55c7a55332c0] GPB: ON
[hevc_qsv @ 0x55c7a55332c0] FrameRateExtD: 1; FrameRateExtN: 60 
Output #0, hevc, to 'output/0099_4K20.h265':
  Metadata:
    encoder         : Lavf58.27.103
    Stream #0:0: Video: hevc (hevc_qsv), 1 reference frame, qsv, 4096x2160, q=2-31, 20000 kb/s, 60 fps, 60 tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.52.101 hevc_qsv
    Side data:
      cpb: bitrate max/min/avg: 0/0/20000000 buffer size: 0 vbv_delay: -1
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1
    Last message repeated 21 times
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1e=10485.8kbits/s speed=0.368x    
    Last message repeated 12 times
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1e=10066.3kbits/s speed=0.389x    
    Last message repeated 12 times
[NULL @ 0x55c7a5520840] missing picture in access unit with size 1e=9933.9kbits/s speed=0.395x    
    Last message repeated 12 times
...

comment:4 by Linjie.Fu, 4 years ago

Would you please help to attach "Netflix_FoodMarket_4096x2160_10bit_420_100mbs_600.h265" in this ticket, since the provided y4m is rather large(14GB+).

BTW, I did some tests locally with a 4K, yuv420p10 clips, and this psnr issue is not reproduced with ffmpeg of either latest version or the commit at end of 2018.

Clips:
https://drive.google.com/file/d/1k0e5bBPs2JDHwJZdT8qBkpMdcwHywnSq/view?usp=sharing

ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v hevc_qsv -i 4K_10_sunflower.mp4 -c:v hevc_qsv -b:v 20M -frames 300 qsv.h265
ffmpeg version N-93010-g26ce3a43a3 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --enable-libmfx --disable-optimizations --enable-debug=3 --disable-stripping --enable-gpl --enable-libopenh264 --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 44.100 / 58. 44.100
  libavformat    58. 26.100 / 58. 26.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '4K_10_sunflower.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf58.33.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.33, start: 0.000000, bitrate: 4955 kb/s
    Stream #0:0(und): Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 4560 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
    Metadata:
      handler_name    : GPAC ISO Video Handler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 394 kb/s (default)
    Metadata:
      handler_name    : GPAC ISO Audio Handler
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (hevc_qsv) -> hevc (hevc_qsv))
Press [q] to stop, [?] for help
Output #0, hevc, to 'qsv.h265':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    genre           : Animation
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    encoder         : Lavf58.26.100
    Stream #0:0(und): Video: hevc (hevc_qsv), qsv, 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 20000 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      handler_name    : GPAC ISO Video Handler
      encoder         : Lavc58.44.100 hevc_qsv
    Side data:
      cpb: bitrate max/min/avg: 0/0/20000000 buffer size: 0 vbv_delay: -1
frame=  300 fps= 18 q=-0.0 Lsize=   16438kB time=00:00:09.86 bitrate=13648.0kbits/s speed=0.608x    
video:16438kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
ffmpeg -i 4K_10_sunflower.mp4 -i qsv.h265 -lavfi 'ssim;[0:v][1:v]psnr' -frames 300 -f null -
ffmpeg version N-93010-g26ce3a43a3 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --enable-libmfx --disable-optimizations --enable-debug=3 --disable-stripping --enable-gpl --enable-libopenh264 --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 44.100 / 58. 44.100
  libavformat    58. 26.100 / 58. 26.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '4K_10_sunflower.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf58.33.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.33, start: 0.000000, bitrate: 4955 kb/s
    Stream #0:0(und): Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 4560 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
    Metadata:
      handler_name    : GPAC ISO Video Handler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 394 kb/s (default)
    Metadata:
      handler_name    : GPAC ISO Audio Handler
Input #1, hevc, from 'qsv.h265':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: hevc (Main 10), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1200k tbn, 30 tbc
Applying unspecific -frames to non video streams, maybe you meant -vframes ?
Stream mapping:
  Stream #0:0 (hevc) -> ssim:main (graph 0)
  Stream #0:0 (hevc) -> psnr:main (graph 0)
  Stream #1:0 (hevc) -> ssim:reference (graph 0)
  Stream #1:0 (hevc) -> psnr:reference (graph 0)
  ssim (graph 0) -> Stream #0:0 (wrapped_avframe)
  psnr (graph 0) -> Stream #0:1 (wrapped_avframe)
  Stream #0:1 -> #0:2 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    genre           : Animation
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    encoder         : Lavf58.26.100
    Stream #0:0: Video: wrapped_avframe, yuv420p10le, 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.44.100 wrapped_avframe
    Stream #0:1: Video: wrapped_avframe, yuv420p10le, 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.44.100 wrapped_avframe
    Stream #0:2(und): Audio: pcm_s16le, 48000 Hz, 5.1, s16, 4608 kb/s (default)
    Metadata:
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.44.100 pcm_s16le
frame=  300 fps=5.0 q=-0.0 Lq=-0.0 size=N/A time=00:00:10.00 bitrate=N/A speed=0.167x    
video:314kB audio:3600kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_ssim_0 @ 0x559413792f00] SSIM Y:0.998935 (29.728072) U:0.998056 (27.112709) V:0.997992 (26.972283) All:0.998632 (28.637829)
[Parsed_psnr_1 @ 0x559413796300] PSNR y:52.651755 u:53.405014 v:53.026333 average:52.830453 min:42.830295 max:inf

by eero-t, 4 years ago

7 first frames from the 10-bit 4K HEVC test video

comment:5 by eero-t, 4 years ago

Upload size limit forced me to clip the attached video to first 7 frames. Shorter video reduces the quality gap between QSV & VA-API from 25 vs 40+ PSNR to 28 vs 31 PSNR.

comment:6 by Linjie.Fu, 4 years ago

It could be reproduced with the attached clips.

The output of QSV and VAAPI have the different number of B-frames between non-B-frames of B frames.

QSV: 6 (not reach the maximum);
VAAPI: 2;

Hence it leads to the PSNR gap.

The root cause seems to be that QSV and VAAPI have the different GopRefDist size by default.

VAAPI: 3

[hevc_vaapi @ 0x563647540b00] Using intra, P- and B-frames (supported references: 3 / 1).

QSV: 9

[hevc_qsv @ 0x564c7866da40] GopPicSize: 248; GopRefDist: 9; GopOptFlag: closed ; IdrInterval: 1

To verify:

Add "-bf 2" to match the default behavior of VAAPI

ffmpeg -v verbose -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v hevc_qsv -i Netflix_FoodMarket_4096x2160_10bit_420_100mbs_60fps_7.h265 -c:v hevc_qsv -b:v 20M -bf 2 output.h265

(add -bf 2 makes no difference for VAAPI)

Before:
PSNR: average:28.524304
With "-bf 2":
PSNR: average:31.516557

Please help to verify and correct me if I was wrong.

comment:7 by eero-t, 4 years ago

"-bf 2" option gives same good PSNR for QSV as with VA-API, in the full video (41 instead of 25).

It reduces bitrate 3% from the requested 20Mbit/s i.e. it seems to make QSV bitrate slightly less accurate (VA-API bitrate is closer to requested, at least in this case).

While "-bf 2" option didn't do anything for VA-API, giving "-bf 6" option for it, dropped VA-API PSNR marginally (<1%).

Is that huge PSNR drop with larger QSV B-frame count a driver issue, or should FFmpeg QSV default be just changed?

comment:8 by Linjie.Fu, 4 years ago

It's not an issue IMHO.

For VAAPI hevc encoder, the default parameter for bf is 2:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/vaapi_encode_h265.c#L1265

For QSV hevc encoder, the default parameter for bf is 8:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc_hevc.c#L261

And for some historical reasons, it was set to 8 on purpose:
https://github.com/FFmpeg/FFmpeg/commit/a43905f4ae261bdde87c300901d867b31961f57b

Hence in this performance test, a better choice could be setting "-bf" with the same value explicitly for both VAAPI and QSV, instead of using the default settings of codecs(usually parameters are different between each codec).

comment:9 by Linjie.Fu, 4 years ago

If no against, will close this in 24h.

in reply to:  8 comment:10 by eero-t, 4 years ago

Replying to fulinjie:

BTW, I did some tests locally with a 4K, yuv420p10 clips, and this psnr issue is not reproduced with ffmpeg of either latest version or the commit at end of 2018.
Clips:

​> https://drive.google.com/file/d/1k0e5bBPs2JDHwJZdT8qBkpMdcwHywnSq/view?usp=sharing

Is this original 4K content, or upscaled 2K content (i.e. lacking details, which would affect quality metrics)?

I tried to reproduce your results with a version of that video that I know to have 4K of details, but ran into another Ffmpeg bug: https://trac.ffmpeg.org/ticket/8342

Replying to eero-t:

While "-bf 2" option didn't do anything for VA-API, giving "-bf 6" option for it, dropped VA-API PSNR marginally (<1%).

Whereas giving -bf 8 to VA-API, drops it to 32 (from 41), which is still noticeably better than 25 from QSV.

Replying to fulinjie:

It's not an issue IMHO.

For VAAPI hevc encoder, the default parameter for bf is 2:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/vaapi_encode_h265.c#L1265

For QSV hevc encoder, the default parameter for bf is 8:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc_hevc.c#L261

And for some historical reasons, it was set to 8 on purpose:
https://github.com/FFmpeg/FFmpeg/commit/a43905f4ae261bdde87c300901d867b31961f57b

QSV backend comment seems a bit dubious. GOP has also P-frames, so number of B-frames isn't going to evenly match GOP anyway, especially if driver / HW can also automatically adapt the number of B-frames like x264 & x265 do.

Looking at the history, earlier values (250 gop, 3 bf) were the same as what's used in qsvenc_h264.c, and which are stated to be defaults for x264.

Therefore same values that x265 might be relevant also for qsvenv_hevc.c. According to x265 docs, it defaults to 4:

https://x265.readthedocs.io/en/default/cli.html#slice-decision-options

I tested different -bf values:

  • 2: PSNR=41
  • 4: PSNR=41
  • 6: PSNR=41
  • 7: PSNR=41
  • 8: PSNR=25
  • 12: PSNR=25
  • 16: PSNR=25

(Setting GOP size to original 250, gave same PSNR=25 with -bf 8.)

I tested also another HEVC video (Crown Run) which is marginally smaller (3840x2160), 8-bit, and has less details than the FoodMarket video. With that, PSNR dropped from 35 to 24, when -bf was increased from 11 to 12.

Then I tried couple of 10-bit HEVC videos in quarter size (1920x1080). PSNR for those didn't drop even with -bf 16.

From above it would seem that large B-frame numbers could be problem in larger resolutions, especially with videos where content has a lot of details & their changes.

Hence in this performance test, a better choice could be setting "-bf" with the same value explicitly for both VAAPI and QSV, instead of using the default settings of codecs(usually parameters are different between each codec).

My small testing seems to indicate that current default value may be badly chosen for more demanding content.

Could you discuss this with the driver team, what is their recommendation on these nowadays?

Maybe do also your own testing on whether you see large quality drops when content is large & detailed enough and B-frame count goes over some threshold? If you have good (not upscaled) 8K content, it would be good to test that too.

comment:11 by eero-t, 4 years ago

Recap of the findings:

  • Individual frames contents are fine, checked by converting both files to raw and calculating PSNR
  • Forcing frame-rate for the QSV encoded file in PSNR calculation with "-r 60" also gives good PSNR, although encoded video frame-rate is already 60
  • When calculating PSNR for more frames, PSNR gets worse

One explanation that I could think for this is:

  • Encoded video includes individual frame times (offsets?) in addition to overall video frame rate
  • FFmpeg does PSNR comparison by aligning video frames to a timeline based on individual frame timings (unless one specifies -r option), instead of comparing frames as-is
  • Timings for individual encoded frames drift (are truncated or rounded up?) with QSV when it uses higher B-frame count => bug

Linjie, could you check my theory; get the individual frame timings for both videos out of FFmpeg and check whether they differ?

Note: See TracTickets for help on using tickets.