I am running an online radio based on Icecast. I wrote the source client myself, so that I can be flexible in schedule of the tracks and so on. In order to play tracks on the radio, inside my python code I run 2 subprocesses: ffmpeg to decode file from disk into WAV and then redirect it's output is encoded by oggenc. Something like this, for each track:
ffmpeg -i foo_bar.mp3 -acodec pcm_s16le -ac 2 -f wav pipe:1 | oggenc - -b 128 --managed -o -
It works fine, until there is a new track to play. Sometimes players start to behave strange, for example mplayer simply stops and exits, vlc can change speed and start producing creepy sounds and so on.
The simplest solution would be keep oggenc running forever and somehow substitute the waveform it reads from standart input, but I have no idea how to do it in a not so tricky manner. I would like to avoid complicated things here, because it impacts the stability of the source client. What do you think?