我创建了一个自定义的AVVideoComposition类,并使用它:
AVAsset *asset = ...
AVMutableVideoComposition *videoComposition = [AVMutableVideoComposition videoCompositionWithPropertiesOfAsset:asset];
videoComposition.customVideoCompositorClass = [MyCustomCompositor class];
MyCustomInstruction *instruction = // custom instruction holding CIFilter that is applied to every video frame
videoComposition.instructions = @[instruction];
导出会话后使用如下:
AVAssetExportSession *session = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
session.outputURL = ...
session.outputFileType = AVFileTypeQuickTimeMovie;
session.videoComposition = videoComposition;
[session exportAsynchronouslyWithCompletionHandler:^{
...
}];
根据documentation,如果我使用AVVideoComposition
,则曲目的preferredTransform
将无效。另外,使用自定义AVVideoCompostion
指令,我无法使用 setTransform:atTime:设置AVMutableVideoCompositionLayerInstruction
。
如何以正确的方向获取视频?