0

I have an AVComposition containing multiple video and audio tracks. So far, it's pure programmatically, no GUI. I want the user to be able to push one track a couple of frames back or forth on will, by clicking a button. e.g: a button titled "-10 frames" will push a track 10 frames back, while "+10 frames" pushes it 10 frames forward. I can't find any way to actually move a track after it has been added using insertTimeRange:ofTrack:atTime:.

I tried to remove it and re-adding it like this:

[secondAudioTrack removeTimeRange:CMTimeRangeMake(kCMTimeZero, kCMTimeIndefinite)];
    [secondAudioTrack insertTimeRange:range ofTrack:[[secondAsset tracksWithMediaType:AVMediaTypeAudio] firstObject] atTime:newTime error:nil];

And it's not actually moving so far (I might've done something wrong though), but I feel like this is such a hacky way of doing it.. Anyone know of a proper way to give a new time to an already added track in an AVComposition?

Sti
  • 8,275
  • 9
  • 62
  • 124
  • best bet would be to rebuild the track layouts and composition after each change, we have an app that uses 4 video and 4 audio tracks and this works well – box86rowh Mar 18 '15 at 00:07

1 Answers1

0

I don't think there is. The complete video should be planned out before involving video composition. Let the user provide only information, save it, then run the video composition only when you have enough information from the user. Start clean each time. You should never have to change the time range inside an AVMutableCompositionTrack.

iOSAaronDavid
  • 140
  • 15