Recording sound and audio streams: radio, VOIP, anything

I recently found myself needing to record the sound coming from a program such as a VOIP or SIP client. Unlike Windows, which has specialized apps to record any and all sound output, in linux you have to work a bit harder.

In Windows, to record from Skype you can use the MP3 Skype Recorder which is freeware (link below). To record a SIP / VOIP session, X-lite can be used and it is also free - covered in our first VOIP from scratch episode. Finally, to record Internet radio (streaming), one can use VLC or simply RadioSure (link below), which will also name the recorded file. Some claim success with Audacity as well (a free, open source audio editor) by choosing in the program WaveOUT as the source of the recording in the program and making sure it's not muted in the Windows Audio Properties. Other such freeware programs are Freecorder, HardDiskOgg (OSS, recommended), MP3DirectCut (links below).

legal or not?

It is worth noting that even in the event that you manage to get the technical aspects of recording working, you should also look at the legality. Some countries, such as Canada, Finland, UK, USA are one party notification jurisdictions. This means that at least one participant in the conversation must know that the recording is taking place. Even then, the recording cannot be used for any purpose - that requires more disclosure / notification. Other jurisdictions require two party notification, such as Germany and the following states:

  • California
  • Connecticut
  • Florida
  • Illinois
  • Maryland
  • Massachusetts
  • Michigan
  • Montana
  • Nevada
  • New Hampshire
  • Pennsylvania
  • Washington
Accepted forms of notifications, as defined by FCC, are:
  • Prior verbal or written consent of all parties to the telephone conversation.
  • Verbal notification before the recording is made. (This is the most common)
  • An audible beep tone repeated at regular intervals during the course of the call.

It is increasingly becoming an offense to record something protected by copyright and also with an encryption scheme, via Intellectual Property laws inspired by the infamous DMCA and imposed on an unsuspecting public via ACTA.

linux world

In Linux, certain methods work depending on the configuration of your Ubuntu sound (Alsa vs Pulse Audio). This includes both the free, multiplatform Audacity and the excellent Ubuntu Sound Recorder (found in Applications -> Sound and Video -> Audio Production). Though an X-lite version exists for Linux, it is older (2, as opposed to 3 for Windows) and does not have the record feature. For Skype, the Free MP3 Recorder only works in Windows. Some of the Windows methods could be made to work using Wine, but that is not what a Linux user wants, generally.

quick recording

The quickest way to record whatever is played in your speakers / headphones is to install, then call the following script.

$ wget http://outflux.net/software/pa-clone
$ chmod u+x pa-clone
$ ./pa-clone output.wav

This installs the following script:

#!/bin/bash
# Copyright 2008-2009, Kees Cook <kees@outflux.net>
# Records the PulseAudio monitor channel.
# http://www.outflux.net/blog/archives/2009/04/19/recording-from-pulseaudio
#!/bin/bash
WAV="$1"
if [ -z "$WAV" ]; then
    echo "Usage: $0 OUTPUT.WAV" >&2
    exit 1
fi
rm -f "$WAV"

# Get sink monitor:
MONITOR=$(pactl list | grep -A1 '^\*\*\* Source #' | \
    grep '^Name: .*\.monitor$' | cut -d" " -f2 | tail -n1)

# Record it raw, and convert to a wav
echo "Recording to $WAV ..."
echo "Close this window to stop"
parec -d "$MONITOR" | sox -t raw -r 44k -sLb 16 -c 2 - "$WAV"

This script requires that you specify the output file and will save as a wave file. It can be further enhanced by  with auto-filename and space-saving encoding (either ogg or mp3):

# set timestamp for filename
TIME=$(date +%d-%b-%y_%H%M-%Z)
# use it in script by modifying the respective line
parec -d "$MONITOR" | sox -t raw -r 44100 -sLb 16 -c 2 - ~/Taped_Recording_$TIME.wav
# Converts the WAV file to OGG then deletes the WAV.
echo "Captured. Converting to a compressed format, please be patient..."
sox ~/Taped_Recording_$TIME.wav ~/Taped_Recording_$TIME.ogg
rm ~/Taped_Recording_$TIME.wav
# it should be possible to save (convert) with sox directly into mp3 or ogg

schedule stream recording

Recording a stream can be scheduled, as explained in suffman's instructable. The following is Matthew L. Beckler's version:

#!/bin/bash
# Save streaming audio to an mp3 file. Requires lame.
# This script will record for the duration entered below.
# Customize the stream URL, duration, filename, and working directory.
# 
# Written by Matthew Beckler (matthew at mbeckler dot org)

STREAM="http://1.2.3.4:8140"
DURATION="1:30:00"
DATESTR="$(date +%Y-%m-%d)"
# Don't include .wav or .mp3 at the end of the variable below:
FILENAME="Stream_dump_$DATESTR"
WORKINGDIR="/data/pub/audio/podcasts/"

cd $WORKINGDIR
rm -rf $FILENAME.{wav,mp3}
mplayer $STREAM -endpos $DURATION -vo null \
    -ao pcm:waveheader:file=$FILENAME.wav &> /dev/null
lame $FILENAME.wav $FILENAME.mp3 &> /dev/null
rm -rf $FILENAME.wav

This script will need to be scheduled with cron or, if you prefer visual cues, try kcron.

sip voip linux clients

I was unable to find any free client under linux that will record conversations in my previous review of softphones. They are:

Those without links are available from the main repositories. To install the SFLphone repository:

sudo add-apt-repository ppa:savoirfairelinux
sudo apt-get update
sudo apt-get install sflphone-client-gnome

Enjoy and keep it legal! :)

Sources / More info: skype-rec, radiosure, harddiskogg, mp3DirectCut, freeCorder4, wiki-voip, wiki-tel-rec, fcc-rec, rec-data, on-rec, wiki-destreaming, ACTA, stream-rec, schedule-rec-streaming, pa-clone-script, pulse-sink-outflux, beckler-scripts, yt-snd-rec

Comments

Rares Cojocaru said…
Pamela(I hope I wrote correctly) works if I want to record a radio show?I understand that it works indeed on Skpe.
Rares Cojocaru said…
Hi.I've just recorded one melody for testing Radio Sure and it's sounds grate.Thank you :)

P.S. Now I've got to find through all "Digital Imported" radios the one who broadcast A State Of Trance thursday evening.

Greetings from Ro.
Miuka said…
Thanks a lot! I used a lot of recording calls tools but I prefer IMCapture for skype
for recording skype calls because it's very easy-to-use and functional program. I found it in imcapture/com.
zamolxis said…
Sadly, the program you're suggesting costs money. I suggested voipcallrecording because, along with its excellent quality, is free of charge and easily records Skype conversations in stereo.
InBonobo said…
Digitally Imported is not bad, but my fav is Soma FM - they're ze best! :)
InBonobo said…
As far as I know, Pamela works, but only on Skype. I've never used it
because it's not free and the "Free MP3 Advanced Call Recorder" works
perfectly with Skype and it is free (but only in Windows, obviously; it
might work in Linux with Wine, but I'm not sure).

If you want to record radio, use Radio Sure, as it will also correctly name
(and separate) the songs. The links are in Sources.
InBonobo said…
Other linux recorders: jitsi, homer and Oreka
Eugene said…
I guess MX Skype Recorder is also a very good option
http://skyperec.com/
Hope you'll like it!

Popular posts from this blog