(Apologies about the question title, not quite sure how to word it)
So I'm working on a turnkey streaming solution / server for a local LAN party, using the fantastic nginx-rtmp to handle incoming RTMP streams from our main PC's and deliver (hopefully) an uninterrupted signal to Twitch and other such streaming services.
One of the main things I'd like to achieve is having the server switch to, say, a local webcam (or another stream) if we're not sending anything to it, which would perfect the zero-downtime approach that I'm aiming for. I've looked into using ffmpeg for this, with arguments along the line of:
ffmpeg -i "rtmp://127.0.0.1/in/stream" -i "rtmp://127.0.0.1/webcam/stream" -vcodec copy -acodec copy rtmp://127.0.0.1/out/stream
but ffmpeg refuses to start outputting unless it's receiving both inputs, and stops completely if it loses one.
Problem is that I can't think of any alternatives, short of:
- hooking into nginx-rtmp's on_publish_done hook and firing a script or something to trigger a webcam stream to start after a short delay (and then just stopping that stream using the control interface), or
- having another system running something like Open Broadcaster Software and handling the mixing
If anyone's got any ideas, no matter how silly, I'd really appreciate it, because I'm stumped!