ios - 相册选择视频 截取第一针当缩略图
迷茫
迷茫 2017-04-18 09:57:23
0
1
675

相册选择视频 截取第一针当缩略图,并且上传

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
刘奇

This is the method I use to get screenshots:

+(UIImage *)thumbnailOfAVAsset:(AVURLAsset *)asset {
    AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    generator.appliesPreferredTrackTransform = YES;
    NSError *err = NULL;
    CMTime time = CMTimeMake(0, 2);
    CGImageRef oneRef = [generator copyCGImageAtTime:time actualTime:NULL error:&err];
    UIImage *one = [UIImage imageWithCGImage:oneRef];// [[UIImage alloc] initWithCGImage:oneRef];
    
    return one;
}

This method of obtaining screenshots is best not to be executed in the main thread.

NSURL *url = [NSURL fileURLWithPath:path];//视频地址
AVURLAsset *asset = [AVURLAsset assetWithURL:url];

UIImage *thumbnailImage = [Class thumbnailOfAVAsset:asset];
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template