Reputation: 701
I need to get screenshots from a video.
I'm using the following method:
- (UIImage *)screenshotFromPlayerItem:(AVPlayerItem *)player atTime:(CMTime)time
{
CMTime actualTime;
NSError *error;
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:player.asset];
CGImageRef cgIm = [generator copyCGImageAtTime:time
actualTime:&actualTime
error:&error];
UIImage *image = [UIImage imageWithCGImage:cgIm];
if (nil != error)
{
NSLog(@"Error making screenshot: %@", [error localizedDescription]);
return nil;
}
CFRelease(cgIm);
return image;
}
In iOS6 it works perfect. But if i test on a device (iPhone and an iPad) with iOS5 i get the following message: "Error making screenshot: Cannot Decode"
The video is mp4.
Any solution?
Upvotes: 2
Views: 315
Reputation: 701
I am using to many media actions (i have 4 AVPlayer) and that's why it doesn't work!
Upvotes: 2