0

To add a time range to an AVMutableCompositionTrack you have to specify the start time in the track (at:)...

  try track?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero,
                                             duration: CMTime(seconds: 2, preferredTimescale: CMTimeScale(1))),
                             of: asset.tracks(withMediaType: .video)[0],
                             at: composition.duration)

Let's say I have several tracks in a mutable composition such that their time ranges play in a sequence with no gaps. If I remove, say, the second track, then do all the following tracks need to have their start time manually updated? Similarly, do all the track instructions need to be updated too? Or is there a way of having this happen automatically?

Ian Warburton
  • 15,170
  • 23
  • 107
  • 189

1 Answers1

1

Tracks are not like a rosary that when you grab a few seeds the other ones shift automatically , yes you have to update the times manually in the mutable composition and the instructions

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • That sounds like a lot of work. Perhaps it's worth keeping a separate data structure that *does* act like a rosary and then updating from there. – Ian Warburton Jun 06 '20 at 16:08