开发者

How to append a UIImage or CGImage to an AVAssetWriter?

开发者 https://www.devze.com 2023-01-16 09:46 出处:网络
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?

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消