问题
I'm trying to get a lower resolution from the webcam
navigator.getUserMedia({audio: true,
video: {
"mandatory" : {maxWidth : 320},
"optional" : []
}
}, function(stream) {
videoElement.src = URL.createObjectURL(stream);
}, function(error) {console.log(e)});
Everything works fine, but videoElement.videoWidth
is still 640. This is the same whatever video constraints I specify. This is happening only in Firefox, in Chrome everything works fine.
Does anyone know why?
I also tried specifying maxFrameRate
, but this is also ignored. I also tried without optional
and with maxHeight too.
回答1:
There are numerous bugs that are being handled in Firefox for it not supporting programable video framerate and resolution changes.
- Allowing the framerate to be changed in the media constraints
- Support runtime change of video resolution
- Support plain numbers for the video resolution in the media constraints
You are supposedly able to set the constraints this way:
mediaConstraints = {
"audio": true,
"video": {
width: {
min: 320,
max: 320
},
height: {
min: 240,
max: 240
} }
};
But I have never been able to get video resolution constraints to work it to work in Firefox through media constraints. I have had limited success with changing the default resolution in about:config
in firefox.
These issues are known and I believe that numerous people are working on them to get them resolved.
来源:https://stackoverflow.com/questions/27159479/webrtc-video-constraints-not-working