2011-11-20

Recording and archiving streaming radio

First store the stream to disk, which in case of an http stream can be done like this

$ mplayer -dumpaudio http://whatever/streaming.url

That should result in a file stream.dump, which in this case luckily comes directly in mp3 format

$ file /tmp/stream.dump
/tmp/stream.dump: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo

Since we're talking live recording here, we'll (hopefully) have provided for some buffer minutes at the beginning and at the end of the file which we need to get rid of now. So fire up the audacity sound editor (in case you're doing this on Fedora Linux make sure to install audacity-freeworld from rpmfusion over the regular audacity package which lacks mp3 support) and find the cue points. Of course you can also trim the stream and save it to a new file right there, but that would mean re-encoding. Not much of an issue but still it would be nicer to preserve the original stream.

So just note the cue points in audacity and head back to the commandline, this time we'll be using a tool by the name mpgtx from a package of the same name.

$ mpgtx -s /tmp/stream.dump [5:47-57:38] -o myrecording.mp3

Easy to tell, the actual program started 5 minutes 47 seconds into the stream, and went on until 57 minutes and 38 minutes. Whole-second precision is usually sufficient, but decimal seconds are also supported.

Finally, we'll want to tag our new file. I like to use eyeD3 (package name python-eyed3) for that:

$ eyeD3 -a "The artist" -t "The title" -G <genre> -Y <year> --add-image=/tmp/artist_pic.jpg:ARTIST: myrecording.mp3

To learn about the possible <genre>s, run "eyeD3 -l"; to see supported image types invoke as "eyeD3 --list-image-types". The term image type may be a bit confusing in this context, we're not talking JPEG vs. PNG but what is depicted (in the example it would be a picture of the performer).

No comments:

Post a Comment