简体   繁体   English

从UIImagePickerController拾取后旋转视频以上传到服务器

[英]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. 如何检测(iPhone SDK)视频文件是以纵向还是横向录制的。

How do I rotate a video from UIImagePickerController before uploading to a webserver 在上传到Web服务器之前,如何旋转UIImagePickerController中的视频

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? 我了解如何从UIImagePickerController获取视频的方向,但是如何实际旋转图像选择器返回的视频网址,以便在上载时未旋转90度的视频网址?

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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