I have function that adds multiple segments in a AVMutableCompositionTrack in a video editor for iPhone. I am using following method
[self.compositionVideoOneTrack insertTimeRange:video_timeRange ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:CMTimeMakeWithSeconds(videoSegmentData.startTime, VIDEO_TIME_SCALE) error:nil];
Everything works fine. Now I am required to increment in startTime of each of already added segments in the compositionTrack. I have so far found no mechanism but to remove all segments and rewrite them at new position from start.
- I have tried to get all AVCompositionTrackSegment in the compositionTrack and change the startTime of target but it is not assignable.
- I have tried
[self.compositionVideoOneTrack removeTimeRange:videoSegmentData.videoTimeRange];
to remove a segment and then insert it again at good position. But this call make all segments next to removed segments move towards left. The insert at good position overlaps with segments that are moved towards left.
Looking forward for a solution.