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.
Trying:
$ (AUDIODEV=hw:0,0; rec test.mp3)
$ rec -d hw:0,0 test.mp3I'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.mp3I'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.mp3Proposed 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+ ?
2 Answers
Pulseaudio
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 SUSPENDEDSpecify the monitor device as input for recording command.
Using
avconv/ffmpegInstall it (only for
avconv)sudo apt-get update sudo apt-get install libav-toolsRecord using:
avconv -f pulse -i alsa_output.pci-0000_00_05.0.analog-stereo.monitor test.mp3or
ffmpeg -f pulse -i alsa_output.pci-0000_00_05.0.analog-stereo.monitor test.mp3AFAIK, 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 ffmpegUsing
soxInstall the needed formats
sudo apt-get install libsox-fmt-pulse libsox-fmt-mp3or this to install all formats
sudo apt-get install libsox-fmt-allRecord using:
sox -t pulseaudio alsa_output.pci-0000_00_05.0.analog-stereo.monitor -t mp3 test.mp3
ALSA
Using ALSA directly, reference:
Check recording devices
arecord -lRecord (change the corresponding <card> and <device> index)
ffmpeg -f alsa -i hw:<card>,<device> test.mp3GUI tools
There are also some advanced GUI tools like: audacity.
5This 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.
- Install
pavucontrol(PulseAudio Volume Control) usingapt-getor the Ubuntu Software Center. - Open PulseAudio Volume Control. It should be in the applications menu under Sound and Video.
- 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.
- Go to the "Recording" tab in the PulseAudio Volume Control window.
- Make sure that "Applications" is selected in the drop down menu on the "Recording" tab.
- 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.