Adrian Ber
Adrian Ber

Reputation: 21380

WebRTC video constraints not working

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.

Upvotes: 0

Views: 4250

Answers (1)

Benjamin Trent
Benjamin Trent

Reputation: 7566

There are numerous bugs that are being handled in Firefox for it not supporting programable video framerate and resolution changes.

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.

Upvotes: 2

Related Questions