WebRTC video constraints not working

北战南征 提交于 2019-12-11 22:58:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!