demo · v136

CapturedSurfaceResolution

Start a screen capture and inspect the captured surface's pixel ratio. On a 2x display, a 1280-pixel-wide window streams as 2560 pixels — previously invisible to capturers.

Probing…
your devicePixelRatio
screen.width × height
track.getSettings()
video.videoWidth × height
capture pixel ratio

A surface streamed at 2560×1440 from a 1280×720 logical window has a pixel ratio of 2.0. Apps can use this to render their own UI overlays at the right density.

the code

const stream = await navigator.mediaDevices.getDisplayMedia();
const [track] = stream.getVideoTracks();
const settings = track.getSettings();

// 136+: explicit pixel ratio of the captured surface
console.log(settings.devicePixelRatio); // e.g. 2

// Or compute it from the stream + window:
const ratio = settings.width / window.outerWidth;

see also