简体   繁体   中英

Rotate Video after picked from UIImagePickerController to upload to server

So I've seen these answers and many others:

How to detect (iPhone SDK) if a video file was recorded in portrait orientation, or landscape.

How do I rotate a video from UIImagePickerController before uploading to a webserver

I understand how to get the orientation of the video from the UIImagePickerController but How do I actually rotate the video url that the Image Picker returns so when I upload it its not rotated 90 degrees?

EDIT:

I'm using this method to get the orientation of the video. After I get the videos orientation how do I actually rotate it to that returned orientation?

- (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset
{
AVAssetTrack *videoTrack = [[asset      tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
CGSize size = [videoTrack naturalSize];
CGAffineTransform txf = [videoTrack preferredTransform];

if (size.width == txf.tx && size.height == txf.ty)
    return UIInterfaceOrientationLandscapeRight;
else if (txf.tx == 0 && txf.ty == 0)
    return UIInterfaceOrientationLandscapeLeft;
else if (txf.tx == 0 && txf.ty == size.width)
    return UIInterfaceOrientationPortraitUpsideDown;
else
    return UIInterfaceOrientationPortrait;
}
- (UIImageOrientation)getImageOrientationWithVideoOrientation:(UIInterfaceOrientation)videoOrientation {
UIImageOrientation imageOrientation;
switch (videoOrientation) {
    case UIInterfaceOrientationLandscapeLeft:
        imageOrientation = UIImageOrientationUp;
        break;
    case UIInterfaceOrientationLandscapeRight:
        imageOrientation = UIImageOrientationDown;
        break;
    case UIInterfaceOrientationPortrait:
        imageOrientation = UIImageOrientationRight;
        break;
    case UIInterfaceOrientationPortraitUpsideDown:
        imageOrientation = UIImageOrientationLeft;
        break;
}
return imageOrientation;
}

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