javascript 改变质量 webRTC
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24227705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change the quality webRTC
提问by Muath
This question is not asking about resolutionsand frameRates on getUserMedia()
.
这个问题不是问关于分辨率和帧率的getUserMedia()
。
It is about how to reduce/increase the quality of the one framein video when using getUSerMedia()
.
它是关于如何减少/增加质量的一个帧的使用时的视频getUSerMedia()
。
Here Demoof using getUserMedia().
这里是使用 getUserMedia() 的Demo。
How to change the Quality of the video? //Please Fiddle answer.
如何更改视频的质量? //Please Fiddle answer.
code:
代码:
var video_constraints = {mandatory: {
maxWidth: 320,
maxHeight: 240,
maxAspectRatio:4/3,
maxFrameRate:1
},
optional: [ ]
};
var constraints = {audio: true, video: video_constraints };
navigator.getUserMedia(constraints, successCallback, errorCallback);
回答by brianchirls
If not resolution or frame rate, I assume you're either talking about bit rate or camera settings (white balance, exposure, contrast, etc.).
如果不是分辨率或帧速率,我假设您要么在谈论比特率或相机设置(白平衡、曝光、对比度等)。
The video stream provided by getUserMedia
should give you uncompressed video at the highest quality available from the camera hardware. There is no way to adjust the camera settings; they are fully automatic, controlled by the camera driver and/or operating system. If you want to adjust the image, you can process it with canvas, using either a 2d or webgl context. There are multiplelibrariesavailable to help you with that.
提供的视频流getUserMedia
应该为您提供相机硬件可用的最高质量的未压缩视频。无法调整相机设置;它们是全自动的,由相机驱动程序和/或操作系统控制。如果要调整图像,可以使用 2d 或 webgl 上下文使用画布进行处理。有多个库可以帮助您解决这个问题。
As for the bit rate, this only becomes an issue when you are transmitting the video over peer connection. This is also done adaptively and automatically.
至于比特率,这只会在您通过对等连接传输视频时成为问题。这也是自适应和自动完成的。
Regardless of the quality and size of provided media streams, the network stack implements its own flow and congestion control algorithms: every connection starts by streaming audio and video at a low bitrate (<500 Kbps) and then begins to adjust the quality of the streams to match the available bandwidth.
无论提供的媒体流的质量和大小如何,网络堆栈都会实现自己的流量和拥塞控制算法:每个连接都以低比特率 (<500 Kbps) 流式传输音频和视频开始,然后开始调整流的质量以匹配可用带宽。
Source: High Performance Browser Networking
来源:高性能浏览器网络