Created
December 7, 2012 13:40
-
-
Save zapsleep/4233335 to your computer and use it in GitHub Desktop.
Getting a screenshot with AVAssetImageGenerator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)screenshotFromFileURL:(NSURL *)url { | |
AVPlayerItem *item = [AVPlayerItem playerItemWithURL:url]; | |
AVURLAsset *asset = (AVURLAsset *)item.asset; | |
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] | |
initWithAsset:asset]; | |
CGImageRef thumb = [imageGenerator | |
copyCGImageAtTime:CMTimeMakeWithSeconds(10.0, 1.0) | |
actualTime:NULL | |
error:NULL]; | |
UIImage *image = [UIImage imageWithCGImage:thumb]; | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment