即时通讯中,需要发送视频,往往需要先显示第一帧图片
// 获取本地视频第一帧
- (UIImage*) getLocationVideoPreViewImage:(NSURL *)path
{
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:path options:nil];
AVAssetImageGenerator *assetGen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
assetGen.appliesPreferredTrackTransform = YES;
CMTime time = CMTimeMakeWithSeconds(0.0, 600);
NSError *error = nil;
CMTime actualTime;
CGImageRef image = [assetGen copyCGImageAtTime:time actualTime:&actualTime error:&error];
UIImage *videoImage = [[UIImage alloc] initWithCGImage:image];
CGImageRelease(image);
return videoImage;
}
更多详解:
喜欢可以加Q群号:913934649,点赞,评论;
简书: https://www.jianshu.com/u/88db5f15770d
网友评论