Capture a screenshot from mov video types

priore Apr 23rd, 2015 631 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <AVFoundation/AVFoundation.h>
  3. AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:self];
  4. CMTime duration = self.duration;
  5. CGFloat durationInSeconds = duration.value / duration.timescale;
  6. CMTime time = CMTimeMakeWithSeconds(durationInSeconds * 0.5, (int)duration.value);
  7. CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:NULL];
  8. UIImage *screenshot = [UIImage imageWithCGImage:imageRef];
  9. CGImageRelease(imageRef);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand