How to capture audio streams?
February 18, 2006 8:26 AM   Subscribe

Does anyone know a command line program that will dump real media and/or windows media audio streams to a file (on a windows PC)?

I've been trying to do this using mplayer, but there are two problems..

1 - It's unreliable on some real media streams, and i can't get it to work with Windons Media files at all.
2 - I can only get it to work by dumping wav files to disc, not the original files.

Ideally, I'd like something that dumps the original ra/wma file to disc, which I could would then be able to convert to wav/mp3 manually. It's got to be command line, as I need to be able to schedule it.

I'm got a download manager (reget) that I can use to dump Windows Media files to disc, but it's not command line. A command line download manager might be of some use to me..

All suggestions welcome!
posted by ascullion to Computers & Internet (15 answers total) 2 users marked this as a favorite
I use Total Recorder. The Standard version doesn't have a command line, but the other two do. All three versions can schedule recordings however, so you might be able to do with just Standard. Only works for audio streams. (Anyone know of a program that will record streaming Real and Windows Media video files?)
posted by longdaysjourney at 8:59 AM on February 18, 2006

posted by noahv at 9:20 AM on February 18, 2006

The thing with MPlayer is that it has a hard time following redirects. Usually an embedded media stream will be something like You can use wget to get this file. Open it with a text editor, or just use the 'type' DOS command to display it. It will have a URL embedded in it like mms://blahblahblah or rtsp://blahblahblah. This is what you should feed into MPlayer:

mplayer -dumpstream -dumpfile out.wmv mms://blahblahblah
mplayer -dumpstream -dumpfile out.rm rtsp://blahblahblah

That's for video; you can substitute .wma and .ra for audio.

I think MPlayer can follow these redirect files automatically, but I'm not sure what options to give it.
posted by zsazsa at 10:15 AM on February 18, 2006

Best answer: Aha, this should work for the automatic redirecting:
mplayer -dumpstream -dumpfile out.wmv -playlist
posted by zsazsa at 10:19 AM on February 18, 2006

I've used ASFRecorder with some success in the past, but mplayer is probably better.
posted by majick at 10:21 AM on February 18, 2006

Best answer: mplayer will dump RealMedia audio and video RTP streams.

usually, you'll see a .ram file for streaming. This is actually a text file.

Download the ram, and open in a text editor.

You'll see a url using the rtsp protocol, followed by a bunch of other stuff, e.g,

Note that Real doesn't actually use the rstp protocol, but a proprietary protocol named rtp. However, the rtp stream is given using the rstp protocol name. This is significant, because there are other programs that will handle actual rstp streams but not, ahem, "Realâ„¢" streams.

mplayer will handle the rtp.

First, ensure that you can actual just play the stream, by starting mplayer with the url. You'll have to quote the url; if you don't, your shell will probably interpret parts of the url differently than you want:

mplayer "rtsp://,554,7070"

If this works -- mplayer should pop up a viewing window and you should see and hear the stream --, kill it (with Ctrl-C) and restart mplayer to dump the file. This commandline ought to work, although you might need to add a "-dumpstream" before the url:

mplayer "rtsp://,554,7070" -dumpfile ""

Note that mplayer will also allow you to dump the audio or video stream separately.

Also, RealMedia streams can dynamically change their quality depending on your available bandwidth. I don't know how to specify a size/quality setting to mplayer. In my plinking around, mplayer seem to dump a file four times the size, and higher quality than, StreamBox VCR, which will also rip Real streams. (But Streambox is no longer (legally) available, and tends to hang, requiring manual restarts of the download.)

Converting the dumped file.

mencoder will convert the dumped rm file to a variety of formats, but will not convert to a format viewable on a video iPod.

ffmpeg will, supposedly, convert to an h264 format viewable on an iPod. I've not gotten this to work. Some proprietary GUI applications will successfully do the conversion; I've been using the "Jodix Free iPod Video converter" which works well enough but makes me suspicious because it's not open source.
posted by orthogonality at 10:34 AM on February 18, 2006

Response by poster: Thanks for all the responses. Audacity and Total Recorder don't do what I need, which is to dump the original file without being played through the sound card.

I know about the need to give mplayer the actual URL of the stream, rather than the URL of the redirect file. What I find is that one of three thigns happens..

