简体   繁体   中英

how to capture the thumnail of the video in UIImagePickerController in iphone

I am capturing the thumnail of video it work fine but problem is that it capture the thumbnail in horizontal mode but i want in vertical mode any idea how to fix this issue.

here is the code for thumbnail.

    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;

Get rotated image using following code, and use final image

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM