Hackathon Project: Daily "cable access TV" with nginx
Repo here: https://github.com/vipyne/nginx-rtmp-docker
A coworker and I were talking about how we enjoyed learning from our other colleagues, even if it was just watching them screenshare and squash a bug or delve through logs or push a small feature. And sometimes we missed just general office chatter. Wouldn't it be neat to have a constant live stream of content like this? I imagined a cable access channel TV-like experience. (Wayne's World was a big inspiration here.) I wanted to keep a small browser window always open in the corner of my screen, much like having a TV on in the background, that would show my coworkers doing a lunch-and-learn or hosting open office hours. There wouldn't be 24 hours everyday of content, so when nothing was streaming (or nothing was "on TV"), a static logo would appear. The nice thing here is that other than navigating to the site, I wouldn't have to do anything to passively access the content. Live streams would start and end and I could just sit back and watch. I imagined a blend of live and "syndicated", or pre-recorded, content and maybe some fun /daily logo bumpers, but in true Hack form, what was created is just a POC. Essentially I wanted to blend real time video with VOD (video on demand), and basically, that's what this does, albeit naively so.
I knew I wanted to learn more about nginx configuration, especially with regard to RTMP streaming, so I started there. After I got the server config to handle RTMP, HLS, and VOD, I made a web 1.0 simple html page that loops an .mp4 file (the static /daily TV logo). Then I poll for RTMP stats (which we get for free from nginx, thanks nginx!). We parse the RTMP streaming stats XML for when a stream has started and when one has, we switch the video src and type on the player to HLS, and the live stream replaces the looping mp4 content. When the stream ends (again determined from polling the RTMP stats), we switch back to the mp4 video source and the player goes back to static.