Adding WebRTC support to OBS using Rust
github.com
github.com
Incidentially if this WebRTC support takes off, it may be a great tool for high-quality peer-to-peer desktop streaming.
edit: Forgot to mention that they also contributed Continuity Camera and Desk Cam support, so those are built in to OBS now as well.
Where OBS shines are
- Precise control over encoding parameters;
- Mix and match multiple input sources, beyond just screen + system sound + mic; this includes rearranging and cropping multiple application windows;
- Add text, images, filters, etc.
In short, it has a lot more power user features. If you just want to quickly record the entire screen / an application window / part of the screen, native screen recording tool beats it handily.
> I'm pretty naive, but would this enable one to self stream to a limited audience? Like if I wanted to just steam my desktop to <5 people. I've kinda been surprised that there's a lack of tools that can accomplish this.
It would be really cool if I could present something from my desktop, show my face, and whatever, while just handing my friends a link and not requiring them to download anything.
On a slightly off-topic note, I’ve been working on a simple WebRTC radio project[2] for a social listening experience. In my limited testing with a few friends, I was able to get < 100ms of lag (audio de-sync) between different players on different networks. It has been an absolute joy to use. The social experience of listening to music together somehow really appeals to me.
It was pleasantly simple to get it up and running with socket.io + Mediasoup as the SFU. I plan to flesh it out a lot more shortly but I’m a bit of a novice. Would love to have some more experienced eyes on the project :D
The way I see it WebRTC is the best way forward to enable people to build interesting things. I was so excited to itemize all the use cases that would be added to OBS by merging WebRTC support. I also wrote a little bit about 'Why WebRTC' https://pion.ly/blog/why-webrtc/. The big advantage WebRTC has over FTL is that is does more. Broadcast is a small part of WebRTC. I think WebRTC's superpower is that it can be used for so many different use cases and industries. Even if another protocol is better at a single use case, it is hard to beat the breadth of WebRTC.
WebRTC isn't without its issues. I think that is fixed by better education + more implementations and owners. We shall see what the future holds :)
I still use WebRTC for my personal projects but the difficulty of compiling and embedding it in a backend makes it really hard to use by the masses. My next project is going to use Pion, and I'm going to make a static compilation and just distribute the executable and have the main service use IPC to communicate with the Pion module.
If there is anything I can do to help please tell me, always happy to help :) Either email me sean @ pion.ly or join https://pion.ly/slack.
Slack is better, but some prefer email!
Sean is everywhere that involve WebRTC ! He is doing an incredible job.
Instant.io
It's still questionable to me to call this WebRTC though. My understanding is it's only output is WHIP, WebRTC-HTTP Ingestion Protocol, which is used by CDNs to actually do the WebRTC protocol browsers do. It's near WebRTC but a couple steps short, seemingly. https://www.ietf.org/archive/id/draft-ietf-wish-whip-05.txt
Agree on renaming from `webrtc_output` -> `whip_output`! I believe that is done in the current PR?
-----
This is my vote for PR of the year in open source! Holy shit. There's amazing thing after amazing tbing listed.
> Latency. With WebRTC we are able to achieve sub second latency. With our initial measurements we see ~120 Milliseconds from Broadcaster to Playback. We believe we can continue to bring down this number as well.
More speculative, but awesome futures here that OBS will either adopt or eventually fall on the wayside to a worthy competitor on:
> Broadcast at all angles. WebRTC supports multiple video streams in the same session. OBS could experiment with broadcasting multiple scenes at once! Viewers could then switch between scenes or different views in the same game.
> Simulcast. WebRTC allows broadcasters to upload multiple streams of different quality. OBS users could upload high, med, and low streams themselves.*
Also notable Rust based, working via FFI. Is this the first Rust in OBS?
Im trying to understand a little deeper how this implementation works. There's seemingly some hardware encoding support, but as compared to using something general & flexible like gstreamer it seems a bit more hardcoded, and embedded in webrtc-rs. Not the worst I guess.
It also has this somewhat odd "whip" output, where it dumps the stream via http. Im not sure if that is the only output right now. This targets some CDN systems, which then host/peer over actual CDN. Calling this webrtc feels a little weird but ok.
>Why webrtc-rs as the WebRTC library?
> WebRTC has many libraries that we could have used. The first one we evaluated was Google’s implementation known as libwebrtc. The time required to fetch+download would have been too much of a burden for the OBS code base. These metrics come from a Macbook M1 with a 400 Mb/s connection.