Created
October 18, 2016 03:34
-
-
Save doluvor/dd0793d05738c583e46e54bcfbff27a6 to your computer and use it in GitHub Desktop.
Generate thumbnail of video
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
AVAsset *asset = [AVAsset assetWithURL:url]; | |
CMTime duration = [asset duration]; | |
CMTime snapshot = CMTimeMake(duration.value * progress, duration.timescale); | |
AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset]; | |
CGImageRef imageRef = [generator copyCGImageAtTime:snapshot actualTime:nil error:nil]; | |
UIImage *thumbnail = [UIImage imageWithCGImage:imageRef]; | |
CGImageRelease(imageRef); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment