视频播放-

播放库

clplayer

截取图片翻转问题

NSURL *url = [[NSURL alloc] initWithString:dic[@"oss"]];
            AVURLAsset *urlAsset = [[AVURLAsset alloc] initWithURL:url options:nil];
            AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:urlAsset];
            imageGenerator.appliesPreferredTrackTransform = YES;    // 截图的时候调整到正确的方向
            CMTime time = CMTimeMakeWithSeconds(1.0, 30);   // 1.0为截取视频1.0秒处的图片,30为每秒30帧
            CGImageRef cgImage = [imageGenerator copyCGImageAtTime:time actualTime:nil error:nil];
            UIImage *image = [UIImage imageWithCGImage:cgImage];

获取视频缩略图

-(UIImage *)getNetImage:(NSString *)videoURL
 
{
 
 AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:videoURL] options:nil];
 
 AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
 
gen.appliesPreferredTrackTransform = YES;
 
 CMTime time = CMTimeMakeWithSeconds(0.0, 600);
 
 NSError *error = nil;
 
 CMTime actualTime;
 
 CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
 
 UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
 
 CGImageRelease(image);
 
 return thumb;
}

猜你喜欢

转载自blog.csdn.net/u011224726/article/details/108061146