Created
August 14, 2014 14:02
-
-
Save Air-Craft/0e7d037e169247d0020d to your computer and use it in GitHub Desktop.
Grab a snapshot from a video file i#iOS #video #images #snapshot #AVFoundation #intermediate
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
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:self.recordedVideoFileURL options:nil]; | |
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset]; | |
gen.appliesPreferredTrackTransform = YES; | |
NSError *err = NULL; | |
CMTime cmTime = CMTimeMake(time, 1); | |
CGImageRef imgRef = [gen copyCGImageAtTime:cmTime actualTime:NULL error:&err]; | |
UIImage *img = [[UIImage alloc] initWithCGImage:imgRef]; | |
return img; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment