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?


  • 1
    The obvious way to do this from inside Python is to open ffmpeg's stdout and oggenc's stdin as pipes to yourself, then copy data between them manually. Then when one ffmpeg quits, you can just start up the next without ever touching the still-running oggenc. – Tom Hunt Dec 10 '15 at 21:51
  • ok, sounds good, but what if it's not python? I think similar task could happen in unix andministration ,when you need to redirect input/output in a such way, so, there should be something in unix/linux toolbox – Illarion Kovalchuk Dec 11 '15 at 14:39
  • In a shell, you could do it by having a shell loop to open/decode/close all your .mp3 files, then piping that output into oggenc. In other languages, there are other ways. It's a language-specific task. – Tom Hunt Dec 11 '15 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.