如何在iOS上使用AVMutableComposition和CALayers [英] How to use AVMutableComposition and CALayers on iOS

查看:90
本文介绍了如何在iOS上使用AVMutableComposition和CALayers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用AV可变合成在iOS的视图中呈现内容。我想将来自一台iPhone摄像机的视频与在一个图层中创建的内容结合在一起-可变的组合似乎很合适,因为它可以将图层合成到视频内容中。

I'm planning to render content in a view on iOS using AV mutable composition. I want to combine the video coming from one of the iPhone cameras with content created in a layer - mutable composition seems to fit the bill here as it can composite layers into the video content.

在录制视频时完成合成并不重要-我也很高兴将所需的数据混合到一个合成中,然后在完成初始视频录制后(通过AVExportSession)将其渲染到文件中。

It's not critical that the compositing be done as video is being recorded - I'm also happy to mix the required data into a composition that is then rendered (via AVExportSession) to a file after initial video recording has been completed.

我不明白的是,在AV的背景下,[ca]层应该如何在合成的给定时间知道要绘制什么

What I don't get though is how a [ca]layer is supposed to know what to draw at a given time during the composition, in the context of the AV framework.

我的图层内容取决于时间线,时间线描述了需要在图层中绘制的内容。因此,如果我在可变组合物中嵌入一个图层,然后通过AVExportSession导出该组合,那么CALayer实例将如何知道其应在何时生成内容?

My layer content is dependent on a timeline, the timeline describes what needs to be drawn within the layer. So if I embed a layer into the mutable composition and then export that composition via AVExportSession - how will the CALayer instance know what time its supposed to produce content for?

推荐答案

我也遇到了类似的情况。我建议您检查一下WWDC 2010 AVEditDemo应用程序源。那里有一个示例代码完全可以满足您的需要-将CALayer放置在视频轨道的顶部,并在其顶部制作动画。

I've had similar thing going on. I would recommend you to check around the WWDC 2010 AVEditDemo application source. There is an example code there which does exactly what you need - placing a CALayer on top of a video track and also doing an animation on top of it.

您还可以在以下位置查看我在该主题上的工作:在使用AVVideoCompositionCoreAnimationTool的CALayer

You can also check my efforts on the subject at: Mix video with static image in CALayer using AVVideoCompositionCoreAnimationTool

这篇关于如何在iOS上使用AVMutableComposition和CALayers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