hap-in-avfoundation
hap-in-avfoundation copied to clipboard
AVF Batch Exporter crash on Catalina in certain situation (and proposed fix)
We recommend our (EboSuite) users to use the AVF Batch Exporter and some of our users had crashes while converting (as I understood) all the files they tried after upgrading to Catalina.
This was the error mentioned in the crash log:
Crashed Thread: 1 Dispatch queue: VVAVFTranscoder
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriterInput appendSampleBuffer:] Cannot append sample buffer: First input buffer must have an appropriate kCMSampleBufferAttachmentKey_TrimDurationAtStart since the codec has encoder delay'
abort() called
terminating with uncaught exception of type NSException
The odd thing is that we initially couldn't reproduce it on Mojave and also not on the first Catalina machine we tried, but later could using another machine (testing all the time with the same file that one user provided as a test). I don't understand how this could happen, but well..
I managed to fix this crash by adding a few lines in VVAVTranscoder.m . I check if the first buffer returned for each track has TrimDurationAtStart key and if not I add it (using the asset's duration as time). This fixes it.