0

I'm accessing the webcam with this code:

getUserMedia( { 'video': true }, success, failure );

Now I'd like to get the highest resolution possible, up to a limit of 720 vertical pixels, so I change it to this:

getUserMedia( { 'video': {
    'optional': [
        { 'height': { 'max': 720 } },
        { 'maxHeight': 720 }
    ]
} }, success, failure );

But it does nothing. I still get a video which is 480 pixels high.

Weirdly, if I change it to use min instead of max, it sort-of works in Chrome (it chooses the highest resolution available, with no limit). Adding a max makes it fail again. None of these seem to work in FireFox.

I realise constraints are still not really standard, but is there any way with the current state of things to reliably do this?

Update: turns out FireFox only supports 640x480, so this question will have to be Chrome-only for now.

Dave
  • 44,275
  • 12
  • 65
  • 105
  • Probably because max resolution is the maximum resolution you want while min res is the minimum you want. – Pablo Jomer Aug 05 '14 at 08:33
  • @PabloKarlsson well, yes, so setting a max of 720 would, logically, choose 720 if it's possible, but never allow anything higher. But it seems it doesn't, or at least didn't when I was testing this. I haven't tested lately but I think this may have been fixed in a more recent release of Chrome. – Dave Aug 05 '14 at 10:36
  • I think it could chose nothing that was larger than 720px. That what max means it says nothing about the lower bound. Just how large it can maximally be. – Pablo Jomer Aug 05 '14 at 11:03
  • I found this link http://webrtchacks.com/how-to-figure-out-webrtc-camera-resolutions/ explains a bit more. – Pablo Jomer Aug 05 '14 at 11:04
  • **Update:** Firefox is ahead of Chrome here now, and supports the spec, so this is a piece of cake: `{ video: { width: 9999, height: 9999 } }` will give you the highest possible resolution. See [this related answer](http://stackoverflow.com/questions/28282385/webrtc-firefox-constraints/28911694#28911694). – jib Jul 07 '15 at 01:38

0 Answers0