AVCaptureSession rotate | orientation while video transmitting

北战南征 提交于 2019-12-03 16:49:26

Thanks for looking into it, basically the solution is, orientation of connection should be set, and i was playing with the preview layer, so its affecting the preview layer but not the orientation.

here goes the code snippet

-(void) orientationChanged
{
    // get the new orientation from device 
    AVCaptureVideoOrientation newOrientation = [self videoOrientationFromDeviceOrientation];

    // set the orientation of preview layer :( which will be displayed in the device )
    [previewLayer.connection setVideoOrientation:newOrientation];

    // set the orientation of the connection: which will take care of capture
    [pCaptureConnection setVideoOrientation:newOrientation];

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!