在我的应用程序中,我使用 AVCapture/AssetsLibrary 录制和保存视频。当我纵向录制时,录制视频的方向没问题,但当我横向录制时,录制视频的方向是 90 度,这很糟糕。我需要请帮忙解决这个问题。 我的代码是..
在我的 appDelegate.m 中
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
NSUInteger orientations = UIInterfaceOrientationMaskAllButUpsideDown;
if(self.window.rootViewController){
UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
orientations = [presentedViewController supportedInterfaceOrientations];
}
return orientations;
}
在 myViewController.m 中
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
捕获 session 方向
AVCaptureConnection *CaptureConnection = [MovieFileOutput connectionWithMediaType:AVMediaTypeVideo];
if ([CaptureConnection isVideoOrientationSupported])
{
AVCaptureVideoOrientation orientation = AVCaptureVideoOrientationPortrait;
[CaptureConnection setVideoOrientation:orientation];
}
谢谢,
最佳答案
设置 CaptureVideoOrientation.i.e:
AVCaptureVideoOrientation orientation =AVCaptureVideoOrientationLandscapeRight
关于iphone - 录制的视频方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17694113/