Skip to content

Instantly share code, notes, and snippets.

@kwindla
Last active December 9, 2023 16:33
Show Gist options
  • Save kwindla/fb43f42585b7ba8af7384cf363cd3e85 to your computer and use it in GitHub Desktop.
Save kwindla/fb43f42585b7ba8af7384cf363cd3e85 to your computer and use it in GitHub Desktop.
Daily.co sending a motion-optimized screenshare
<html>
<head>
<title>test high bitrate, motion-oriented screenshare</title>
<script src="https://unpkg.com/@daily-co/daily-js"></script>
</head>
<body onload="main()">
<div id="videos"></div>
<script>
async function main() {
const ROOM_URL = ROOM URL HERE;
window.callObject = DailyIframe.createCallObject({
audioSource: false,
videoSource: false,
});
await callObject.join({ url: ROOM_URL });
// better to set this as a domain or room property, but just
// to make the test code easier, we'll force the network
// topology to sfu mode
await callObject.setNetworkTopology({ topology: "sfu" });
}
async function startMotionScreenShare() {
callObject.startScreenShare({
displayMediaOptions: {
audio: false,
selfBrowserSurface: "exclude",
surfaceSwitching: "include",
video: {
height: 720,
},
},
// video send settings
// can be set to the 'motion-optimized' preset or you can set the bitrate manually.
// currently the maxBitrate for the motion-optimized preset is 2mbps. This
// number is a little bit low for full-motion video at 720p, but raising
// the bitrate target will cause issues for receive-side users with
// slower connections.
screenVideoSendSettings: {
maxQuality: "low",
encodings: {
low: {
dtx: true,
maxBitrate: 2800000,
scaleResolutionDownBy: 1,
maxFramerate: 30,
},
},
},
});
}
</script>
<button onclick="startMotionScreenShare()">start screenshare</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment