Creating a movie file of a animation with avassetwriter

北慕城南 提交于 2019-12-04 14:28:02

问题


I have a animation created using normal core animation methods. If there any way to create a movie file using avassetwriter? Ive seen other questions which show the how to use avassetwriter to create a movie using images, but i would like to create a movie using a animation created with core animation.

Thank in advance


回答1:


Run a timer (or whatever) to periodically convert the animation's CALayer to a UIImage (see here), then write that image to the AVAssetWriter as seen in the other examples you cite. You'll also need to keep track of elapsed time, because ultimately what you're trying to do is set up a call to -[AVAssetWriterPixelBufferAdapter appendPixelBuffer:atPresentationTime:].

I did a talk a few months back that did regular screen grabs and made a movie of it, called VTM_ScreenRecorder.zip. Only difference for you might be that my code is getting the window's CALayer, and you seem to be interested in some other layer (the one you're animating).



来源:https://stackoverflow.com/questions/6311184/creating-a-movie-file-of-a-animation-with-avassetwriter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!