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.


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

#yum install pulseaudio-utils

To install the sox utility:

#yum install sox

2 thoughts 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.

    TIME=$(date +%Y.%m.%d.%H.%M.%S)
    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 –

  2. With modern versions of sox, command given in this post will result in the error:

    sox WARN getopt: option `s’ not recognized
    sox FAIL sox: invalid option

    It looks like the fix is to replace `-s` with `-e signed`.

    (I’m assuming I can use markdown formatting here…if not, apologies for what is probably a poorly formatted comment.)

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 )

Connecting to %s