Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
13.09k stars 1.51k forks source link

Support the SRT streaming protocol #4276

Open Your-New-SJW-Waifu opened 3 years ago

Your-New-SJW-Waifu commented 3 years ago

Describe the problem to be solved

Currently the only ingest protocol supported for live streaming is RTMP which has many downsides. SRT aims to fix this. A few of it's benifits over RTMP are:

All of these are a big plus. Using newer codecs could also be beneficial if we ever decide to default to AV1 and/or Opus or possibly for a user with low bandwidth (using a server with live transcoding) to get the same quality stream at a lower bitrate.

Additionally, since version 25, OBS supports streaming to SRT endpoints.

Additionally, with SRT having security built in it'd negate the need for #4236

Describe the solution you would like:

Add support for the SRT streaming protocol.

Describe alternatives you have considered

As for the way things stand right now there aren't many alternatives. RTMP isn't being maintained and won't be updated. SRT was designed to be a modern replacement to the aging RTMP protocol. The only real alternative is the FTL protocol but it's far more limiting and was never fully documented before the fall of Beam/Mixer.

whyronimus commented 2 years ago

As far as I understand it's very difficult to actually get an actual SRT stream to show up in a browser-displayed player (it's not even working very well in VLC media player due to the partially (?) implemented streamid parameter).

However, there's a possible solution to this:

With one ffmpeg call, an incoming SRT stream can transmuxed into HLS/DASH, which is described here: https://github.com/Haivision/srt/issues/371#issuecomment-389494674 If the -hls_segment_type fmp4 option works here, things like alternate audio tracks and FLAC support are on. (FLAC in HLS works with fmp4 enabled, see here: https://github.com/Chocobozzz/PeerTube/issues/4635#issuecomment-997041580)

I still need to test it, but if this works, it could open some great options. An implementation like described above would not take advantage of SRT's great latency, but I wouldn't consider this critical if videos are streamed for entertainment or similar issues.

IMHO a bounty should be set up for this feature, and I'd be glad to donate. It could provide the "giant leap" for peertube to offer an advanced, much more powerful streaming protocol. RTMP/FLV is widespread and well known to work, but lacking some functionality.

@Chocobozzz , is there any official or preferred way for peertube, such as bountysource?

Chocobozzz commented 2 years ago

Hello,

We don't have bountysource for peertube. What we miss to implement SRT is a nodejs library so we can check the stream, credentials etc like we do with https://github.com/illuspas/Node-Media-Server

whyronimus commented 2 years ago

Thanks for the hint! @Your-New-SJW-Waifu, the feature already has been adressed here: https://github.com/illuspas/Node-Media-Server/issues/379, let's ask if we can provide any help.

whyronimus commented 2 years ago

@Chocobozzz would it be possible using https://github.com/Eyevinn/node-srt ? It is documented here: https://eyevinntechnology.medium.com/develop-an-srt-client-and-server-in-node-js-cedf52873469

Chocobozzz commented 2 years ago

Unfortunately no, it requires a native dependency (something we try to avoid) and does not provide appropriate hooks.

lilymonad commented 2 years ago

Would it work if we build a static WASM version of it? I am currently trying to build one for librist. SRT seems harder to port though.