Streaming WebRTC from nodeJS

Hi, is there an example (or advice) of how to use stream webrtc from a nodeJS server? Is this possible? Use case is we got a screencast within our nodeJS system and we'd like to stream it in realtime to browser clients.
3 Replies
Brendan Irvine-Broque
When you say that you get a screencast within your nodeJS system — what's the source of this screencast? How does your nodeJS server receive it today?
quambo
quambo2y ago
its a screencast from a playwright/puppeteer instance @irvinebroque
Brendan Irvine-Broque
Got it — Playwright itself is built to record video, but AFAIK not setup well to stream it live: https://playwright.dev/docs/api/class-video This would be outside of Playwright, but in principle, within the page you want to screencast, you could use the Screen Capture API: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture ...and then use this as the input stream, using something like the example WHIP client here: https://github.com/cloudflare/templates/blob/main/stream/webrtc/src/WHIPClient.ts#L58
Video | Playwright
When browser context is created with the recordVideo option, each page has a video object associated with it.
Using the Screen Capture API - Web APIs | MDN
In this article, we will examine how to use the Screen Capture API and its getDisplayMedia() method to capture part or all of a screen for streaming, recording, or sharing during a WebRTC conference session.
GitHub
templates/WHIPClient.ts at main · cloudflare/templates
A collection of stater templates and examples for Cloudflare Workers and Pages - templates/WHIPClient.ts at main · cloudflare/templates