1

I have an app that records videos. It will display each video in its interface, and I'd like to have a little thumbnail to represent each video. OS X shows a preview of the video, a poster frame taken some few seconds into the file. I'd like to do something similar. I've heard it called a "poster frame" but the Googles aren't helping for this one.

Can anyone point me at the appropriate API that would help me do this?

Thanks,

Aaron

Aaron Vegh
  • 5,217
  • 7
  • 48
  • 75

1 Answers1

2

The API you’re looking for is the AVAssetImageGenerator class. Create an AVAsset from your video file (using its +assetWithURL: method—note that for URLs from the filesystem you must either prepend file:// to the path or use NSURL’s +fileURLWithPath:), set up a generator with that asset once it’s done loading, and use the generator’s -copyCGImageAtTime:actualTime:error: or -generateCGImagesAsynchronouslyForTimes:completionHandler: to get the thumbnails.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
  • your post doesn't answer the question. The question is how to extract the poster frame of a video. Using AVAssetImageGenerator you can extract any frame of a video but you did not explain how to extract the poster frame that may not be the first frame, for example. – Duck Aug 22 '15 at 13:34
  • The “poster frame” as defined in the question is a frame “taken some few seconds into the file”, which is trivial to acquire with either of the APIs suggested. Is there another definition you think is missing here? – Noah Witherspoon Aug 22 '15 at 16:48