After saving the video the orientation is changed to landscape
I am recording a video in portrait mode and for some reason I am getting the video in landscape mode when I view it.
let me check that. I recently added some features about the rotation.
I found a work around solution currently, in the cameraEngineVideoEncoder class, I am getting the orientation from status bar orientation instead of using the device orientation as I read it on a thread somewhere that it is more reliable to use the status bar information. `
var orientation : UIInterfaceOrientation
orientation = UIApplication.sharedApplication().statusBarOrientation
switch orientation {
case .Portrait: return CGFloat(M_PI / 2)
case .PortraitUpsideDown: return CGFloat(M_PI / 4)
case .LandscapeRight: return CGFloat(M_PI)
case .LandscapeLeft: return CGFloat(M_PI * 2)
default: return 0
}`
This is working fine for me.
You can still use deviceOrientation but you must invert transformations as this:
case .LandscapeRight: return CGFloat(M_PI * 2)
case .LandscapeLeft: return CGFloat(M_PI)
It seems to work for me.
@ferama @vkhattar Hey this issue persists for me whether its a saved video or previewing a just taken video. However I dont understand both your solutions or how to implement them?
@remirobert Is there a more permanent solution? It seems odd that a video being taken in portrait is being outputted in landscape.
Update. I figured your solution @vkhattar
It wasnt in the CameraEngineVideoEncoder class rather in the extension UIDevice
extension UIDevice {
static func orientationTransformation() -> CGFloat {
var orientation : UIInterfaceOrientation
orientation = UIApplication.sharedApplication().statusBarOrientation
switch orientation {
case .Portrait: return CGFloat(M_PI / 2)
case .PortraitUpsideDown: return CGFloat(M_PI / 4)
case .LandscapeRight: return CGFloat(M_PI)
case .LandscapeLeft: return CGFloat(M_PI * 2)
default: return 0
}
}
}
this should be the fix for the latest Swift syntax change once again...
extension UIDevice {
static func orientationTransformation() -> CGFloat {
switch UIApplication.shared.statusBarOrientation {
case .portrait: return (.pi / 2)
case .portraitUpsideDown: return (.pi / 4)
case .landscapeRight: return .pi
case .landscapeLeft: return (.pi * 2)
default: return 0
}
}
}