I'm trying to record the output of my speakers, but when I do this, it also records from the microphone. I'd like to only record the non-microphone devices.


$ (AUDIODEV=hw:0,0; rec test.mp3)    
$ rec -d hw:0,0 test.mp3

I've also tried ffmpeg:

$ ffmpeg -f alsa -i hw:CARD=PCH,DEV=0 test.mp3
$ ffmpeg -f alsa -i front:CARD=PCH,DEV=0 test.mp3
$ ffmpeg -f alsa -i surround40:CARD=PCH,DEV=0 test.mp3

I've seen elaborate things such as:

$ parec -v -d analog-output-speaker | sox -t raw -e signed-integer b 16 -r 44100 -c 2 test.mp3

Proposed online, but this still records the mic, and comes with obsolete sox options.

How can I record only non-mic input in ubuntu 14.04+ ?

  1. Check for available sources

    $ pactl list short sources
    0   alsa_output.pci-0000_00_05.0.analog-stereo.monitor  module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
    1   alsa_input.pci-0000_00_05.0.analog-stereo   module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
  2. Specify the monitor device as input for recording command.

    • Using avconv/ffmpeg

      Install it (only for avconv)

      sudo apt-get update
      sudo apt-get install libav-tools

      Record using:

      avconv -f pulse -i alsa_output.pci-0000_00_05.0.analog-stereo.monitor test.mp3


      ffmpeg -f pulse -i alsa_output.pci-0000_00_05.0.analog-stereo.monitor test.mp3

      AFAIK, Ubuntu install only one tool the other just alias (after, libav was forked from ffmpeg)

      $ file /usr/bin/avconv 
      /usr/bin/avconv: symbolic link to ffmpeg
    • Using sox

      Install the needed formats

      sudo apt-get install libsox-fmt-pulse libsox-fmt-mp3

      or this to install all formats

      sudo apt-get install libsox-fmt-all

      Record using:

      sox -t pulseaudio alsa_output.pci-0000_00_05.0.analog-stereo.monitor -t mp3 test.mp3
| improve this answer | |
  • 1
    Do you happen to know the ffmpeg equivalent? – Mittenchops Oct 9 '16 at 23:37
  • @Mittenchops, As I tested it (but in 16.04) it's the same. ffmpeg -f pulse -i alsa_output.pci-0000_00_05.0.analog-stereo.monitor test.mp3 – user.dz Oct 10 '16 at 5:08

This method shows how to record whatever audio is playing on your computer, similar to recording "stereo mix" in windows. This makes recording audio played by any application, including flash videos, possible.

I'm using the Sound Recorder application that comes in standard Ubuntu installations. To set this up using other programs (like Audacity) just substitute it in these instructions.

  1. Install pavucontrol (PulseAudio Volume Control) using apt-get or the Ubuntu Software Center.
  2. Open PulseAudio Volume Control. It should be in the applications menu under Sound and Video.
  3. Open Sound Recorder and start recording. Playing any sound at this point would be helpful, as your level indicator should react once you have finished.
  4. Go to the "Recording" tab in the PulseAudio Volume Control window.
  5. Make sure that "Applications" is selected in the drop down menu on the "Recording" tab.
  6. Choose "Monitor of Internal Audio Analog Atereo" from the "Record Stream from" menu in the Sound Recorder entry of the application list.

This appears to be persistent so that you will only have to do this once, but you will have to repeat these steps to record in another application.

All credit for this answer goes to this post.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.