CameraEngine icon indicating copy to clipboard operation
CameraEngine copied to clipboard

After saving the video the orientation is changed to landscape

Open vkhattar opened this issue 9 years ago • 6 comments

I am recording a video in portrait mode and for some reason I am getting the video in landscape mode when I view it.

vkhattar avatar May 24 '16 15:05 vkhattar

let me check that. I recently added some features about the rotation.

remirobert avatar May 24 '16 16:05 remirobert

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.

vkhattar avatar May 25 '16 13:05 vkhattar

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 avatar Jun 08 '16 15:06 ferama

@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.

otymartin avatar Aug 18 '16 05:08 otymartin

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
        }
    }
}

otymartin avatar Aug 19 '16 19:08 otymartin

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
        }
    }
}

roceller avatar Apr 11 '17 07:04 roceller