Tips for recording audio streams

From: Robert Glueck (
Date: 10/08/05

Date: Sat, 08 Oct 2005 00:46:56 -0400

In response to the thread "Recording streaming audio" from
10/02/05 I spent some time experimenting with ways of
recording streaming audio from the Internet on a Linux box.
  Here's what I've learned.

If you want to record streaming audio from a source on the
Internet for which you have a URL (e.g. an http or rtsp
link) you can accomplish that with MPlayer, realcap or

1. MPLAYER is an up and coming multimedia player that's
loaded with features but is not always easy to install
correctly. You can use it on the command line or from
within its GUI. You will also need to download codecs for
playing a variety of different audio formats, e.g. the
"essential" codecs set from

Example (all one long line):

mplayer -noframedrop -dumpfile out.rm -dumpstream

This records the audio stream linked to in RealAudio format
in the file out.rm in your current working directory (cwd)
until you exit the program (ctrl-Z).

2. REALCAP is a bash shell script that allows you to capture
an audio stream from RealPlayer to a file in wav, ogg or mp3
format, with various options for sampling rates and audio
quality. To exploit its functionality fully you should have
realplay, vsound, lame and oggenc installed. You can get
realcap from . You can
put it in /usr/local/bin.

Example (all one long line):

realcap -c 60 -m 48 -a NPR -t Knuth -d

This command uses vsound and lame to write about half a
minute of this stream at 48 kbps in mp3 format to the file
vsound.mp3 in your cwd (after first idling for some 30 secs
due to connect and buffering time).

3. STREAMTUNER is an internet audio stream directory browser
with GUI that allows you to easily access thousands of audio
streams from Internet radio stations and from other audio
sources on the Internet. It has a "record" option that will
capture the audio stream you're listening to in ogg format.
  This option requires the presence of Streamripper which is
a separate command line program (you may have to install it
separately). Streamtuner/Streamripper rips shoutcast and
icecast compatible audio streams to separate subfolders in a
folder in your home dir that will be named after the audio
source you're ripping (e.g. the radio station).

STREAMRIPPER is the utility that rips the online audio
stream to individual ogg files. You can also use it
stand-alone on the command line, e.g.


This command will rip all the songs played to separate
tracks in ogg format until you kill the program.

If you want to record streaming audio from a source on the
Internet for which you don't have a URL (i.e. direct stream
recording), you can use arecord, rawrec/rawplay or Krecord.

4. ARECORD records audio files using the ALSA sound system, e.g.

arecord -f cd -t wav -d 45 -D hw:0,0 capture.wav

This command records 45 sec of the currently playing audio
stream in CD quality in wav format to the file capture.wav
in your cwd. You can play back that file e.g. with RealPlayer.

arecord -f cd -t wav -d 45 -D hw:0,0 | lame -m s --bitwidth
16 -s 44.1 - - | cat > `date +%d%b%y%H%M%S`.mp3

This command records 45 sec of the currently playing audio
stream as above, then pipes it to lame to encode it in mp3
format and writes it as a date&time-stamped mp3 file to your
cwd. Play it back with xmms or RealPlayer.

5. RAWREC/RAWPLAY is a buffered raw audio recorder/player, e.g.

rawrec -t 30 capture.raw

This command records 30 sec of the current audio stream in
raw audio format to the file capture.raw in your cwd. You
can play it back with the command "rawplay capture.raw".

rawrec -t 30 | sox -t sw -r 44100 -c 2 - -t cdr capture.cdr

This command records 30 sec in raw audio and then uses sox
to convert it to a CD quality cdr file. You can play that
back with sox or convert it to something else.

6. KRECORD is a program for recording anything that goes
through your DSP (the digital signal processor on your
soundcard). It's part of the KDE suite and has some nice
features such as an input level indicator and a frequency
spectrum display. The former is very handy for setting the
proper record input level with the "Capture" slider in the
alsamixer console.

To direct record audio, open a new file buffer, give it a
name with .wav extension, save it, then press the record
button. You can watch the record level in the "input level"
window. When done, press stop and play back the file e.g.
with RealPlayer.

7. AUDACITY is a full-fledged audio editor with a rather
complex interface. I have little experience with it. It
has a "record" button which I presume allows you to capture
in raw audio format whatever audio goes through the
soundcard. In fiddling around with this program for a brief
length of time, I did manage just once to accomplish just
that. But the recording was horribly distorted, and I just
don't remember how I got there.

An essential prerequisite for all of this to work is to set
up your sound mixer properly. This can be done with the
command line utility ALSAMIXER (I use v.1.0.8). It's
probably installed in your distro by default. Alsamixer
seems to work reliably whereas Kmixer, a KDE program that's
designed to do the same thing in a GUI, doesn't always seem
to be reliable, i.e. changes you make in Kmixer don't always
seem to jive with the settings shown in the alsamixer
display. The latter is probably more trustworthy.

In the alsamixer console you can toggle "View" with the tab
key, navigate between devices with the forward and backward
keys, turn capture on and off with the space bar, toggle
muting with the "m" key and change slider settings with the
up and down keys.

The mixer setting that I've found to work for direct stream
recording with arecord, rawrec etc. has "Capture" and "Mix"
turned on to CAPTUR and "Capture" set to about 60%. All
other adjustable sliders are set to about 70% save for
"Headphones" (100%). "PCM" definitely must be on, i.e. not
muted, whereas for recording the other devices may or may
not be muted.

Once you have sound playing through your soundcard, you can
use the input level meter in Krecord to check the record
level in db (use the log option) while you're adjusting the
alsamixer sliders and switches. A setting with the moving
horizontal bars being red much of the time (i.e. the peak
mostly being between -10 and 0 db) seems to work fine.

I'm using the Intel 82801DB-ICH4 AC'97 Audio Controller
which is integrated into the motherboard and uses the
AD1981A sound chip. With other soundcards the alsamixer
console may show device names other than "Capture" and
"Mix"; in this case turn on capture for "AC'97" and "AC'97
Cap" and turn up the latter's slider.

Good luck,