AVCaptureSession rotate | orientation while video transmitting

前端 未结 1 1635
猫巷女王i
猫巷女王i 2021-02-10 15:31

I am developing video streaming application, in which i need to capture front camera video frame and encode then transfer to other end, a typical flow is like this

AVCa

1条回答
  •  既然无缘
    2021-02-10 16:08

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

    0 讨论(0)
提交回复
热议问题