为什么在iOS上默认的webrtc视频捕获器方向是90°?



在查看RTCCameraVideoCapturer.m时,我发现:

- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection {

#if TARGET_OS_IPHONE

switch (_orientation) {
case UIDeviceOrientationPortrait:
_rotation = RTCVideoRotation_90;
break;
case UIDeviceOrientationPortraitUpsideDown:
_rotation = RTCVideoRotation_270;
break;
case UIDeviceOrientationLandscapeLeft:
_rotation = usingFrontCamera ? RTCVideoRotation_180 : RTCVideoRotation_0;
break;
case UIDeviceOrientationLandscapeRight:
_rotation = usingFrontCamera ? RTCVideoRotation_0 : RTCVideoRotation_180;
break;
}
#else
// No rotation on Mac.
_rotation = RTCVideoRotation_0;
#endif
}

为什么默认的相机捕获器的方向是90°。我做了一个简单的voip客户端,我的iPhone上的视频看起来是旋转的,即使设备是纵向的。我遗漏了什么?有没有办法旋转捕捉者的视频方向?

任何想法都感谢

检查AVCaptureConnection.videoOrientation

https://developer.apple.com/documentation/avfoundation/avcaptureconnection/1389415-videoorientation

我猜原始方向取决于相机制造商。为了给客户提供最快的速度,图像数据直接从传感器缓冲区传输。你不能旋转捕捉者的视频方向。你只能混合视频和界面方向属性来正确地呈现给用户。

最新更新