Note that there are some explanatory texts on larger screens.

plurals
  1. POException error trying to merge videos with AVMutableComposition: "objects cannot be nil"... but they don't appear to be nil?
    text
    copied!<p>My brain feels like scrambled eggs... I'm trying to merge video clips together. I have each clip URL stored in an NSMutableArray (arrayClipURL) &amp; that's all good. When I print timeRanges &amp; tracks (both NSMutableArrays) in debug console, everything checks out, which means for loop is doing its job. I keep getting an exception error: '<em>*</em> -[__NSArrayM insertObject:atIndex:]: object cannot be nil'. </p> <p>I threw in an exception breakpoint and its breaking at the last line below. I cant figure it out because both timeRanges and tracks are NOT nil... I can print them in the debug console and see them just fine directly before the line that breaks. </p> <pre><code>composition = [[AVMutableComposition composition] init]; composedTrack = [[AVMutableCompositionTrack alloc] init]; composedTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; NSMutableArray * timeRanges = [[NSMutableArray alloc] initWithCapacity:arrayClipURL.count]; NSMutableArray * tracks = [[NSMutableArray alloc] initWithCapacity:arrayClipURL.count]; for (int i=0; i&lt;[arrayClipURL count]; i++){ AVURLAsset *assetClip = [[AVURLAsset alloc] initWithURL:[arrayClipURL objectAtIndex:i] options:nil]; AVAssetTrack *clipTrack = [[AVAssetTrack alloc] init]; clipTrack = [[assetClip tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; [timeRanges addObject:[NSValue valueWithCMTimeRange:CMTimeRangeMake(kCMTimeZero, assetClip.duration)]]; [tracks addObject:clipTrack]; } debug(@"timeranges: %@",timeRanges); debug(@"tracks: %@",tracks); [composedTrack insertTimeRanges:timeRanges ofTracks:tracks atTime:kCMTimeZero error:nil]; </code></pre> <p>I am in need of some veteran assistance :( Any idea what could be causing the problem?</p> <p>Edit: Here are how the 2 arrays look printed in the console. The only thing I can think of is maybe the CMTimeRange or AVAssetTrack aren;t formatted properly in the arrays??? i have no idea. Just thought it might help to see what it's actually trying to insert when the exception is thrown.</p> <pre><code> 2013-02-18 13:18:20.811 app[5242:907] [AVCaptureManager.m:401] timeranges array: ( "CMTimeRange: {{0/1 = 0.000}, {498/600 = 0.830}}", "CMTimeRange: {{0/1 = 0.000}, {556/600 = 0.927}}" ) 2013-02-18 13:18:20.812 app[5242:907] [AVCaptureManager.m:402] tracks array: ( "&lt;AVAssetTrack: 0x220c21a0, trackID = 1, mediaType = vide&gt;", "&lt;AVAssetTrack: 0x1cdec820, trackID = 1, mediaType = vide&gt;" ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload