I cannot figure out how to handle the video capture orientation on the front panel. I have all the turns that are processed for the rear camera when capturing video and images and all the turns that are processed for the front camera when shooting, as well as for saving captured videos and images with the correct orientation, except for capturing video from the front camera.
The first problem is that in landscape mode the video is not saved correctly with the correct orientation. The second problem is that the saved video is mirrored. Although I know how to handle this mirroring effect for an image using the front camera, I'm not sure what to call to process it for video.
I had a lot of problems trying to find something specifically for this one problem and could not do it. If anyone can point me to a thread that addresses this particular issue, that would be great.
In any case, a method is called here that processes the orientation of the video when the orientation of the device changes. I'm not sure exactly what to add to my code if using the front camera.
func deviceOrientationDidChange() {
println("DEVICE ORIENTATION DID CHANGE CALLED")
let orientation: UIDeviceOrientation = UIDevice.currentDevice().orientation
if orientation == UIDeviceOrientation.FaceUp || orientation == UIDeviceOrientation.FaceDown || orientation == UIDeviceOrientation.Unknown || orientation == UIDeviceOrientation.PortraitUpsideDown || self.currentOrientation == orientation {
println("device orientation does not need to change --- returning...")
return
}
self.currentOrientation = orientation
switch orientation {
case UIDeviceOrientation.Portrait:
rotateButtons(self.degrees0)
if self.usingFrontCamera == true {
}
else {
}
println("Device Orientation Portrait")
break
case UIDeviceOrientation.LandscapeLeft:
println("Device Orientation LandScapeLeft")
rotateButtons(self.degrees90)
if self.usingFrontCamera == true {
println("Using front camera, rotation in landscape left")
}
else {
if let connection = self.captureConnection {
connection.videoOrientation = AVCaptureVideoOrientation.LandscapeRight
println("Capture connection Orientation is LandScape Right")
}
else {
println("Capture connection is nil, could not change video orientation")
}
}
break
case UIDeviceOrientation.LandscapeRight:
println("Device Orientation LandscapeRight")
rotateButtons(-self.degrees90)
if self.usingFrontCamera == true {
println("Using front camera, rotation in landscape right")
}
else {
if let connection = self.captureConnection {
connection.videoOrientation = AVCaptureVideoOrientation.LandscapeLeft
println("Capture connection Orientation is LandScape Left")
}
else {
println("Capture connection is nil, could not change video orientation")
}
}
break
default:
break
}
}
source
share