Capture a screenshot from mov video types

Apr 23rd, 2015
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add to your ad blocker whitelist or disable your adblocking software.