从视频文件URL捕获图像

时间:2014-01-15 06:36:22

标签: image url video take

- (void)captureImageFromUrlPath:(NSString *)urlStr {

// Import this from for these classes #import <AVFoundation/AVFoundation.h>
AVURLAsset* asset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:urlStr] options:nil];
AVAssetImageGenerator* imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset];
UIImage* image = [UIImage imageWithCGImage:[imageGenerator copyCGImageAtTime:CMTimeMake(0, 1) actualTime:nil error:nil]];
UIImageView  *imageView = [[UIImageView alloc] init];
[imageView setImage:image];
[imageView setFrame:CGRectMake(0, 20, 320, 200)];
[self.view addSubview:imageView];

}

1 个答案:

答案 0 :(得分:0)

这是从视频文件Url中捕获图像的最佳方式。