From f8db73ffc6d0063960f4134ea6b86b5956ec9509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 8 Nov 2023 05:58:30 +0100 Subject: [PATCH] Fix "zoom" effect with some cameras when changing the resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the video track resolution is changed the browser may crop and downscale the camera output to satisfy the requested constraints ("resizeMode: crop-and-scale"). However, in some cameras this causes an annoying "zoom" effect when changing between resolutions (it might be caused by the original source being shown for a split second before being cropped and downscaled, which may change the aspect ratio, although the reason is not fully clear). To prevent that, now the browser is asked to provide the camera output as is (although respecting the given constraints), without further adjustments. Note that the resize mode is not enforced, though. The browser may still crop and scale the camera output if it is not possible to get a native track in the requested resolution range. Signed-off-by: Daniel Calviño Sánchez --- src/utils/webrtc/VideoConstrainer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/webrtc/VideoConstrainer.js b/src/utils/webrtc/VideoConstrainer.js index 8406042964d..47e93e3d847 100644 --- a/src/utils/webrtc/VideoConstrainer.js +++ b/src/utils/webrtc/VideoConstrainer.js @@ -197,6 +197,7 @@ VideoConstrainer.prototype = { ideal: 30, min: 20, }, + resizeMode: 'none', } } @@ -217,6 +218,7 @@ VideoConstrainer.prototype = { ideal: 24, min: 15, }, + resizeMode: 'none', } } @@ -237,6 +239,7 @@ VideoConstrainer.prototype = { ideal: 15, min: 8, }, + resizeMode: 'none', } } @@ -251,6 +254,7 @@ VideoConstrainer.prototype = { frameRate: { max: 8, }, + resizeMode: 'none', } } @@ -264,6 +268,7 @@ VideoConstrainer.prototype = { frameRate: { max: 1, }, + resizeMode: 'none', } },