title: How to merge the videos using AVMutableComposition in iPhone sdk
body: <p>i have used the following way but videos didn't merge and in the output the last video added to AVMutableCompositionTrack gets stored in Library.</p>
  
  <pre><code>NSArray *arrVideoUrl=[objApp.dictSelectedVideos allKeys];
  AVURLAsset *video1=[[AVURLAsset alloc]initWithURL:[arrVideoUrl objectAtIndex:0] options:nil];
  AVURLAsset *video2=[[AVURLAsset alloc]initWithURL:[arrVideoUrl objectAtIndex:1] options:nil];
  AVURLAsset *audioAsset=[[AVURLAsset alloc]initWithURL:songUrl options:nil];
  
  AVMutableComposition *mixcomposition=[AVMutableComposition composition];
  
  AVMutableCompositionTrack *track1=[mixcomposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
  [track1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, video1.duration) ofTrack:[[video1 tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
                   atTime:kCMTimeZero error:nil];
  
  
  AVMutableCompositionTrack *track2=[mixcomposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
  
  [track2 insertTimeRange:CMTimeRangeMake(kCMTimeZero, video2.duration) ofTrack:[[video2 tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
                   atTime:kCMTimeZero error:nil];
  </code></pre>
  
  <p>Can anyone please help me out ?</p>