IOS : Video recording using avcam in landscape mode?

1.1k views Asked by At

My app is locked to portrait mode in the General -> Device orientation setting.

I'm using AVCam to record the videos and i would like to record both in landscape and portrait video.

I have tried with the below approach and also i have tried the few more approaches but that doesn't help :

When the device is rotated , i have set the preview layer orientation and start recorded the video.

[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:(AVCaptureVideoOrientation)toInterfaceOrientation];
2

There are 2 answers

0
Manoj Arun S On BEST ANSWER

Set the current device orientation while start recording the video.

// Update the orientation on the movie file output video connection before starting recording.

[[[self movieFileOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:(AVCaptureVideoOrientation)[UIDevice currentDevice].orientation];
0
parth On

Set video orientation of the video output connection before starting recording.

Swift 3

videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = AVCaptureVideoOrientation(rawValue: UIDevice.current.orientation.rawValue)!