Problem with rendering AVAssetExportSession

AVAssetExportSession crashes when rendering more than 7 clips. No matter how long the clips are, it always crashes. I am sure this is a memory leak, because it tells you that the phone disconnected from xcode when it works.

AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetHighestQuality]; [exporter setOutputURL:outputURL]; [exporter setOutputFileType:AVFileTypeQuickTimeMovie]; [exporter setVideoComposition:output]; [exporter setAudioMix:mix]; [exporter setShouldOptimizeForNetworkUse:YES]; /* Begin exporting the video. */ [exporter exportAsynchronouslyWithCompletionHandler:^{ // *NARROWED IT DOWN, THE CRASH OCCURS SOMETIMES IN THE MIDDLE* /* Do this off of the main thread to increase speed. */ dispatch_async(dispatch_get_main_queue(), ^{ /* Call the user completion block and pass it the URL of the exported video. */ if (exporter.status == AVAssetExportSessionStatusCompleted) { NSLog(@"success"); handler([exporter outputURL]); } else { NSLog(@"error: %@", [exporter error]); } }); }]; 

We do not use SCRecorder. We use AVAssetExportSession directly. We do a bunch of custom materials with music, so we cannot integrate SCRecorder into what we have already created. We use AVMutableComposition to stitch clips and render them through AVAssetExportSession.

Is there something we are doing wrong or maybe working?

+5
source share

Source: https://habr.com/ru/post/1264549/


All Articles