- (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];
}
答案 0 :(得分:0)
这是从视频文件Url中捕获图像的最佳方式。