获取缩略图方法一:
导入
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
MPMoviePlayerController *player = [[MPMoviePlayerControlleralloc]initWithContentURL:url];
UIImage *thumbnail = [playerthumbnailImageAtTime:1.0timeOption:MPMovieTimeOptionNearestKeyFrame];
[playerstop];
#import <AssetsLibrary/ALAssetsLibrary.h>
+ (UIImage *)getVideoThumbnailImage:(NSURL *)videoURL {
AVURLAsset *asset = [[AVURLAssetalloc]initWithURL:videoURLoptions:nil];
AVAssetImageGenerator *gen = [[AVAssetImageGeneratoralloc]initWithAsset:asset];
gen.appliesPreferredTrackTransform =YES;
CMTime time =CMTimeMakeWithSeconds(0.0,600);
NSError *error =nil;
CMTime actualTime;
CGImageRef image = [gencopyCGImageAtTime:time actualTime:&actualTimeerror:&error];
UIImage *thumb = [[UIImagealloc]initWithCGImage:image];
CGImageRelease(image);
return thumb;
}
NSData *data = [NSDatadataWithContentsOfURL:videoURL];