1 - the file records properly
2 - the file sounds very strange at the end (possibly because of the bitrate of the original file changing)
3 - mplayer stops 'recording' before it should

the other problem with mplayer is that you can't give it a time limit - ie, tell it to record for 600 seconds. You can give it a number of frames, but the length of a frames seems to vary from stream to stream.

orthogonality, for what it's worth, though slightly off-topic, I've been able to get ffmpeg converting video to use on my video ipod.

here's the code to encode a 4x3 file (two passes, so two lines of code - put in a batch file)

(there's some variables in this, hope it's obvious what they mean)

ffmpeg.exe -y -maxfr 30 -i "%location%\%~1.mpg" -pass 1 -passlogfile "C:\videoripping\ffmpeg\logs\%~1" -bitexact -vol 256 -vcodec xvid -s 320x240 -qscale 7 -acodec aac -ac 2 -ab 80 -f mp4 "%ipodlocation%\%~2\%~1.mp4"

ffmpeg.exe -y -maxfr 30 -i "%location%\%~1.mpg" -pass 2 -passlogfile "C:\videoripping\ffmpeg\logs\%~1" -bitexact -vol 256 -vcodec xvid -s 320x240 -qscale 7 -acodec aac -ac 2 -ab 80 -f mp4 "%ipodlocation%\%~2\%~1.mp4"

This will change a 16:9 file to a 4:3 file for use on an ipod

ffmpeg.exe -y -maxfr 30 -i "%location%\%~1.mpg" -pass 1 -passlogfile "C:\videoripping\ffmpeg\logs\%~1" -bitexact -vol 256 -vcodec xvid -croptop 0 -cropbottom 0 -cropleft 94 -cropright 96 -s 320x240 -qscale 7 -acodec aac -ac 2 -ab 80 -f mp4 "%ipodlocation%\%~2\%~1.mp4"

ffmpeg.exe -y -maxfr 30 -i "%location%\%~1.mpg" -pass 2 -passlogfile "C:\videoripping\ffmpeg\logs\%~1" -bitexact -vol 256 -vcodec xvid -croptop 0 -cropbottom 0 -cropleft 94 -cropright 96 -s 320x240 -qscale 7 -acodec aac -ac 2 -ab 80 -f mp4 "%ipodlocation%\%~2\%~1.mp4"

Now, back to dumping streams :)
posted by ascullion at 11:54 AM on February 18, 2006

Response by poster: zsazsa, thanks for the playlist option, didn't know that - will try it out
posted by ascullion at 11:54 AM on February 18, 2006

Response by poster: I've had a go at what orthogonality suggested above

The rm file is created, but realplayer won't play it... that may not be a problem, as I'll be using mplayer to convert it anyway.. I'll give this a few more tests and let you know how I get on. Thanks a lot.

Other suggestions still warmly welcomed!
posted by ascullion at 12:09 PM on February 18, 2006

If RealPlayer won't play it, that's a problem.

Make sure you have the latest Real codecs. of course, you DO NOT want to install Real, because it's full of crap that's essentially spyware.

So install RealAlternative instead (which also installs Media Player Classic, which is good to have). Then try playing the file in MPClassic.

And thanks for the ffmpeg info.
posted by orthogonality at 2:11 PM on February 18, 2006

Response by poster: I should have said.. the ffmpeg only works with the original ipod video firmware
posted by ascullion at 2:25 PM on February 18, 2006

Wait, 1.1 firmware is less functional than 1.0???? Crap.
posted by orthogonality at 3:16 PM on February 18, 2006

Response by poster: Well.. the 1.1 firmware makes it so the ffmpeg files stop playing after about 20 seconds. God knows why.. I went straight back to 1.0, as you can imagine.

There are supposedly some performance improvements with 1.1, but nothing else I'm aware of.
posted by ascullion at 3:32 PM on February 18, 2006

This question gets asked every few weeks on AskMe.
posted by meehawl at 8:10 PM on February 18, 2006

Response by poster: With respect, my question was very specifically about command-line tools - I couldn't find another question about that.
posted by ascullion at 1:56 AM on February 19, 2006

« Older Making medical treatment preferences known   |   How does an 18-year-old with no credit history get... Newer »
This thread is closed to new comments.