我正在AVMutableCompositionTrack中将视频拼接在一起,使用:
AVMutableVideoCompositionLayerInstruction *passThroughLayer = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];
我还使用animationLayer将一个带有文字和图像的CALayer添加到合成中。
开始时,我使用insertEmptyTimeRange添加5秒无法插入标题。
到目前为止,一切正常。
现在我想在视频的末尾添加一些“没有”,再次使用insertEmptyTimeRange - 但这种情况很糟糕。
CMTime creditsDuration = CMTimeMakeWithSeconds(5, 600);
CMTimeRange creditsRange = CMTimeRangeMake([[compositionVideoTrack asset] duration], creditsDuration);
[compositionVideoTrack insertEmptyTimeRange:creditsRange];
[compositionAudioTrack insertEmptyTimeRange:creditsRange];
NSLog(@"credit-range %f from %f", CMTimeGetSeconds(creditsRange.duration), CMTimeGetSeconds(creditsRange.start));
NSLog(@"Total duration %f", CMTimeGetSeconds([[compositionVideoTrack asset] duration]));
插入点是正确的(第一个NSLog),但总持续时间不会延长......
任何想法我可能做错了什么?
答案 0 :(得分:0)
事实证明,似乎不可能在AVMutableComposition的末尾添加一个空的时间范围。
这个答案挽救了我的生命:AVMutableComposition of a Solid Color with No AVAsset