IOS 获取视频图片的

来源:互联网 发布:维棠 for mac 编辑:程序博客网 时间:2024/05/18 01:24
获取视频图片的+(UIImage *)getImage:(NSString *)videoURL{    //视频地址    NSURL *url = [[NSURL alloc] initWithString:videoURL];//initFileURLWithPath:videoURL] autorelease];       AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:url options:nil];//    //获取视频时长,单位:秒    NSLog(@"%llu",urlAsset.duration.value/urlAsset.duration.timescale);    [url release];    AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset];       generator.appliesPreferredTrackTransform = YES;    generator.maximumSize = CGSizeMake(1136, 640);       NSError *error = nil;    CGImageRef img = [generator copyCGImageAtTime:CMTimeMake(10, 10) actualTime:NULL error:&error];    UIImage *image = [UIImage imageWithCGImage: img];    return image;}


原创粉丝点击