0

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.

Adrian Ber
  • 20,474
  • 12
  • 67
  • 117
  • 1
    For which browser are you experiencing this issue? – Benjamin Trent Nov 29 '14 at 18:56
  • This works on [this](https://simpl.info/getusermedia/constraints/) example, source [here](https://github.com/samdutton/simpl/blob/master/getusermedia/constraints/js/main.js). The only difference I see is that there is no `optional` defined, and that both `maxWidth` and `maxHeight` are defined. – MarijnS95 Nov 30 '14 at 18:59
  • @BenjaminTrent, indeed it seems a browser issue. It works on Chrome, but not on Firefox. I updated my question to reflect this. – Adrian Ber Dec 02 '14 at 12:05

1 Answers1

2

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.

Benjamin Trent
  • 7,378
  • 3
  • 31
  • 41
  • The way you specified the constraints, as opposed to how I did it, does it make any difference? As far as I understood from your answer, it doesn't work either way. – Adrian Ber Dec 03 '14 at 17:11
  • It is ***SUPPOSED*** to according to what I have read about the implementation in Firefox but in my experience, it does not matter. I want to give FF the benefit of the doubt in that it could very well work in certain situations, but I have not found those situations yet. – Benjamin Trent Dec 03 '14 at 17:23
  • On another note, I don't think it's good to specify both min and max for width and height because it could depend on the webcam aspect ratio. – Adrian Ber Dec 04 '14 at 08:49