(IOS)获取一个视频的第一帧图片

NSURL*url = [NSURL URLWithString:filepath];

AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:url options:nil];

AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];

generate1.appliesPreferredTrackTransform =YES;

NSError*err =NULL;

CMTimetime = CMTimeMake(1,2);

CGImageRefoneRef = [generate1 copyCGImageAtTime:time actualTime:NULLerror:&err];

UIImage *one = [[UIImage alloc] initWithCGImage:oneRef];

return one;

你可能感兴趣的:((IOS)获取一个视频的第一帧图片)