Opened 2 years ago
Last modified 2 years ago
#9481 new defect
VA-API + QSV H264 => MPEG2 transcode PSNR dropped by 25%
Reported by: | eero-t | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | unspecified | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Between following FFmpeg commits:
- 2021-09-22 a487635b85: avcodec/dynamic_hdr10_plus: check size before using it
- 2021-09-23 6e26015a6b: avformat/astenc: Simplify writing padding
PSNR for following transcode operation:
$ ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i 720x480p_30.00_4mb_h264_cabac_180s.264 -c:v mpeg2_vaapi -b:v 2000K -compression_level 4 -an -vframes 4800 -y 0039_SD03MP2_1.0.mpg
Has dropped by 25%, as measured by:
$ ffmpeg -i 720x480p_30.00_4mb_h264_cabac_180s.264 -i 0039_SD03MP2_1.0.mpg -an -vframes 2399 -filter_complex psnr -f null -
(I'm using fewer frames in PSNR check than for transcode, because there were odd results if all frames are used for PSNR calculation.)
Between same commits, PSNR for similar transcode done using QSV:
ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v h264_qsv -i 720x480p_30.00_4mb_h264_cabac_180s.264 -c:v mpeg2_qsv -b:v 2000K -compression_level 4 -an -vframes 4800 -y 0039_SD03MP2_1.0.mpg
also dropped to same value, but the drop for QSV transcode PSNR was smaller because it had dropped from the original VA-API PSNR value by 7% already earlier, between these FFmpeg commits:
- 2021-03-14 1af4885014: avcodec: add a mention about get_encode_buffer in the old encode API doxy
- 2021-03-15 63344337f9: libavformat/hls: Reset options after open_url_keepalive() fails
(I did not pay attention to that earlier/smaller QSV PSNR drop because there was at the same time marginal (<1%) perf increase, and updates in underlying drm-tip kernel & MediaSDK components.)
See also #9377.
Now results of both VA-API and QSV transcode operations give same (low) PSNR as using MediaSDK tool to do same transcode has been giving:
sample_multi_transcode -i::h264 720x480p_30.00_4mb_h264_cabac_180s.264 -o::mpeg2 0039_SD03MP2_1.0.mpg -b 2000 -u 4 -n 4800 -async 4 -hw
Change History (6)
comment:1 by , 2 years ago
comment:2 by , 2 years ago
I found the problem is not about VA-API or QSV. Between two commits, the encoded stream is identical. It is PSNR calculation command that returns different results. If I run PSNR calculation command on the same output video on two commits, I get different result.
The decoded yuv data of build-in 264 decoder on two commit have same md5 value, so seems it is an issue of PSNR filter.
comment:3 by , 2 years ago
so seems it is an issue of PSNR filter.
Or a bugfix. After all MS SSIM was fixed in fcc0424c933742c8fc852371e985d16b6eb4bfe9 and it did change the output.
comment:4 by , 2 years ago
FYI: Quality reported by SSIM for that transcode operation dropped also between these commits. SSIM drop (9%) was smaller than with PSNR (25%).
comment:5 by , 2 years ago
Note: using "-vsync passthrough" is not a workaround for this regression, like it is for #9377. Neither with QSV nor with VA-API.
comment:6 by , 2 years ago
You need to set all (at least 3) parameters for PSNR for it to work on the same frames. Please also rename an issue.
I will quote Paul on this:
"Use "setpts=PTS-STARTPTS,split=2[a][b],[a][1:v]ssim;[b][1:v]psnr".
Your first input pts does not start from 0.
You also need to use settb to set both inputs to same timebase, and do that before using setpts filters."
These H264 -> MPEG2 transcode results PSNR drops are visible in the data from all the machines I have which support encoding to MPEG2 (SKL, KBL, CML, TGL).
Here's FFmpeg output for the VA-API transcode: