Created
May 4, 2014 06:12
-
-
Save nonstriater/222014229a113c2c2df8 to your computer and use it in GitHub Desktop.
从视频文件中获得一张图片(截图)
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:url options:nil]; | |
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset]; | |
gen.appliesPreferredTrackTransform = YES; | |
CMTime time = CMTimeMakeWithSeconds(0.0, 600); | |
NSError *error = nil; | |
CMTime actualTime; | |
CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error]; | |
UIImage *img = [[UIImage alloc] initWithCGImage:image]; | |
CGImageRelease(image); | |
[self performSelector:@selector(saveImg:) withObject:img afterDelay:0.1]; | |
[img release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment