{"id":262,"date":"2017-02-27T08:04:41","date_gmt":"2017-02-27T08:04:41","guid":{"rendered":"https:\/\/blog.mozilla.org\/webrtc\/?p=262"},"modified":"2020-05-23T15:11:46","modified_gmt":"2020-05-23T15:11:46","slug":"fiddle-week-downscale-video-peerconnection","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/","title":{"rendered":"Fiddle-of-the-week: Downscale video in RTCPeerConnection"},"content":{"rendered":"<p>More of last year&#8217;s new laptop cameras have few or no low-resolution modes. These reveal a big difference in how Chrome and Firefox implement the <code>getUserMedia<\/code> 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 <a href=\"https:\/\/w3c.github.io\/mediacapture-main\/getusermedia.html#constrainable-interface\">spec<\/a>. That said, the elaborate constraints language offered by <code>getUserMedia<\/code>, with <code>min<\/code>&#8211;<code>max<\/code> ranges and <code>ideal<\/code> values, was clearly designed for resolution discovery; it is overkill for setting a target resolution override.<\/p>\n<p>But sending large resolution video over a peer connection is expensive. Here&#8217;s how you downscale it in Firefox<!--more-->:<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/jsfiddle.net\/jib1\/eL2byuw8\/embedded\/js,result,html\/\" allow=\"camera; microphone\" width=\"100%\" height=\"600px\" frameborder=\"0\"><\/iframe><\/p>\n<p>Hit the &#8220;Run&#8221; tab to see it in action. This uses the <a href=\"https:\/\/w3c.github.io\/webrtc-pc\/#dom-rtcrtpencodingparameters-scaleresolutiondownby\"><code>scaleResolutionDownBy<\/code><\/a> and <a href=\"https:\/\/w3c.github.io\/webrtc-pc\/#dom-rtcrtpencodingparameters-maxbitrate\"><code>maxBitrate<\/code><\/a>  features of the\u00a0<a href=\"https:\/\/w3c.github.io\/webrtc-pc\/#dom-rtcrtpsender-setparameters\"><code>sender.setParameters<\/code><\/a> method in the <a href=\"https:\/\/w3c.github.io\/webrtc-pc\/#dom-rtcrtpsender-setparameters\">WebRTC specification<\/a>.<br \/>\n<strong><br \/>\nUpdate 2020: This now works in Chrome and Edge as well! You can also resize it dynamically now.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"More of last year&#8217;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 [&hellip;]","protected":false},"author":1399,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"coauthors":[301098],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Fiddle-of-the-week: Downscale video in RTCPeerConnection - Advancing WebRTC<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fiddle-of-the-week: Downscale video in RTCPeerConnection - Advancing WebRTC\" \/>\n<meta property=\"og:description\" content=\"More of last year&#8217;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 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/\" \/>\n<meta property=\"og:site_name\" content=\"Advancing WebRTC\" \/>\n<meta property=\"article:published_time\" content=\"2017-02-27T08:04:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-23T15:11:46+00:00\" \/>\n<meta name=\"author\" content=\"Jan-Ivar Bruaroey\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jan-Ivar Bruaroey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/\",\"url\":\"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/\",\"name\":\"Fiddle-of-the-week: Downscale video in RTCPeerConnection - Advancing WebRTC\",\"isPartOf\":{\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/#website\"},\"datePublished\":\"2017-02-27T08:04:41+00:00\",\"dateModified\":\"2020-05-23T15:11:46+00:00\",\"author\":{\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/#\/schema\/person\/f2eb9712b8d85b70aebe1faf24e731fd\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.mozilla.org\/webrtc\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fiddle-of-the-week: Downscale video in RTCPeerConnection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/#website\",\"url\":\"https:\/\/blog.mozilla.org\/webrtc\/\",\"name\":\"Advancing WebRTC\",\"description\":\"Committed to moving Firefox and WebRTC forward\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.mozilla.org\/webrtc\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/#\/schema\/person\/f2eb9712b8d85b70aebe1faf24e731fd\",\"name\":\"Jan-Ivar Bruaroey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/webrtc\/#\/schema\/person\/image\/5f3d49a61b032619d0d33c4cc7c7433f\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/16d7e05dc9f8a855a02e0796b00aad3f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/16d7e05dc9f8a855a02e0796b00aad3f?s=96&d=mm&r=g\",\"caption\":\"Jan-Ivar Bruaroey\"},\"url\":\"https:\/\/blog.mozilla.org\/webrtc\/author\/jbruaroeymozilla-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fiddle-of-the-week: Downscale video in RTCPeerConnection - Advancing WebRTC","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/","og_locale":"en_US","og_type":"article","og_title":"Fiddle-of-the-week: Downscale video in RTCPeerConnection - Advancing WebRTC","og_description":"More of last year&#8217;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 [&hellip;]","og_url":"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/","og_site_name":"Advancing WebRTC","article_published_time":"2017-02-27T08:04:41+00:00","article_modified_time":"2020-05-23T15:11:46+00:00","author":"Jan-Ivar Bruaroey","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jan-Ivar Bruaroey","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/","url":"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/","name":"Fiddle-of-the-week: Downscale video in RTCPeerConnection - Advancing WebRTC","isPartOf":{"@id":"https:\/\/blog.mozilla.org\/webrtc\/#website"},"datePublished":"2017-02-27T08:04:41+00:00","dateModified":"2020-05-23T15:11:46+00:00","author":{"@id":"https:\/\/blog.mozilla.org\/webrtc\/#\/schema\/person\/f2eb9712b8d85b70aebe1faf24e731fd"},"breadcrumb":{"@id":"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.mozilla.org\/webrtc\/fiddle-week-downscale-video-peerconnection\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.mozilla.org\/webrtc\/"},{"@type":"ListItem","position":2,"name":"Fiddle-of-the-week: Downscale video in RTCPeerConnection"}]},{"@type":"WebSite","@id":"https:\/\/blog.mozilla.org\/webrtc\/#website","url":"https:\/\/blog.mozilla.org\/webrtc\/","name":"Advancing WebRTC","description":"Committed to moving Firefox and WebRTC forward","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.mozilla.org\/webrtc\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.mozilla.org\/webrtc\/#\/schema\/person\/f2eb9712b8d85b70aebe1faf24e731fd","name":"Jan-Ivar Bruaroey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/webrtc\/#\/schema\/person\/image\/5f3d49a61b032619d0d33c4cc7c7433f","url":"https:\/\/secure.gravatar.com\/avatar\/16d7e05dc9f8a855a02e0796b00aad3f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/16d7e05dc9f8a855a02e0796b00aad3f?s=96&d=mm&r=g","caption":"Jan-Ivar Bruaroey"},"url":"https:\/\/blog.mozilla.org\/webrtc\/author\/jbruaroeymozilla-com\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/posts\/262"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/users\/1399"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/comments?post=262"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/tags?post=262"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webrtc\/wp-json\/wp\/v2\/coauthors?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}