iOS - 视频截图

- (UIImage *)screenshot {
    AVAssetImageGenerator *imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:self.urlAsset];
    NSError *error = nil;
    CMTime actucalTime;
    CGImageRef cgImage = [imageGenerator copyCGImageAtTime:self.player.currentTime actualTime:&actucalTime error:&error];
    if ( error ) { NSLog(@"截取视频图片失败:%@", error.localizedDescription); return nil;}
    CMTimeShow(actucalTime);
    UIImage *image = [UIImage imageWithCGImage:cgImage];
    CGImageRelease(cgImage);
    return image;
}

你可能感兴趣的:(iOS - 视频截图)