watchparty
watchparty copied to clipboard
Explore using mediasoup for screenshare/fileshare
Currently, screenshare/fileshare require one user to upload to everyone else in the room, which doesn't scale to large room sizes.
To achieve higher viewer counts, we can try something like MediaSoup which provides a server that will broadcast a single user's video stream to everyone else over WebRTC.
An example: https://github.com/michaelfig/mediasoup-broadcast-example
Another example (currently private): https://github.com/howardchung/watchparty-mediasoup
Another option: Ant Media Server
https://github.com/ant-media/Ant-Media-Server/wiki/Installation
https://github.com/ant-media/Ant-Media-Server/blob/877cbecd01fcff0bb77ad6f1533fbe67f4b3b977/doc/website/docs/guides/developer-sdk-and-api/sdk-integration/WebRTC-Publish-Page-Creation-Tutorial.md
https://hub.docker.com/r/nibrev/ant-media-server
It supports ingesting video via webrtc (we can pass it getDisplayMedia output), and can create an HLS stream for consumers (less complicated than mediasoup webrtc everywhere, but adds some latency)
Did some additional testing--the ant media server works and we could output to HLS and have watchers just watch the m3u8 playlist.
However:
- It has about 10 seconds of latency
- CPU expensive since I think AMS is transcoding
- quality seems lower
I retested the mediasoup example and it appears to work better--there is almost no latency, no transcoding needed and quality is better.
A third option that just occurred to me: Having the sharer transcode the video using ffmpeg.wasm (https://github.com/ffmpegwasm/ffmpeg.wasm), and then we could either just stick the transcoded video in temporary blob storage or HLS or even in memory in Redis like we do with subtitles