获取视频的第一帧

it2022-05-09  17

1 +(UIImage *)getImage:(NSString *)videoURL 2 { 3 //视频地址 4 NSURL *url = [[NSURL alloc] initWithString:videoURL];//initFileURLWithPath:videoURL] autorelease]; 5 6 AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:url options:nil];// 7 //获取视频时长,单位:秒 8 NSLog(@"%llu",urlAsset.duration.value/urlAsset.duration.timescale); 9 10 AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset]; 11 12 generator.appliesPreferredTrackTransform = YES; 13 generator.maximumSize = CGSizeMake(1136, 640); 14 15 NSError *error = nil; 16 CGImageRef img = [generator copyCGImageAtTime:CMTimeMake(0, 1) actualTime:NULL error:&error]; 17 UIImage *image = [UIImage imageWithCGImage: img]; 18 return image; 19 }

 

转载于:https://www.cnblogs.com/KingQiangzi/p/3214568.html

相关资源:QtAV 基于Qt和FFmpeg的跨平台高性能音视频播放框架

最新回复(0)