【发布时间】:2018-11-14 21:55:00
【问题描述】:
我正在使用核心 WebRTC 框架 并以 iPhone 全屏模式呈现我的本地流。不幸的是,我的视频显示被拉伸,不像相机应用程序中的视频视图那样显示。
我尝试在RTCMediaConstraints 中添加纵横比,还使用adaptOutputFormatToWidth 方法来修复输出。
NSDictionary* mandatoryConstraints;
/* want to calculate aspect ratio dynamically */
NSString *aspectRatio = [NSString stringWithFormat:@"%f",(double)4/3];
if (aspectRatio) {
mandatoryConstraints = @{ kRTCMediaConstraintsMaxAspectRatio:
aspectRatio};
}
RTCMediaConstraints *cameraConstraints = [RTCMediaConstraints alloc];
cameraConstraints = [cameraConstraints initWithMandatoryConstraints:mandatoryConstraints optionalConstraints:nil];
RTCAVFoundationVideoSource *localVideoSource = [peerFactory avFoundationVideoSourceWithConstraints:mediaConstraint];
[localVideoSource adaptOutputFormatToWidth:devicewidth:devicewidth fps:30];
在下面的链接中,显示了相机视频视图和我的应用调用视频视图之间的区别
https://drive.google.com/file/d/1HN3KQcJphtC3VzJjlI4Hm-D3u2E6qmdQ/view?usp=sharing
【问题讨论】: