将 CoreAnimation 导出到视频文件

发布于 2024-12-17 20:32:21 字数 579 浏览 3 评论 0原文

我在 iPhone 上使用 Core Animation 编写了一个基本的动画框架。它具有暂停和恢复动画的功能,还可以在指定时间运行动画。我的基本问题是我找不到将动画导出到视频文件(.mov、.avi 等)的方法。我已阅读有关 AVAssetWriterAVComposition 的内容,但无法理解如何使它们在我的情况下工作。

通过在互联网上搜索,我能够得到的最接近的是通过逐帧阅读我的动画。即使对于它,我也找不到一种方法让它工作,也找不到 iPhone SDK 是否有办法在我的情况下实现这种逐帧读取。我也接近了这个stackoverflow上的问题,但仍然可以不明白(抱歉,如果我觉得我是这些事情的初学者,但我不是,只是无法理解一些事情)

如果有人知道如何使其工作,甚至如何做类似的事情,请分享。如果没有办法,那么如果您知道任何其他方法,即使用 OpenGL ES 而不是 CoreAnimation,也请分享。

I wrote a basic animation framework using Core Animation on iPhone. It has the functionality for pause and resume of animations and also can run animations at specified time. My basic problem is that I cannot find a way to export my animations to a video file (.mov, .avi etc). I have read about AVAssetWriter and AVComposition but cannot understand how to make them work in my case.

By searching the internet the closest I was able to get was it by doing frame by frame reading of my animations. Even for it I could not find a way to make it work and could not find that whether iPhone SDK have something to do that for this kind of frame by frame reading in my case. I also came close to this question on stackoverflow and still could not figure out (sorry if I feel that I am beginner in those things, but I am not, just could not understand some things)

If anyone know how to make it work or even how to something similar to it please share. And if there is no way then if you know any other way to do i.e using OpenGL ES instead of CoreAnimation please share it too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白色秋天 2024-12-24 20:32:21

检查此演示文稿:http://www.slideshare.net/无效名称/advanced-media-manipulation-with-av-foundation
在第 84 页左右,他谈到了向视频作品添加动画。我相信这会帮助您获得您需要的东西。

<块引用>

编辑:具体来说,您需要查看视频合成的动画工具。这是一个 AVVideoCompositionCoreAnimationTool 对象,允许您向输出视频添加核心动画层。另请参阅这个问题:
在 iPhone 上录制自定义叠加层
很抱歉,我没有时间为您提供完整的代码片段,但基本上您可以设置视频合成的动画工具,然后创建一个 AVAssetExportSession 并将其 videoComposition 设置为您制作的视频合成。

Check this presentation: http://www.slideshare.net/invalidname/advanced-media-manipulation-with-av-foundation
Around page 84 he talks about adding animation to video compositions. I believe this will help you get what you need.

EDIT: Specifically you need to look at the animationTool of your video composition. This is a AVVideoCompositionCoreAnimationTool object that allows you to add a core animation layer to your output video. See also this question:
Recording custom overlay on iPhone
I am sorry I do not have the time to get you a full code snippet, but basically you set this animation tool of your video composition, and then create an AVAssetExportSession and set its videoComposition to the one you made.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文