-
Notifications
You must be signed in to change notification settings - Fork 24
HEVC encoder inserts VPS SPS PPS NAL units every frame. AUD delimiters for AVC and HEVC. #133
Description
When i investigated some discrepancies with metrics between outputs from reference TranscodeHW and VCEEnc, i found out one noticeable difference in how VCEEnc writes HEVC output in particular (AVC also is slightly different, but in much less significant matter).
[After setting up forced AMF defaults for each codec and trying out other comparison methods i found reason, it was faulty tool...]
While i managed to encode pretty much fully identical (outside of raw bitstream comparison) outputs for AVC and HEVC, HEVC was still slightly different.
Main issue:
For VCEEnc HEVC encoder, VPS/SPS/PPS are written for every single frame, instead of every I-frame (key frame)
Reference TranscodeHW, compiled from AMF sources behaves properly.
If i understand correctly these NAL units do count in bitrate, and as these headers to take quite a number of bytes, hence in long distance it may be slightly harming output quality by spending bitrate budget on repeating headers.
...
Secondary difference [not much of a problem, just a nitpick]:
VCEEnc does not insert AUD delimiters before each data unit for AVC and HEVC. This one is not as significant relative to main problem as at least some tools that put streams into contaner do strip those delimiters anyways (Usually for AVC only, though).
...
VCEEnc and Reference encoder commands:
I managed to produce AVC and AV1 outputs that are identical to ones that i generate with TranscodeHW with these commands
::AVC
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_avc.mkv" --avsw --codec avc --vbr 10000 --max-bitrate 30000 --audio-copy --gop-len 240 --ref 4
%~dp0\TranscodeHW.exe -input %1 -output "%~n1_TranscodeHW_avc%~x1" -codec AVC -RateControlMethod vbr -TargetBitrate 10000000 -PeakBitrate 30000000
::AV1
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_av1.mkv" --avsw --codec av1 --vbr 10000 --max-bitrate 30000 --audio-copy --gop-len 240 --ref 1
%~dp0\TranscodeHW.exe -input %1 -output "%~n1_TranscodeHW_av1%~x1" -codec AV1 -Av1RateControlMethod vbr -Av1TargetBitrate 10000000 -Av1PeakBitrate 30000000
Other than GOP length and amount of reference frames for HEVC and AV1 there seems to be no difference after version when set of parameters was switched to use AMF defaults. HEVC should in theory do same via using AMF default --ref 1 and --level 5.2 (VCEEnc defaults to 5.1). But i wasn't able to yet create identical outputs specifically with HEVC.
::HEVC
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_hevc.mkv" --avsw --codec hevc --vbr 10000 --max-bitrate 30000 --audio-copy --gop-len 240 --ref 1 --level 5.2
%~dp0\TranscodeHW.exe -input %1 -output "%~n1_TranscodeHW_hevc%~x1" -codec HEVC -HevcRateControlMethod vbr -HevcTargetBitrate 10000000 -HevcPeakBitrate 30000000
My current assumption is that excessive insertion of NAL units affect encoder bitrate distribution.
Moved into separate issue
Ah yeah, forgot about another thing. Somewhat outside of scope of original issue, but shouldn't be too hard to adjust.
-
AVC and HEVC currently do not seem to have proper
--preset slowersetup. They produce same output as--preset slow. Unless AMF has no difference between them as well? -
AVC
--preset fastalso does not seem to be working properly? (it produces same output as--preset balanced) [HEVC and AV1 ones do work for reference]