Skip to content

Awesome ways to save audio streams for future listening

For a start, you can use mplayer to save the stream to a local disk:

mplayer -bandwidth 10000000000 -cache 32 -dumpstream -dumpfile output_file.ra 'rtsp://some.server/some_stream'

The huge bandwidth parameter will make sure that no throttling happens (at the client side anyway) — i.e. you can download hours of audio in a few seconds.

The dumpstream parameter writes the stream out byte-for-byte in the format it arrives in, e.g. RealAudio in the example above. But you can use ffmpeg to decode a RealAudio stream into a wav, and lame to re-encode it as an mp3, on-the-fly:

ffmpeg -i output_file.ra -f wav - | lame - output_file.mp3

N.B. That can be quite processor-intensive, but hey, what’s dual-core for??

ffmpeg will tell you what the bitrate of the stream is, so you can use lame’s -b switch to make sure you’re not re-encoding it at a vastly higher quality than it’s actually capable of.

e.g. for spoken word:

ffmpeg -i output_file.ra -f wav - | lame -b 64 -f - output_file.mp3

(-f = fast mode, slightly quicker encoding for less quality per bit)

Or if you’re feeling especially boffiny, use a named pipe so you don’t have to save the original stream to the hard disk:

… which is apparently possible but I haven’t got it to work yet. If you know how, leave a comment before I figure it out :-)

Andrew.

Share/save this page:
  • email
  • Print
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Reddit
  • StumbleUpon
  • Technorati
  • DZone
  • Slashdot
  • Fark
  • Facebook
  • MySpace
  • LinkedIn
  • Live
  • connotea

Post a Comment

Your email is never published nor shared. Required fields are marked *