如何在iphone中的UIImagePickerController中捕获视频的缩略图

时间:2013-11-27 03:56:46

标签: ios iphone uiimagepickercontroller

我正在捕捉视频的thumnail它工作正常,但问题是它在水平模式下捕捉缩略图但我想在垂直模式下任何想法如何解决这个问题。

这是缩略图的代码。

    AVAsset *asset = [AVAsset assetWithURL:movieURL];// url= give your url video here
    AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
    CMTime time = CMTimeMake(1, 5);//it will create the thumbnail after the 5 sec of video 
    CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:NULL];
    UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
    thumbnailImageView.image=thumbnail;

1 个答案:

答案 0 :(得分:0)

使用以下代码获取旋转图像,并使用最终图像

UIGraphicsBeginImageContext(thumbnail.size);//thumbnail is your original image
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextRotateCTM (context, radians(90));//set rotation as per your requirement
[thumbnail drawAtPoint:CGPointMake(0, 0)];
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();//image after rotation