Recently, I've run into some internet radio programs that I want to timeshift. Using mplayer and lame, we can transcode from windows media or real audio to mp3 with the bash function below.

I wanted it to not write to disk (except for any buffering that mplayer or lame do), as shows can go for hours and that would imply having to use lots of unnecessary temp disk as even my laptop can "real-time" transcode audio at internet radio bitrates. The /dev/stdout trick may not be portable to non-linux systems.

# puts on standard out the mp3 of url's audio stream capture(){ url="$1" duration="$2" # seconds # for short captures, buffering gets you more than you expect mplayer="mplayer -really-quiet" from_pcm="${mplayer} -ao pcm:fast:file=/dev/stdout ${url}" to_mp3="lame -r -S - -" # assume that we can encode at line speed or faster ${from_pcm} | ${to_mp3} & sleep ${duration} kill %1 # safe as jobs not inherited from parent }

Were it mp3, one could skip transcoding and just dump it to disk for the duration of the show.