R – Delay a Shoutcast stream by 12 hours (Linux/bash)


I am living on the other side of the world from my home (GMT+1 now, GMT+13 is home), and I miss my old terrestrial radio station. It has a Shoutcast stream, and I would like to simply delay it by 12 hours so that it is always available when I want to listen to it, in a way that would make its timezone be synchronised to my timezone.

I envision this as a script being run on my server host.

A naive approach would simply be to allocate enough ram in a ringbuffer to store the entire 12 hour delay, and pipe in the output from streamripper. But the stream is a 128kbps mp3, which would mean (128/8) * 60 * 60 = ~56MB per hour, or 675MB for the whole 12 hour buffer, which isn't really so practical. Plus, i might have to deal with my server host just killing the process after a certain timeout.

So, what are some strategies that might actually be practical?

Best Solution

A stream ripper would be the Easy way, and probably the Right way, but if you want to do it the Programmer way....

  • Most development machines have quite a bit of RAM. Are you SURE you can't spare 675 MB?
  • Rather than store the output in a buffer can't you store it in a file or files(s), say an hour at a time? (essentially, you would be writing your own stream ripper)
  • Convert the stream to a lower bitrate, if you can tolerate the loss in quality