1

Reading this article I see that is possible to see the capabilities of input devices. Unfortunately I cant access this.

var video = document.querySelector('video');
var constraints = window.constraints = {
  audio: true,
  video: true
};
var errorElement = document.querySelector('#errorMsg');

navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
  var videoTracks = stream.getVideoTracks();
  //console.log('Got stream with constraints:', constraints);
  console.log('Using video device: ' + videoTracks[0].label);
  var audioTracks = stream.getAudioTracks();
  audioTracks.getCapabilities();//xxxx

//...

So, can I assume that is not implemented?

carduh
  • 529
  • 1
  • 4
  • 13

1 Answers1

1

It is not implemented yet in Chrome and Firefox.

While the specification allows browsers to downscale (Chrome does, Firefox does not), they are not allowed to upscale, so finding the device's highest native resolution is easy with getUserMedia, just request a very high resolution using constraints. The resolution returned will be the max the device can handle.

If you have multiple cameras, it will select the one with the highest resolution, or if you don't want that use the deviceId constraint to prevent it.

Community
  • 1
  • 1
jib
  • 40,579
  • 17
  • 100
  • 158
  • so, is there no way then to determine what the native resolution of the device is to capture video/images at that size? – Michael Mar 29 '16 at 03:35
  • You can request it with constraints. I've updated the answer. – jib Mar 29 '16 at 05:49
  • hmm, odd... in Chrome if i request too high a value it refuses and if i request too low a value it gives me that. overall it appears this is a very immature, inconsistently implemented feature. thanks for the update though. – Michael Mar 29 '16 at 05:55
  • @Michael it's a limitation in the [adapter.js](https://github.com/webrtc/adapter) polyfill for Chrome, since Chrome does not yet implement the fitness-distance algorithm natively. Adapter.js has to simulate the basic idea using older "advanced" constraints which aren't as expressive (no gravity), so it's limited to working with the most common values for width and height. It could be improved, but it was always intended to be a temporary measure. This should improve once Chrome's updated implementation lands. Firefox does not have this problem FWIW. – jib Mar 29 '16 at 06:09