Fedora 11 : Recording Audio from Pulseaudio using pacat (a.k.a. parec) and sox

To record audio, for example, from a Firefox/Flash-based application, running on Fedora 11, the following command seems to work:

pacat --record | sox -t raw -r 44100 -s -L -b 16 -c 2 - "output.wav"

Installation and usage instructions after the break…

The “pacat” command is the pulseaudio command-line audio recording/playback utility.  In this instance, it is being used to “–record” from the default source (this can be changed, if needed, using additional command-line parameters).

The “pacat” command defaults to exporting “raw” formatted data, which must then be converted to a valid wave file using the “sox” utility.

The “sox” utility is part of the “Sound eXchange” utility for linux, which is a “swiss-army-knife” multi-use application.  In this case, it is being used to convert the raw output from pacat to the more traditional 44K,16bit, Stereo WAV file that is ubiquitous in PC computing.

This can be further converted to an MP3, but how to do so is beyond the scope of this document at this time.

Installation:

To install the pacat utility (part of pulseaudio-utils):

#yum install pulseaudio-utils

To install the sox utility:

#yum install sox

Advertisements

One thought on “Fedora 11 : Recording Audio from Pulseaudio using pacat (a.k.a. parec) and sox

  1. I have copied recordwhatyouhear.sh and modified it as follows. This records in flac and is run directly from a terminal (any, not just xterm).
    Dependencies are now flac and pulseaudio. Perhaps somebody will find this useful.

    #!/bin/bash
    TIME=$(date +%Y.%m.%d.%H.%M.%S)
    OUTPUTFILE=~/pulseaudio_audio_out-$TIME.flac
    MONITOR=$(pactl list | grep -A2 ‘^Source #’ | grep ‘Name: .*\.monitor$’ | awk ‘{print $NF}’ | tail -n1)
    echo “Recording to $OUTPUTFILE, press Ctrl-C to stop …”
    parec -d “$MONITOR” | flac –endian=little –sign=signed –sample-rate=44100 –bps=16 –channels=2 -o $OUTPUTFILE –

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s