Show HN: Pxy – A Go server that proxies websocket livestreams to RTMP servers
github.com
github.com
This is, IMO, the simplest way to be able to go from a modern browser to an RTMP endpoint. You could try and do server-side WebRTC using a project like Pions[2], or use headless Chrome and be a peer, but both of those come with their own headaches. This just uses the MediaRecorder API to send chunks of video as it’s available via a WebSocket, then the server pipes those messages into FFmpeg via stdin. It’s lightweight enough that it even runs incredibly well on Glitch[3].
Also, if you’re curious, the videos that come out of the MediaRecorder are all over the place between browsers, but they’re all varying degrees of “barely qualifying as playable video”. Incredibly fun to play with, but you will absolutely need to encode any output from it.
[1] https://mux.com/blog/the-state-of-going-live-from-a-browser
Meanwhile, there's another well-explained tutorial that complements [1] along with a code walkthrough to implement something similar in Node.js.
https://github.com/fbsamples/Canvas-Streaming-Example/blob/m...
I'm really interested to see where this project goes, please keep me in the loop!
https://github.com/deepch/RTSPtoWSMP4f
https://github.com/deepch/RTSPtoWebRTC
I'm jealous of Go's WebRTC library that makes the latter possible. I'd love to have a similar Rust crate.
One thing I'd love to see at some point is a project that compiles FFMpeg's transmuxing code to WASM such that the WebM --> FLV conversion could be done client-side. That way the server-side portion would be as simple as proxying the WebSocket to a TCP socket for the outgoing RTMP traffic.
Getting the client to do the heavy lifting while the server acts solely as a relay is a really good idea. In my use case, however, I have a flutter client that's not capable of doing that at the moment, perhaps that's something that could be explored further in the future.