IOS 获取视频图片的

获取视频图片的






+(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;


}

你可能感兴趣的:(ios,图片,uiimage)