我正在开发一个应用程序,它使用AVMutableVideoComposition和AVVideoCompositionCoreAnimationTool (通过AVExportSession导出)在2-10秒的视频中导出AVMutableVideoComposition动画。
在每个构图中可以有数百个CAShapeLayers,每个构图上都会有动画。
let animationLayer = CALayer()
animationLayer.frame = CGRectMake(0, 0, size.width, size.height)
animationLayer.geometryFlipped = true
// Add a ton of CAShapeLayers with CABasicAnimation's to animation Layer
let parentLayer = CALayer()
let videoLayer = CALayer()
parentLayer.frame = CGRectMake(0, 0, size.width, size.height)
videoLayer.frame = CGRectMake(0, 0, size.width, size.height)
parentLayer.addSublayer(videoLayer)
parentLayer.addSublayer(animationLayer)
mainCompositionInst.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, inLayer: parentLayer)
let exporter = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetHighestQuality)
exportSession.outputURL = finalUrl
exportSession.outputFileType = AVFileTypeQuickTimeMovie
exportSession.shouldOptimizeForNetworkUse = true
exportSession.videoComposition = mainCompositionInst
exportSession.exportAsynchronouslyWithCompletionHandler(...)现在,这完全可行。但是,当动画数量众多时,组合输出可能非常缓慢(15-25秒可导出)。我对加快出口业绩的任何想法都感兴趣。
到目前为止,我的一个想法是进行多个组合/导出传递,并在每次传递中添加一个“合理”的动画层数。但我有种感觉只会让它变慢。
或者,可能会导出大量较小的视频,每个视频都包含“合理”数量的动画层,然后在最终导出中将它们组合在一起。
还有其他的想法吗?,慢只是生活中的一个事实吗?我很感激你的洞察力!我是AVFoundation的新手。
发布于 2015-11-12 00:29:57
https://stackoverflow.com/questions/33631538
复制相似问题