-
Notifications
You must be signed in to change notification settings - Fork 152
Description
Describe the bug
Not sure if there is one or several issues hidden within. Not even sure if it is issue with source or global problem. But i found specific file, which during transcode produces garbled result. It can be watched, but fragment containing 00:10-00:20 interval is missing. Issue is easily visible on PSNR/SSIM graphs.
There definitely is something weird with source, but i cannot easily distinguish what specifically is wrong. Weirdness is such - seeking via MPC-HC, VLC or PotPlayer with HW Acceleration enabled, causes video to stutter or jitter between "future" and "past" frames for about second after skip.
Windows native players do not have such issue, though (aka it seeks perfectly well), but if you do it too much, at some point it will end up "breaking" with 0xC00D36BB error. Playback HW also plays this video and seeks through more or less fine, so this one is perhaps on side of PotPlayer and LAV Filters?.
I have suspicions it is due to same exact non-IDR I-frames which caused corruption on skip causing me to raise these issues. Which i described in these issues:
#447
Nevcairiel/LAVFilters#580
Except unlike previous sample which only contained non-IDR I-frames marked as keyframes, this video still has proper IDR I-frames placed periodically, so it doesn't corrupt.
Source (fragment to reproduce. Cropped with ffmpeg from very beginning of the file):
https://drive.google.com/file/d/1DquRhTVLkG30A5-7lOq9JdqAP6uleF0R/view?usp=sharing
Transcoded with parameters that do not trigger bug:
https://drive.google.com/file/d/1SwGuj2c1G1X8to66c5Ile16-luj5QciM/view?usp=sharing
Transcoded with parameters that cause bug to happen:
https://drive.google.com/file/d/1yfVErVyEpkyxedp6x5Mt7esHMN50drGp/view?usp=sharing
Transcoded with TranscodeHW - has multiple issues: [Including offset by 5 frames and completely whacky seek table where audio seeks fine, but video skips HUGE chunks...]
https://drive.google.com/file/d/1tFR6o7RMPhCre7HTN4_ik0wFCYs1Wxlw/view?usp=sharing
[Encode of larger fragment with TranscodeHW also results in curious case when after performing a seek framerate can go to 144 fps for some time and then slows down to below intended value. (this particular one seems to be specific to MPC-HC for some reason).
Encoding full source makes it even worse, and you won't be able to seek with arrow keys, as video won't continue playing. And seeking by cursor will make it so 144 fps period will last for a WHILE (i counted about 40-50 seconds of sped up playback after seek)]
...
What i could find out within day of testing.
- Issue definitely is easily reproduceably with VCEEnc, and it is not tied to VCEEnc version (tried on old 8.17 and latest 8.37 versions to confirm).
- Issue also is reproduceable on all drivers since 25.3.1 (as it is oldest i can test with 9070XT)
- Issue is specific to source. Other sources still may produce some issues with frame-to-frame synchronisation (which actually is an issue, as seeking same exact frame on source and output won't actually show you same frame in some positions)
- Issue is NOT specific to decoder. It manifests either way, no matter if i use hardware decoder, or software one.
- Issue is specific to HEVC encoder, as i tried AVC and AV1 with same parameters and it does not produce such issue.
- Issue is specific to
--codec hevc --pa lookahead=X,ltr=true, whereXmust be10or higher for issue to be present (lookahead=9or lower will encode normally) - Issue is very similar to how encoding with TranscodeHW produces outputs with corrupted beginnings, except missing fragment with TranscodeHW is at 0:00 to 0:10 (first frame or two are still there), and not at 10-20 seconds interval.
There are at least 2 problems which prevent me from pinning issue further. - I cannot really set up same exact parameters in TranscodeHW... I do not really understand how i can set up automatic LTR during preanalysis properly.
- For some reason no matter what i try to encode with TranscodeHW, everything loses it's beginning in some way. This way analysing PSNR or SSIM of outputs from TranscodeHW becomes very problematic and using reference for comparison is not really viable unless issue is global throughout whole output.
To Reproduce
Used commands:
VCEEnc:
::Condition testing:
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_no_bug1%~x1" --avsw --codec hevc --preset slow --vbr 10000 --max-bitrate 30000
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_no_bug2%~x1" --avsw --codec hevc --preset slow --vbr 10000 --max-bitrate 30000 --pa ltr=true
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_no_bug3%~x1" --avsw --codec hevc --preset slow --vbr 10000 --max-bitrate 30000 --pa lookahead=41
::Limitation testing:
::Does not trigger bug:
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_no_bug4%~x1" --avsw --codec hevc --preset slow --vbr 10000 --max-bitrate 30000 --pa lookahead=9,ltr=true
::Triggers bug:
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_bug_threshold%~x1" --avsw --codec hevc --preset slow --vbr 10000 --max-bitrate 30000 --pa lookahead=10,ltr=true
::Bug reproduction:
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_VCEEnc_bugged%~x1" --avsw --codec hevc --preset slow --vbr 10000 --max-bitrate 30000 --pa lookahead=41,ltr=true
Attempt to reproduce with TranscodeHW, even though not sure if i should call it success or failure...
%~dp0\TranscodeHW.exe -input %1 -output "%~n1_TranscodeHW_nopa%~x1" -codec HEVC -HevcRateControlMethod vbr -HevcTargetBitrate 10000000 -HevcPeakBitrate 30000000 -HevcEnablePreAnalysis false
%~dp0\TranscodeHW.exe -input %1 -output "%~n1_TranscodeHW_pa%~x1" -codec HEVC -HevcRateControlMethod vbr -HevcTargetBitrate 10000000 -HevcPeakBitrate 30000000 -HevcEnablePreAnalysis -PALookAheadBufferDepth 41
Setup (please complete the following information):
- OS: Windows 11 23H2, 22631.5624
- Driver Version: 25.6.3 (can reproduce all the way back to 25.3.1)
- GPU: 9700XT
- Which component has the issue: Encoder?
Debug Log (please upload or paste):
Couldn't see anything wrong there, sadly. But here is log from creating problematic output.
VCEEncC_log.zip
Expected behavior
I would assume that such situation should not happen?
Would also be nice if TranscodeHW will stop garbling start of outputs from a lot of sources.
...
Additional context
This part is more of a preliminary question of "is it a bug?" type... [Aka should i format it as separate issue?]
Above i spoke about some frame to frame synchronisation issue. It is very peculiar, and i currently am not very keen on conditions. It happens both in TranscodeHW and in VCEEnc, but for each source results will vary.
UPD: For TranscodeHW it happens if source had it's first few seconds corrupted for some reason (depends on source, but common). While for VCEEnc it is global, and seems to be a separate issue...
...
After some additional testing, found out that for TranscodeHW when they get offset by about 4-5 frames for some reason, if i seeking a frame and they do not align, i need to go back frame by frame to find where they do align [aka 5073 frame in source = 5068 frame in output, or 10135==>10131]. I think it has some relation to that many sources are getting their beginnings corrupted. At least i came to this conclusion due to corellation observed.
Meanwhile it seems that issue with by-frame seek desync out of VCEEnc i also noticed while testing is slightly different. It just misses a "seek" mark by single frame, for some reason. Maybe some sort of doubling? Basically, if i seek, let's say 5960 frame on both source and output, then for source i will get actual 5960 frame, but for output i will get 5959 frame marked as if it was 5960. Then doing "next step", i get actual 5960 frame, while counter for "seek" window does not change and still shows 5960.
If i understand correctly it should not do that, so something is going on here? So i will probably report that to VCEEnc developer...


