views:

192

answers:

1

Is it possible to convert a UIImage instance to a CMSampleBufferRef so that it can be appended to a specified output file using AVAssetWriter's appendSampleBuffer: method?

If so ... how?

Thanks

+2  A: 

While I haven't really tried this one possibility is to create a CVPixelBuffer using CVPixelBufferCreateWithBytes, and pointing it to the raw pixels from the UIImage.

Once this is done, since CVPixelBuffers are just CVImageBuffers you can use CMSampleBufferCreateForImageBuffer to get a CMSampleBufferRef that you can then use the appendSampleBuffer method.

As I said previously I haven't ever tried this, but it looks plausible.

Aurojit Panda
This looks good, but I got stuck on the `appendSampleBuffer:` call, see my follow-up question: http://stackoverflow.com/questions/3751664.
zoul