Reputation: 31973
I am working on an OSX video editing app and have a set of CMSampleBufferRef's in an array representing each frame of the video.
I want to render a preview of the video using AVPlayer - is it possible feed in these samples directly into AVPlayer?
I've looked at most of the AVFoundation classes. I know I can use AVAssetWriter to write to a file, but want to avoid this as the user will still be doing more editing (so good to have the raw frame data).
Any thoughts?
Upvotes: 3
Views: 2321
Reputation: 2299
Yes you can.
First of all, you should convert CMSampleBufferRef
to CGImageRef
, this will allow you to display frame samples in screen.
This answer has the all necessary code to make this.
About to play with AVPlayer
, I'm not sure if you really need to do this, since you have full access through your CMSampleBufferRef
array and you are able to convert and render those samples properly, I think is not necessary to put those samples at AVPlayer
, instead, you can render directly CGImage
at CALayer
.
I hope this can help you.
Upvotes: 1