2

When creating an AVMutableComposition with 2 video AVMutableCompositionTrack objects displayed side by side if I trim the end or the start of the videos (so 2 different durations), I have a black frame instead of the last frame of the video when I play the final video after exporting the AVMutableVideoComposition object via a AVAssetExportSession object.

The below code show you how I insert the time range for the first video :

let start = CMTimeMakeWithSeconds(trimStart, 600)
let end  = CMTimeMakeWithSeconds(trimEnd, 600)

try videoTrack.insertTimeRange(CMTimeRangeMake(start, end), of: videoAssetTrack, at: kCMTimeZero)

Some help in order to keep the last frames displayed will be greatly appreciated

remy_jourde
  • 300
  • 1
  • 2
  • 14
  • 1
    The second argument to `CMTimeRangeMake` is supposed to be a duration, but it looks like you're using a point in time. Does changing the code to `CMTimeRangeMake(start, CMTimeSubtract(start, end))` help? – Rhythmic Fistman Apr 21 '17 at 03:40
  • It works ! I just needed to switch the `start` and the `end` parameters in `CMTimeRangeMake(start, CMTimeSubtract(end, start))`. Thank you very much @RhythmicFistman – remy_jourde Apr 21 '17 at 07:49
  • Oh cool, I'll turn it into an answer. – Rhythmic Fistman Apr 21 '17 at 07:52

1 Answers1

0

The second argument to CMTimeRangeMake is supposed to be a duration, but it looks like you're using a point in time. Does changing the code to CMTimeRangeMake(start, CMTimeSubtract(start, end)) help?

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159