标签:
+ (UIImage *)getFirstFrameOfVideoWithVideoURL:(NSURL *)videoURL { AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil]; NSParameterAssert(asset); AVAssetImageGenerator *assetIG = [[AVAssetImageGenerator alloc] initWithAsset:asset]; assetIG.appliesPreferredTrackTransform = YES; assetIG.apertureMode = AVAssetImageGeneratorApertureModeEncodedPixels; CGImageRef thumbnailImageRef = NULL; CFTimeInterval thumbnailImageTime = 60; NSError *igError = nil; thumbnailImageRef = [assetIG copyCGImageAtTime:CMTimeMake(thumbnailImageTime, 60) actualTime:NULL error:&igError]; if (!thumbnailImageRef) NSLog(@"thumbnailImageGenerationError %@", igError ); UIImage *thumbnailImage = thumbnailImageRef ? [[UIImage alloc] initWithCGImage:thumbnailImageRef] : nil; return thumbnailImage; }
标签:
原文地址:http://www.cnblogs.com/songxing10000/p/4706033.html