SDAVAssetExportSession
SDAVAssetExportSession copied to clipboard
Crash while export
Hello, This project is great (y), but I faced with few crashes on my application:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '***
-[AVAssetWriterInput appendSampleBuffer:] Must start a session (using -[AVAssetWriter startSessionAtSourceTime:) before appending sample buffers'
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '***
-[AVAssetWriterInput markAsFinished] Cannot call method when status is 0'
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '***
-[AVAssetReader initWithAsset:error:] invalid parameter not satisfying: asset != ((void *)0)'
Config is:
SDAVAssetExportSession *session = [[SDAVAssetExportSession alloc] initWithAsset:composition];
session.videoComposition = videoMix;
session.audioMix = audioMix;
session.videoSettings = @{
AVVideoCodecKey : AVVideoCodecH264,
AVVideoWidthKey : @640,
AVVideoHeightKey : @640,
AVVideoCompressionPropertiesKey : @{
AVVideoAverageBitRateKey : @2000000,
AVVideoProfileLevelKey : AVVideoProfileLevelH264Baseline31,
}
};
session.audioSettings = @{
AVFormatIDKey : @(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey : @2,
AVSampleRateKey : @44100,
AVEncoderBitRateKey : @64000,
};
session.outputURL = [[NSURL alloc] initFileURLWithPath:outPath];
session.outputFileType = AVFileTypeMPEG4;
session.shouldOptimizeForNetworkUse = YES;
Plus I'm using custom videoComposition and audioMix
They happens rarely - hard to reproduce, but.. any thoughts why this happens? Recommendations?
I had a similar issue that rarely occurred and nearly drove me mad. Turns out it was due to the rare case that input video had 0 audio tracks. (Think of 4x video filmed in an iOS device, for example. Apple removes the audio tracks from the video asset).
On Tue, Feb 10, 2015 at 11:00 AM, Aleksey Garbarev <[email protected]
wrote:
Hello, This project is great (y), but I faced with few crashes on my application:
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '* -[AVAssetWriterInput appendSampleBuffer:] Must start a session (using -[AVAssetWriter startSessionAtSourceTime:) before appending sample buffers'
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '* -[AVAssetWriterInput markAsFinished] Cannot call method when status is 0'
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[AVAssetReader initWithAsset:error:] invalid parameter not satisfying: asset != ((void *)0)'
Config is:
SDAVAssetExportSession *session = [[SDAVAssetExportSession alloc] initWithAsset:composition]; session.videoComposition = videoMix; session.audioMix = audioMix; session.videoSettings = @{ AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : @640, AVVideoHeightKey : @640, AVVideoCompressionPropertiesKey : @{ AVVideoAverageBitRateKey : @2000000, AVVideoProfileLevelKey : AVVideoProfileLevelH264Baseline31, } }; session.audioSettings = @{ AVFormatIDKey : @(kAudioFormatMPEG4AAC), AVNumberOfChannelsKey : @2, AVSampleRateKey : @44100, AVEncoderBitRateKey : @64000, }; session.outputURL = [[NSURL alloc] initFileURLWithPath:outPath]; session.outputFileType = AVFileTypeMPEG4; session.shouldOptimizeForNetworkUse = YES;Plus I'm using custom videoComposition and audioMix
They happens rarely - hard to reproduce, but.. any thoughts why this happens? Recommendations?
— Reply to this email directly or view it on GitHub https://github.com/rs/SDAVAssetExportSession/issues/21.
@axpence Thanks for response I figured out that crash 3 was my fault - (AVAsset was nil). But others are still here. Let's see If I can found the reason..
Also I have AVPlayer which plays my composition, videoComposition and audioMix at same time during export. (Could it is be a reason? Probably not)
@alexgarbarev How do you solve
@longhongwei17 solved my removing that library from my project and using standard AVAssetExportSession.
I'm also having the issue (using Swift 4) that happens maybe 1/20 times. I can barely find any info online about it. It crashes when I end the recording. It shows nothing in my code where it crashed, except in assembler in "libsystem_kernel.dylib`__pthread_kill:", but it appears that it crashes on endSession(atSourceTime:). I'm also already using AVAssetExportSession.
Did anyone find a solution for this? @alexgarbarev did was it a big job to swap out and use the standard AVAssetExportSession?
Hi @aaronwardle any updates?
Check the AVAssetWriterStatus before call "appendSampleBuffer:(CMSampleBufferRef)sampleBuffer". Sometimes the session will be cancel / failed by system.