iOS AVVideoCompositionCoreAnimationTool:如何使用videoCompositionCoreAnimationToolWithAdditionalLayer

问题描述 投票:0回答:1

我正在努力寻找有关如何使用

videoCompositionCoreAnimationToolWithAdditionalLayer
的任何文档。我一直在使用
videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer
,但它不支持 HDR 视频。

如果有人可以提供一个例子,将不胜感激。

ios avfoundation avassetexportsession
1个回答
0
投票

除了animationTool还需要添加图层指令

CMPersistentTrackID trackId = [asset unusedTrackID];

AVMutableVideoCompositionLayerInstruction* effectlayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstruction];
[effectlayerInstruction setTrackID: trackId];
[effectlayerInstruction setOpacity:1.0 atTime:kCMTimeZero];

videoInstruction.layerInstructions = @[effectlayerInstruction, videolayerInstruction]; //effectlayerInstruction should be first to not overlap by the video, make layer with bgColor clear

/// animationTool:
composition.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithAdditionalLayer:layer asTrackID: trackId]; //trackId should be the same
© www.soinside.com 2019 - 2024. All rights reserved.