ios - 为什么 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
我猜原始方向取决于相机制造商。为了向客户端提供最大速度,图像数据直接从传感器缓冲区传输。您无法旋转捕获器的视频方向。您只能混合视频和界面方向属性以正确地呈现给用户。
推荐阅读
- tensorflow - 为什么我不能通过 google colab 将 TensorFlow 预测图像从谷歌地球引擎写入谷歌云存储桶?
- reactjs - ReactJS Formik 以红色显示错误消息
- python - 在 Python 中识别子字符串(沿着字符串中的索引移动) - 只能将 str(不是“int”)连接到 str
- git - Git拉和推不起作用
- vue.js - 可拖动 | 将参数传递给 :move
- cs50 - 我不断收到分段错误,我不知道为什么。我可能错误地使用 strcasecmp 函数,但我不确定
- swift - 如何在导航栏(Xcode)中将右栏按钮项放在彼此之上?
- amazon-web-services - 如何限制对 REST API 的访问以仅匹配用户的 ID?
- xamarin.forms - Xamarin Forms两个ListView垂直并排
- design-patterns - 如何在 Rust 中可变地使用堆栈上多个实例中的一个实例?