博客> iOS获取视频截图
iOS获取视频截图
2017-07-23 02:55 评论:0 阅读:283 674313234a
ios
  • (void)getImageFromVedio:(NSURL )url { NSDictionary opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey]; AVURLAsset urlAsset = [AVURLAsset URLAssetWithURL:url options:opts]; AVAssetImageGenerator generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset]; generator.appliesPreferredTrackTransform = YES; // generator.maximumSize = CGSizeMake(SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT); NSError *error = nil; CGImageRef img = [generator copyCGImageAtTime:CMTimeMake(10, 10) actualTime:NULL error:&error]; if (error != nil) {

    }else{ //这里写你需要展示的地方 img就是拿到的图片 //[UIImage imageWithCGImage:img] 用这个方法转换成UIImage对象 }

}

收藏
1
sina weixin mail 回到顶部