AVErrorInvalidVideoComposition = -11841 AVErrorInvalidVideoComposition = -11841 arrays arrays

AVErrorInvalidVideoComposition = -11841


I found your question while having the same problem. My theory on this issue is that all the properties for the video composition are not set at export time, so it's crapping out. Here's the stanza that I am now using which is now resulting in an error-free export:

AVMutableVideoComposition *videoComposition = [AVMutableVideoComposition videoComposition];videoComposition.frameDuration = CMTimeMake(1,30);videoComposition.renderScale = 1.0;videoComposition.renderSize = CGSizeMake(352.0, 288.0);instruction.layerInstructions = [NSArray arrayWithObject: layerInstruction];instruction.timeRange = CMTimeRangeMake(kCMTimeZero, videoAsset.duration);videoComposition.instructions = [NSArray arrayWithObject: instruction];

In my case, I was missing the timeRange property on the instruction. Check your own properties to ensure they're getting the correct values. Good luck! This stuff is hard.


If you happen to be passing more than one main instruction to the instructions array of AVMutableVideoComposition, make sure that the time ranges do not overlap or it will cause this error.


You need to set opacity for the first LayerInstruction, e.g.:

[FirstlayerInstruction setOpacity:0.0 atTime:firstAsset.duration];