2013-01-05 62 views
2

所以,我已經看到了這些問題的答案和許多其他:旋轉視頻從採摘的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; 
} 
+0

你找到一個答案? – TMan

回答

0
- (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; 
} 
相關問題