To enable this feature in Chrome, toggle the Experimental Web Platform feature (See chrome://flags/#enable-experimental-web-platform-features).
Display the screensharing stream from getDisplayMedia() in a video element and record the stream.
getDisplayMedia()