WebRTC not getting resolution of both desktop displays for stream

279 views
Skip to first unread message

JoeD

unread,
Oct 9, 2021, 1:30:06 PM10/9/21
to discuss-webrtc

This is a remote desktop application via Chrome where the user shares their screen. The problem I am having is when the user has 2 or more screens, WebRTC only gets the first display's resolution. I can see this by logging localStream.getVideoTracks()[0].getSettings():

aspectRatio: 1.7777777777777777 
deviceId: "screen:-1:0" 
frameRate: 30 
height: 1080
resizeMode: "crop-and-scale"
width: 1920

Both screens end up streaming in one connection (getVideoTracks()[1] does not exist), but it only shows as one screen. The width should be 1920 * 2 screens at 3840.

My constraints and getting media are set as:

let mediaConstraints = { 
audio: false, 
resizeMode: "none", 
video: { 
mandatory: { chromeMediaSource: "desktop", }, 
}, 
}; 

localStream = await navigator.mediaDevices.getUserMedia(mediaConstraints);

I noticed crop-and-scale was set instead of none, and thought that might be causing a problem but I can't seem to get it to set for this kind of constraint. aspectRatio did nothing as well. Setting resizeMode within mandatory throws an error. Where am I going wrong here?

guest271314

unread,
Oct 10, 2021, 1:34:46 PM10/10/21
to discuss-webrtc

>  The problem I am having is when the user has 2 or more screens

I do not understand what is meant by 2 or more screens?

> The width should be 1920 * 2 screens at 3840

Are you trying to capture two separate screens, create a single image, then stream the combined images as a single video?

JoeD

unread,
Oct 11, 2021, 7:10:43 AM10/11/21
to discuss-webrtc
When the computer on the other end you are trying to remote control has more than one screen WebRTC only gets the first screens dimensions. 

I don't even think I have the capability to get both screens separately. All I do is await navigator.mediaDevices.getUserMedia(mediaConstraints) and it just finds all screens at once for one stream as getVideoTracks()[1] does not exist.
Reply all
Reply to author
Forward
0 new messages