Need to Mirror Video Orientation and Handle Rotation When Using Front Camera

Based on this answer: Video Saving in the wrong orientation AVCaptureSession

I faced the same issue and was able to fix it following this post.

var videoConnection:AVCaptureConnection?
  for connection in self.fileOutput.connections {
    for port in connection.inputPorts! {
      if port.mediaType == AVMediaTypeVideo {
        videoConnection = connection as? AVCaptureConnection
          if videoConnection!.supportsVideoMirroring {
            videoConnection!.videoMirrored = true
          }
        }
      }
   }
}

Please let me know if it helps you James

Tags:

Ios

Swift