Ripping streams with mplayer and ffmpeg
Audio streams cannot be "saved" in the usual sense, because the full content of the file is not available all at once. In many cases it is possible to extract an .mp3 file if you have some patience and are willing to do the investigative work.
Take KCRW's Morning Becomes Eclectic archive. They provide only the streaming content of past shows. That's not something you are going to load on your iPod, or in my case iRiver T10.
I wanted to get it the (non-streamed) audio content of a recent show featuring "Air". The examination of the HTML source reveals a snippet of Javascript containing these URLs...
var fmts = {'QuickTime': 'http://media.kcrw.com/audio/qt/mb071121Air',
'RealAudio': 'http://media.kcrw.com/audio/real/mb071121Air',
'WindowsMedia': 'http://media.kcrw.com/audio/wm/mb071121Air'};
By fetching the link associated with RealAudio I find another pointer which looks like this (note it is the 2nd URL reference, the first being an intro track).
<audio src="http://play.rbn.com/?url=livecon/kcrw/g2demand/mb/mb071121Air.rm&proto=rtsp&?title=Air&author=Morning Becomes Eclectic hosted by Nic Harcourt©right=Wednesday, November 21, 2007 KCRW.com"/>
Again, I fetch the URL shown and (almost done!) it reveals an rtsp:// style link which is the meat and potatoes of what I need.
rtsp://rxn-rbn-sea05.rbn.com/farm/*/livecon/kcrw/g2demand/mb/mb071121Air.rm?author=Morning
Becomes Eclectic hosted by Nic Harcourt©right=Wednesday, November 21, 2007
KCRW.com&title=Air
After stripping off the disposable query string elements, this can now passed to mplayer and ffmpeg for processing.
mplayer -dumpstream "rtsp://rxn-rbn-sea05.rbn.com/farm/*/livecon/kcrw/g2demand/mb/mb071121Air.rm" -dumpfile air-stream.dump
ffmpeg -i air-stream.dump mb071121air.mp3
Now the mplayer capture of the stream will take as long as the stream itself. The dump in this case is in RealMedia format and is 11.6MB in size. The ffmpeg command converts it into a file mb071121air.mp3 is a MPEG ADTS, layer III, v1, 64 kBits, 44.1 kHz, JntStereo MP3 file, 17MB in size.
I am not (yet) sure whether this will work with the other variants shown above (WindowsMedia and QuickTime).
A re-examination of the conversion shows the reason for the size increase. Apparently the input bit-rate of 44 kb/s was of lower-quality than the output rate of 64 kb/s. This can likely be fine-tuned for future conversions if ffmpeg allows it.
Input #0, rm, from 'air-stream.dump':
Duration: 00:36:07.1, start: 0.000000, bitrate: 44 kb/s
Stream #0.0: Audio: cook, 44100 Hz, stereo, 44 kb/s
Output #0, mp3, to 'mb071121air.mp3':
Stream #0.0: Audio: mp3, 44100 Hz, stereo, 64 kb/s



1 Comments:
Seems bitrate can be retained using -ab 44 argument to ffmpeg but only works using .ogg output.
Post a Comment
Links to this post:
Create a Link
<< Home