Reputation: 624
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
Upvotes: 4
Views: 1863
Reputation: 3185
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).
Upvotes: 4