3

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?

Andy Hin
  • 30,345
  • 42
  • 99
  • 142

1 Answers1

1

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.

Community
  • 1
  • 1
Jan Cássio
  • 2,076
  • 29
  • 41
  • Thanks for the answer. Does this mean I will need to write my own custom player to handle the timing of each frame, etc? I will want the video frames to loop over and over again. – Andy Hin May 10 '15 at 03:13
  • Yes, if you only need to loop through frames, is simple enough to implement by hand :) Have a nice code. – Jan Cássio May 10 '15 at 03:26