Aaron Vegh
Aaron Vegh

Reputation: 5217

Cocoa Touch: Capturing Still Poster Frame from Video File?

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

Upvotes: 1

Views: 704

Answers (1)

Noah Witherspoon
Noah Witherspoon

Reputation: 57139

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.

Upvotes: 2

Related Questions