Search code examples
iosobjective-cavcapturesessionavcam

IOS : Video recording using avcam in landscape mode?


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];

Solution

  • 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];