One of the great things about Linux is that it's an open platform, so you can get round stupid DRM nonsense. The BBC produces lots of great stuff in real media format, but some of it isn't made available to people outside the UK. I want to review some of this material, and I want my review to be available outside the UK.
So, I need to take some of the audio from a RealPlayer stream and store it as MP3.
Before you start...
The first thing to do is turn on the capture channel on my soundcard. Fire up gnome-alsamixer, turn on the capture channel, and set the volume to something sensible. (Originally I set the volume to maximum, but I ended up with the level way too high.)
Record the stream
Next, start recording into a .wav file:
arecord -f cd -t wav -D hw:0 rawsample.wav
If you have more than one soundcard on your machine, you may have to set the device (-D) to something other than hw:0.
Then play the sample on RealPlayer. You will hear it through your speakers, and it will be recorded into the file rawsample.wav. When the piece has finished playing, stop recording by typing Ctrl-C.
Remove any silent lead in
You're rawsample.wav probably has a long silent lead in, since it takes time for RealPlayer to start playing a track. Use sox to trim off the silent lead in:
sox rawsample.wav sample.wav silence 1 0:0:0.01 -25d
The last parameter here is the silence threshold in decibels. You might have to adjust it, depending upon how quiet your recording it.
Now simply compress the file into an MP3 with:
lame sample.wav sample.mp3
What's that? You don't have lame? Hmm, well it's not included in most Linux distributions because of patent problems. However you can get the source from Sourceforge. If you are lucky enough to be using Debian, you can just add the following line to your /etc/apt/sources.list:
deb ftp://ftp.nerim.net/debian-marillat/ sarge main