Welcome to Project Lightspeed. This is a project that allows anyone to easily deploy their own sub-second latency live-streaming server. In its current state you can stream from OBS [1] and watch that stream back from any desktop browser.
This has been a super fun project which has taught me more than any other project I have done. It uses Rust, Go and React and can be deployed fairly easily on a very lightweight server. For example, I have been doing my test streams on a $5 Digital Ocean droplet and the CPU usage is at around 20%. Granted not a lot of people are watching however it is more lightweight than a solution such as Janus. The point of this project is twofold. First I wanted to learn more about WebRTC and real-time communication in general. Second, I wanted to provide a platform where people can setup their own little live-stream environment. Maybe you just want a place where you and some friends can hang out or you are sick of the main-stream platforms. Anyhow as of writing this post it is v0.1.0 and considered an MVP release. In the coming months I (and hopefully some of you :)) will be adding more features and trying to flesh this out into as much of a full featured platform as possible. Feel free to take a look at the repo and let me know what you all think :) [1] Open Broadcast Software (OBS): https://obsproject.com/
A very interesting project, can you elaborate more on how
it is getting sub second latency and why youtube/twitch seem to have more than a few seconds of delay.
YouTube and twitch use RTMP which operates over TCP. This means that each time we send a packet we need to ensure that it’s been received which adds latency overhead. Lightspeed uses the FTL protocol which operates over udp thus reducing the latency overhead
So assuming you have packet loss - you just get a paused/blank stream until the flow continues? How does it handle any network issues.
Would it ever be possible to route two stream via different paths to the client and let the client just accept the first packet from either and drop the other in order to add some redundancy to delivery?
HTTP video streams are split into segments and those segments are delivered whole. Larger segments are easier to cache and scale to bigger number of viewers. The other factor is that youtube and twitch spend more CPU time on compression to achieve lower bitrates.
Could it be possible to use WebRTC to have listeners become seeders/repeaters so you could have more listener without impacting too much your own CPU ? Something like AceStream.
This project is pretty cool, I’ll tinker around with it tomorrow.
As an aside, I’ve noticed you’re building out your own stream protocol stack (FTL/LightSpeed). What’s the reasoning there? Seems slightly inconvenient to have to “hack” OBS to make the output stream work. Will FTL support be merged into OBS in the future? If you’re just trying to avoid the latency of RTMP then I might suggest considering the existing SRT protocol[1]. It’s been open source for a while and is well-established(native support in OBS core and optional in FFMPEG). Seems to already solve a lot of the transport-level stuff that you’re working on with FTL. [1] Secure Reliable Transport: https://github.com/Haivision/srt
So FTL is supported by OBS and was used by Mixer. I’m interested to move to SRT in the future since you’re correct, FTL support will be going away eventually
Also the work required to adapt what I have to SRT is non trivial and I would rather have something that works right now and then build in SRT support in the future
Got it. I’m fresh on FTL, first I’ve really dug into it so apologies for the ignorance. I’m in the industry of stream transport and mostly work with SRT.
Yes to the first half of this at least (KCP is not something I've heard of).
Having recently attempted to use SRT for an event's backend restreaming stack, the low latency was nice but it's a pain in the ass. It's really not designed for links where latency isn't known and consistent. You have to bake an expected latency amount into initial protocol negotiation or you'll end up with problems, and OBS' support is quite poor (failure to establish a connection for whatever reason is likely to freeze it up completely, it sucks up a lot of cpu vs. rtmp, etc). And the other end of the stack is either pretty immature and kind of wonky (haivision's own software, srt-live-server) or requires you to pay to use it or is very closed source. WebRTC of some sort is definitely the future of this, imo. Even if the stack kind of sucks right now the results are fabulous (discord's video streaming for eg. is webrtc based and is easily the lowest latency free screen sharing I've seen outside share-my-desktop stuff like parsec or rdp). It looks like this uses the already-built-into-obs support for the webrtc-based ftl protocol mixer used and microsoft killed. That's actually really clever and honestly I think this is far more appealing than SRT.
Hoping to see OP answer this and in particular what I would like to see them comment on is how they divide their codebase between these two languages. Which parts are being implemented in which of those languages and why. Personally a huge proponent of Rust.
I think it was a matter of what libraries were available where. Namely, Lightspeed-webrtc uses the extremely popular & robust Go library Pion[1] for webrtc. It's a little over 500 lines.
The Rust Lightspeed-ingest[2] server is also ~500 lines of code, and primarily handshakes the FTL protocol used to communicate with OBS. There is a Pion port to rust[3] that is in progress. I am not sure the state of this work. Pion is used quite extensively by many many projects; I'm not sure if the rust webrtc-rs port has any notable users yet. As I began by saying, I expect the trustability & extensiveness of Pion is what lead to lightspeed-webrtc being written in Go. [1] https://pion.ly/ [2] https://github.com/GRVYDEV/Lightspeed-ingest [3] https://github.com/webrtc-rs/webrtc
Awesome! I was looking for something like this when trying to play a local multiplayer game via the Internet in an early lockdown.
There are, or were, no good turnkey solutions for this. Twitch and Youtube have 5-10s latency, which is often not good enough. Mixer promised (and presumably delivered) ~1s latency using the FTL protocol you use, but they had a wait list of a couple of days or weeks, and of course now, they don't exist anymore. Even Steam Play Together, ostensibly built for this purpose, wasn't low latency enough in my limited experience (this really surprised me, so maybe I'm doing it wrong). The easiest solution, use the share desktop function of whatever video conference tool, almost works, but they universally seemed reduce the frame rate, which is ok for presentations but unsuitable for games (also, no audio). My solution was to output OBS to a virtual webcam device and use Jitsi Meet. A bit roundabout, but it worked wonderfully. Ideally, I'd forgo the DO droplet, and just run everything locally. 20% of a small droplet is even less of a modern desktop computer's CPU. Which leaves upload bandwidth for broadcast, which depends on your connection and how many people you need to be able to stream to.
Yes, I forgot about Parsec, that's a good suggestion. I remember trying it, and not getting it to do what I want, unfortunately I don't remember why. I think I was stuck in the "Arcade", when all I wanted was to share my desktop or one window. It certainly looks like exactly what I was looking for.
About the choice of license (MIT): could you share your considerations about it? (if any)
It's a topic I'm interested in. Mainly to see examples (and learn from them) about when people prefer lax licenses on the style of "do what you want with this, including a closed-source proprietary business" (MIT, Apache) which has allowed in the past that big Co's. benefit from it without giving back (lots of cases in HN), vs. strong copyleft "do what you want except closed-source proprietary stuff" style (generally speaking, the GPL family -- EDIT: I know that this, being mainly a server-side thing, would be more affected by AGPL than by GPL. Bear with me.). If there are no business / commercialization intentions in the foreseeable future, would it make sense to use a GPL license (one of them) to build a strong open-source community? Or it doesn't matter in practice? (i.e. it doesn't really affect the chances of building a good and strong developer community)
Would I like a strong open source community? Absolutely, could you fork this and make money off of it right now? No not even close. Maybe in the future I would consider a different license but at the end of the day if you take this and make it profitable good for you :) my goal wasn’t to make money
I am also pro-MIT. For me, "freedom" doesn't mean "restricting what users can do."
GPL restricts what users can do, and thus restricts freedom in my eyes. Not sure why anyone would care but it seemed like a good time to explain my thoughts on that while agreeing with you. This kind of thing has been needed for some time, so thank you for creating it.
Restricting the freedom to use your work to restrict others' freedom, is not nearly so onerous or hypocritical as GPL bemoaners try to characterize it. I feel absolutely zero sympathy for the argument.
Realize how I oriented my question around how it might affect building an OSS community.
A MIT or Apache license might detract contributors, because essentially these licenses say "your contribution is OSS today, but it might end up resulting as unintended free labor that helps build a commercial product of which you won't be part of". However some see GPL licenses as a guarantee that external contributions are actually contributions to the overall Open-Source community as a whole, because they cannot be turned into other non-OSS product without explicit permission of all people who built it. So yes, copyleft is more restrictive than non-copyleft. But only in the subtle sense of ensuring that no further restrictions will get added by any third party, ever. Which is a strong promise that should encourage contributions. Ultimately, my objective is to learn if this theory matches the practice.
Actually those who prefer GPL see things from the perspective of the code, not the users.
GPL ensures the code is freely available at all times, and anyone can use it, change it, distribute it but not take it away or restrict access to it. From the code pov, MIT/Apache is freedom to take away and restrict access.
A developer is the "user"? MIT is freer for the dev, but the dev is free to restrict the end-user. End-users are the users? GPL restricts developers from closing the source, empowering end users to become developers too.
> For me, "freedom" doesn't mean "restricting what users can do."
> GPL restricts what users can do, and thus restricts freedom in my eyes. A few sibling commenters have already rebutted, but to add to that, a way of looking at this is that all licences necessarily restrict users (with the possible/arguable exception of things like CC0). The difference with GPL vs MIT is that MIT gives users the "freedom" to further restrict other users in future, whereas GPL restricts users from ever further restricting other users
As I said, I'm not trying to push for this or that license, just want to have a perspective of the choice for new OSS projects. Mostly the usual lesson is that authors typically don't really think through much about the licensing choice when they are hyped about an upcoming first release. Technical concerns are, understandably, what gets most attention at the beginning. Your position is the most common one I've found for small-ish projects.
This is awesome! I wanted to make something like this too after Mixer shut down and I didn't have good options anymore to stream low latency gameplay to friends. But I was too lazy to do it properly.
I ended up with this hack: https://i.imgur.com/jDeMxly.png Redirect the "Record" button of obs to make ffmpeg output to an http endpoint, which is a small server that just forwards any bytes it receives to connected consumers. They can then play it back with
I've found that most of the latency is actually coming from the player. I.e. VLC has way more latency, even if you tell it to not buffer. TCP is a bit of an issue since ffplay doesn't speed up playback when it falls behind, but it mostly works and you can just restart ffplay if you fall behind too far. When it works (good network conditions) it also achieves sub second latency.
Will definitely have to give this a try over my hack.
If you want casual people to use this, I would look into simplifying the setup. Either by providing compiled binaries instead of having to set up go, rust etc oneself. Or by containerizing something.
Comments (138) 17 threads
This has been a super fun project which has taught me more than any other project I have done. It uses Rust, Go and React and can be deployed fairly easily on a very lightweight server. For example, I have been doing my test streams on a $5 Digital Ocean droplet and the CPU usage is at around 20%. Granted not a lot of people are watching however it is more lightweight than a solution such as Janus.
The point of this project is twofold. First I wanted to learn more about WebRTC and real-time communication in general. Second, I wanted to provide a platform where people can setup their own little live-stream environment. Maybe you just want a place where you and some friends can hang out or you are sick of the main-stream platforms.
Anyhow as of writing this post it is v0.1.0 and considered an MVP release. In the coming months I (and hopefully some of you :)) will be adding more features and trying to flesh this out into as much of a full featured platform as possible. Feel free to take a look at the repo and let me know what you all think :)
[1] Open Broadcast Software (OBS): https://obsproject.com/
Would it ever be possible to route two stream via different paths to the client and let the client just accept the first packet from either and drop the other in order to add some redundancy to delivery?
Continue this thread — 3 replies
As an aside, I’ve noticed you’re building out your own stream protocol stack (FTL/LightSpeed). What’s the reasoning there? Seems slightly inconvenient to have to “hack” OBS to make the output stream work. Will FTL support be merged into OBS in the future?
If you’re just trying to avoid the latency of RTMP then I might suggest considering the existing SRT protocol[1]. It’s been open source for a while and is well-established(native support in OBS core and optional in FFMPEG). Seems to already solve a lot of the transport-level stuff that you’re working on with FTL.
[1] Secure Reliable Transport: https://github.com/Haivision/srt
Looking forward to tinkering with this!
Continue this thread — 1 reply
I wanted to try this, even made a docker config and only then realized I can't stream to it from Archlinux.
Having recently attempted to use SRT for an event's backend restreaming stack, the low latency was nice but it's a pain in the ass. It's really not designed for links where latency isn't known and consistent. You have to bake an expected latency amount into initial protocol negotiation or you'll end up with problems, and OBS' support is quite poor (failure to establish a connection for whatever reason is likely to freeze it up completely, it sucks up a lot of cpu vs. rtmp, etc).
And the other end of the stack is either pretty immature and kind of wonky (haivision's own software, srt-live-server) or requires you to pay to use it or is very closed source.
WebRTC of some sort is definitely the future of this, imo. Even if the stack kind of sucks right now the results are fabulous (discord's video streaming for eg. is webrtc based and is easily the lowest latency free screen sharing I've seen outside share-my-desktop stuff like parsec or rdp).
It looks like this uses the already-built-into-obs support for the webrtc-based ftl protocol mixer used and microsoft killed. That's actually really clever and honestly I think this is far more appealing than SRT.
Continue this thread — 1 reply
RIST adds nack based retransmissions to decades old RTP and has multiple implementations.
Continue this thread — 1 reply
Hoping to see OP answer this and in particular what I would like to see them comment on is how they divide their codebase between these two languages. Which parts are being implemented in which of those languages and why.
Personally a huge proponent of Rust.
The Rust Lightspeed-ingest[2] server is also ~500 lines of code, and primarily handshakes the FTL protocol used to communicate with OBS.
There is a Pion port to rust[3] that is in progress. I am not sure the state of this work. Pion is used quite extensively by many many projects; I'm not sure if the rust webrtc-rs port has any notable users yet. As I began by saying, I expect the trustability & extensiveness of Pion is what lead to lightspeed-webrtc being written in Go.
[1] https://pion.ly/
[2] https://github.com/GRVYDEV/Lightspeed-ingest
[3] https://github.com/webrtc-rs/webrtc
There are, or were, no good turnkey solutions for this. Twitch and Youtube have 5-10s latency, which is often not good enough. Mixer promised (and presumably delivered) ~1s latency using the FTL protocol you use, but they had a wait list of a couple of days or weeks, and of course now, they don't exist anymore. Even Steam Play Together, ostensibly built for this purpose, wasn't low latency enough in my limited experience (this really surprised me, so maybe I'm doing it wrong).
The easiest solution, use the share desktop function of whatever video conference tool, almost works, but they universally seemed reduce the frame rate, which is ok for presentations but unsuitable for games (also, no audio). My solution was to output OBS to a virtual webcam device and use Jitsi Meet. A bit roundabout, but it worked wonderfully.
Ideally, I'd forgo the DO droplet, and just run everything locally. 20% of a small droplet is even less of a modern desktop computer's CPU. Which leaves upload bandwidth for broadcast, which depends on your connection and how many people you need to be able to stream to.
Continue this thread — 1 reply
Continue this thread — 2 replies
Continue this thread — 6 more replies
Continue this thread — 4 more replies
It's a topic I'm interested in. Mainly to see examples (and learn from them) about when people prefer lax licenses on the style of "do what you want with this, including a closed-source proprietary business" (MIT, Apache) which has allowed in the past that big Co's. benefit from it without giving back (lots of cases in HN), vs. strong copyleft "do what you want except closed-source proprietary stuff" style (generally speaking, the GPL family -- EDIT: I know that this, being mainly a server-side thing, would be more affected by AGPL than by GPL. Bear with me.).
If there are no business / commercialization intentions in the foreseeable future, would it make sense to use a GPL license (one of them) to build a strong open-source community?
Or it doesn't matter in practice? (i.e. it doesn't really affect the chances of building a good and strong developer community)
GPL restricts what users can do, and thus restricts freedom in my eyes.
Not sure why anyone would care but it seemed like a good time to explain my thoughts on that while agreeing with you.
This kind of thing has been needed for some time, so thank you for creating it.
Restricting the freedom to use your work to restrict others' freedom, is not nearly so onerous or hypocritical as GPL bemoaners try to characterize it.
I feel absolutely zero sympathy for the argument.
A MIT or Apache license might detract contributors, because essentially these licenses say "your contribution is OSS today, but it might end up resulting as unintended free labor that helps build a commercial product of which you won't be part of".
However some see GPL licenses as a guarantee that external contributions are actually contributions to the overall Open-Source community as a whole, because they cannot be turned into other non-OSS product without explicit permission of all people who built it.
So yes, copyleft is more restrictive than non-copyleft. But only in the subtle sense of ensuring that no further restrictions will get added by any third party, ever. Which is a strong promise that should encourage contributions.
Ultimately, my objective is to learn if this theory matches the practice.
Continue this thread — 15 replies
GPL ensures the code is freely available at all times, and anyone can use it, change it, distribute it but not take it away or restrict access to it.
From the code pov, MIT/Apache is freedom to take away and restrict access.
A developer is the "user"? MIT is freer for the dev, but the dev is free to restrict the end-user.
End-users are the users? GPL restricts developers from closing the source, empowering end users to become developers too.
Continue this thread — 1 reply
> GPL restricts what users can do, and thus restricts freedom in my eyes.
A few sibling commenters have already rebutted, but to add to that, a way of looking at this is that all licences necessarily restrict users (with the possible/arguable exception of things like CC0).
The difference with GPL vs MIT is that MIT gives users the "freedom" to further restrict other users in future, whereas GPL restricts users from ever further restricting other users
As I said, I'm not trying to push for this or that license, just want to have a perspective of the choice for new OSS projects.
Mostly the usual lesson is that authors typically don't really think through much about the licensing choice when they are hyped about an upcoming first release. Technical concerns are, understandably, what gets most attention at the beginning. Your position is the most common one I've found for small-ish projects.
I ended up with this hack: https://i.imgur.com/jDeMxly.png
I've found that most of the latency is actually coming from the player. I.e. VLC has way more latency, even if you tell it to not buffer. TCP is a bit of an issue since ffplay doesn't speed up playback when it falls behind, but it mostly works and you can just restart ffplay if you fall behind too far. When it works (good network conditions) it also achieves sub second latency.Redirect the "Record" button of obs to make ffmpeg output to an http endpoint, which is a small server that just forwards any bytes it receives to connected consumers. They can then play it back with
Will definitely have to give this a try over my hack.
Don't expect much. I threw this entire thing together as quickly and lazily as possible.
If you want casual people to use this, I would look into simplifying the setup. Either by providing compiled binaries instead of having to set up go, rust etc oneself. Or by containerizing something.
Continue this thread — 1 reply
Continue this thread — 1 more reply
All comments shown.
Couldn't load more comments. Check your connection and try again.