-
Notifications
You must be signed in to change notification settings - Fork 24
Implement way to react on AMF "corrupted frame" detection error. #124
Description
Starting with 25.5.1 driver, old corrupted samples i had (that are used for testing for changes) started to error out with 0 frames encoded.
With VCEEnc it looks like this.
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_test1%~x1" --audio-copy --chapter-copy --sub-copy --colorrange auto
Exception Code: 0xC0000005
0x00007FF7CACC0877, C:\Users\-----\Desktop\Utilites\Video_Transcoding_stuff\VCEEncC_x64\VCEEncC64.exe(0x00007FF7CAC60000) + 0x60877 byte(s)
0x00007FF7CACE478E, C:\Users\-----\Desktop\Utilites\Video_Transcoding_stuff\VCEEncC_x64\VCEEncC64.exe(0x00007FF7CAC60000) + 0x8478E byte(s)
0x00007FF7CACB1E58, C:\Users\-----\Desktop\Utilites\Video_Transcoding_stuff\VCEEncC_x64\VCEEncC64.exe(0x00007FF7CAC60000) + 0x51E58 byte(s)
0x00007FF7CACB2585, C:\Users\-----\Desktop\Utilites\Video_Transcoding_stuff\VCEEncC_x64\VCEEncC64.exe(0x00007FF7CAC60000) + 0x52585 byte(s)
0x00007FF7CAEA2210, C:\Users\-----\Desktop\Utilites\Video_Transcoding_stuff\VCEEncC_x64\VCEEncC64.exe(0x00007FF7CAC60000) + 0x242210 byte(s), clrngGetLibraryDeviceIncludes() + 0xA4E0 byte(s)
0x00007FFF00EC259D, C:\Windows\System32\KERNEL32.DLL(0x00007FFF00EB0000) + 0x1259D byte(s), BaseThreadInitThunk() + 0x1D byte(s)
0x00007FFF0180AF58, C:\Windows\SYSTEM32\ntdll.dll(0x00007FFF017B0000) + 0x5AF58 byte(s), RtlUserThreadStart() + 0x28 byte(s)
Exiting!
Digging deeper (in other words, trying ffmpeg with AMF decoder [as D3D11VA does work] and TranscodeHW, it all fell down to AMF decoder throwing new error.
2025-05-11 04:01:31.837 3434 [h264_hevc_util] Error: C:\constructicon\builds\gfx\six\25.10\drivers\amf\stable\runtime\src\components\VideoStreamParser\parsers\common\h264_hevc_util.cpp(369):Assertion failed:element=pCurrSlice->start_mb_nr val =4080 out of range(0,4079)
2025-05-11 04:01:31.837 3434 [H264Parser] Error: C:\constructicon\builds\gfx\six\25.10\drivers\amf\stable\runtime\src\components\VideoStreamParser\parsers\h264\H264Parser.cpp(2656):AMF_ERROR 5 : AMF_OUT_OF_RANGE: FirstPartOfSliceHeader() failed
2025-05-11 04:01:31.837 3434 [H264Parser] Error: C:\constructicon\builds\gfx\six\25.10\drivers\amf\stable\runtime\src\components\VideoStreamParser\parsers\h264\H264Parser.cpp(1890):Assertion failed:ProcessSlice() failed
2025-05-11 04:01:31.837 3434 [H264Parser] Error: C:\constructicon\builds\gfx\six\25.10\drivers\amf\stable\runtime\src\components\VideoStreamParser\parsers\h264\H264Parser.cpp(2137):Assertion failed:ret != READ_ERROR
2025-05-11 04:01:31.837 3434 [AMFVideoStreamParserImpl] Error: C:\constructicon\builds\gfx\six\25.10\drivers\amf\stable\runtime\src\components\VideoStreamParser\VideoStreamParserImpl.cpp(201):AMF_ERROR 1 : AMF_FAIL: SubmitInput : m_pVideoParser->ParseBuffer
2025-05-11 04:01:31.838 3434 [AMFDecoderUVDImpl] Error: C:\constructicon\builds\gfx\six\25.10\drivers\amf\stable\runtime\src\components\DecoderUVD\DecoderUVDImpl.cpp(666):AMF_ERROR 1 : AMF_FAIL: SubmitInput() - Parser SubmitInput Failed
SubmitInput() returned error: AMF_FAIL
Not sure how it looks for HEVC and AV1 though. Corrupted sources i have are AVC only.
Anyways... After some questioning on AMF repo (as issue hit basically everything) i was told that it is new feature, and processing of these errors should be done on application side, not AMF.
Link to related issue: GPUOpen-LibrariesAndSDKs/AMF#553
By default ffmpeg drops corrupted frames. (Except with AMF update it is not properly set up to do so with AMF decoder, only D3D11VA).
But then... What behaviour VCEEnc should have?
I think that dropping corrupted frame and continuing encode would be most optimal, if possible. But i also do think that user should be still at some point that either corrupted frame was detected, or that there was dropped frame in encode. Just as warning/notification. (This is how ffmpeg behaves. It will show you dropped frame count after encode completion and, depending on source/decoder, print out error or warning in process of encode itself).
If not possible, though, then... Well, simply throwing an error and gracefully finishing process will also work. Maybe suggesting to try SW decoder.