IOS:在横向模式下使用avcam进行视频录制?
我的应用程序在“常规->设备方向”设置中锁定为纵向模式 我正在使用AVCam录制视频,我想同时录制横向和纵向视频 我尝试过以下方法,也尝试过其他几种方法,但都无济于事: 当设备旋转时,我已设置预览层方向并开始录制视频IOS:在横向模式下使用avcam进行视频录制?,ios,objective-c,avcapturesession,avcam,Ios,Objective C,Avcapturesession,Avcam,我的应用程序在“常规->设备方向”设置中锁定为纵向模式 我正在使用AVCam录制视频,我想同时录制横向和纵向视频 我尝试过以下方法,也尝试过其他几种方法,但都无济于事: 当设备旋转时,我已设置预览层方向并开始录制视频 [[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:(AVCaptureVideoOrientation)toInterfaceOrientation]
[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:(AVCaptureVideoOrientation)toInterfaceOrientation];
// Update the orientation on the movie file output video connection before starting recording.
[[[self movieFileOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:(AVCaptureVideoOrientation)[UIDevice currentDevice].orientation];
开始录制视频时设置当前设备方向
[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:(AVCaptureVideoOrientation)toInterfaceOrientation];
// Update the orientation on the movie file output video connection before starting recording.
[[[self movieFileOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:(AVCaptureVideoOrientation)[UIDevice currentDevice].orientation];
开始录制前,设置视频输出连接的视频方向 斯威夫特3
videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = AVCaptureVideoOrientation(rawValue: UIDevice.current.orientation.rawValue)!
试试这个