← View all posts
February 27, 2017

Fiddle-of-the-week: Downscale video in RTCPeerConnection

Contributed by Jan-Ivar Bruaroey,

More of last year’s new laptop cameras have few or no low-resolution modes. These reveal a big difference in how Chrome and Firefox implement the getUserMedia camera API. Whereas Chrome re-scales video to whatever constraints you put in, Firefox does not, instead guaranteeing the closest native resolution. Both are technically within spec. That said, the elaborate constraints language offered by getUserMedia, with minmax ranges and ideal values, was clearly designed for resolution discovery; it is overkill for setting a target resolution override.

But sending large resolution video over a peer connection is expensive. Here’s how you downscale it in Firefox:

If you’re in Firefox, hit the “Run” tab to see it in action. This uses the scaleResolutionDownBy feature or the sender.setParameters method in the WebRTC specification. Sadly, this only works in Firefox at the moment. But then you don’t need it in Chrome.