ios 获取视频中的某一帧图片

/**

 获取视频的 某一帧

 @paramcurrentTime 某一时刻单位 s

 @parampath 视频路径

 @returnreturn 返回image

 */

+ (UIImage*)getVideoImageWithTime:(Float64)currentTime videoPath:(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;

    CMTimeactualTime;

    CGImageRefimage = [assetGencopyCGImageAtTime:timeactualTime:&actualTimeerror:&error];

    UIImage *videoImage = [[UIImage alloc] initWithCGImage:image];

    CGImageRelease(image);

    returnvideoImage;

}

你可能感兴趣的:(ios 获取视频中的某一帧图片)