I would like to create a web page where users can listen to various public safety radio streams in an area. A typical setup involves running a traditional radio scanner to make one audio stream.
My goal is to have a page with many different streams, each one can be selected "on" or "off", and they can play simultaneously.
The naive approach would just be to scale up the traditional audio stream method with one stream per radio channel, however I am concerned about the bandwidth demands and reliability. Users report their streams dropping out and having to reconnect.
My next idea, is to essentially buffer the streams through an FFMPEG instance and record them to disk while also cutting out the silence, then monitor the output of that with some code to "push" the new audio clips out to the listeners.
I don't have any code written yet, I am looking for suggestions on an overall approach to take.
My solution seems overly-complex to me, does anyone know of an audio codec or streaming solution that is well suited to audio with long periods of silence? Or is my idea the best way to do this? Can you think of any improvements?
The naive approach would just be to scale up the traditional audio stream method with one stream per radio channel
This is what I would recommend doing. It's simple, fairly low latency, has no special requirements on the server or the client.
however I am concerned about the bandwidth demands and reliability
Bandwidth for this is minimal. I recommend using Opus for the best quality for the bandwidth. Also, consider using VBR for the encoding. You'll end up with very low bandwidth when there is silence, with more bandwidth used while there's actual content. This is similar to what you were considering doing, but already built into the codec.