旋转视频从采摘的UIImagePickerController后上传到服务器
问题描述:
所以,我已经看到了这些问题的答案和许多其他:旋转视频从采摘的UIImagePickerController后上传到服务器
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
我知道如何让从视频的方向UIImagePickerController但我怎么实际上旋转图像选取器返回的视频网址,所以当我上传它没有旋转90度?
编辑:
我正在使用此方法来获取视频的方向。在我获得视频方向后,我如何将其旋转到返回的方向?
- (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;
}
你找到一个答案? – TMan