Skip to content

Instantly share code, notes, and snippets.

@doluvor
Created October 18, 2016 03:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doluvor/dd0793d05738c583e46e54bcfbff27a6 to your computer and use it in GitHub Desktop.
Save doluvor/dd0793d05738c583e46e54bcfbff27a6 to your computer and use it in GitHub Desktop.
Generate thumbnail of video
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