https://webrtchac
om/video-constraints-2/
https://webrtchacks.com/how-to-figure-out-webrtc-camera-resolutions/
|
Try maxWidth/maxHeight constraints:
var video_constraints = {
mandatory: {
maxHeight: 480,
maxWidth: 640
},
optional: []
};
navigator.getUserMedia({
audio: false,
video: video_constraints
}, onsuccess);
Updated (Sep 26, 2013):
According to this page; you can set following resolutions (min/max width/height):
1920:1080
1280:720
960:720
640:360
640:480
320:240
320:180
Or Maybe:
1280:800
1280:720
960:600
960:540
640:400
640:360
640:480
480:300
480:270
480:360
320:200
320:180
320:240
240:150
240:135
240:180
160:100
160:90
160:120
|
分辨率最高的是WVGA:800×480
VGA为标准分辨率:640×480
WVGA 分辨率:800×480
WQVGA 分辨率:480×320
QVGA分辨率:320×240
D1 分辨率:720×576
CIF 分辨率: 352×288
QCIF 分辨率:176×144
Openwebrtc:
QCIF and QVGA are unusable and result in an oddly shaped black frame on the receiving end in Chrome.
CIF works and reduces the latency to 0.5 s or so initially, however latency gradually increases to several seconds and longer.
getUserMedia() constraints
As covered in the What happens when there’s missing media sources? post, getUserMedia() takes a constraints object. The object, as defined in the getUserMedia()W3C specification looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
{
mandatory
:
{
width
:
{
min
:
640
}
,
height
:
{
min
:
480
}
}
,
optional
:
[
{
width
:
650
}
,
{
width
:
{
min
:
650
}
}
,
{
frameRate
:
60
}
,
{
width
:
{
max
:
800
}
}
,
{
facingMode
:
"user"
}
]
}
|
The spec allows mandatory and optional constraints for both minimum and maximums on:
Object | What it does | Value options |
Height | Specifies the video source height | Min and Max of an integer |
Width | Specifies the video source width | Min and Max of an integer |
FrameRate | specify how many frames to send per second (usually 60 for HD, 30 for SD) | Min and Max of an integer |
aspectRatio | height divided by width – usually 4/3 (1.33333333333) or 16/9 (1.7777777778) | Min and Max of an decimal |
facingMode | Select the front/user facing camera or the rear/environment facing camera if available | Which camera to choose – currently user, environment, left, or right |
In addition to turning audio and video on/off all together, in practice minHeight, minWidth, maxHeight, and maxWidth variables are the most widely supported:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
{
"audio"
:
true
,
"video"
:
{
"mandatory"
:
{
"minWidth"
:
320
,
"maxWidth"
:
1280
,
"minHeight"
:
180
,
"maxHeight"
:
720
,
"minFrameRate"
:
30
}
,
"optional"
:
[
]
}
}
|
I have also seen reference to others that could theoretically be passed down to the libjingle media engine that powers WebRTC. These are out of scope for my camera resolution project, so I did not experiment with them.