Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to capture sound card output and encode it in Vorbis ogg format using the following command:

arecord -f cd -t raw | oggenc - -r -o file.ogg

However, the computer's microphone input is recorded rather than the sound card output.

The output of the command arecord -l is

**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CONEXANT Analog [CONEXANT Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

The output of the command arecord -L is contained in this pastebin entry.

The arecord man page indicates that the input device can be selected using the -D flag, but gives no syntactical examples.

I would like to know how to change the input for arecord from the microphone to the sound card. I am not interested in GUI-based alternatives such as Audacity. Thanks.

Edit: I am running Debian 7.0 (stable) with arecord version 1.0.25, vorbis-tools version 1.4.0, and ALSA driver version 1.0.24.

share|improve this question
    
Does your hardware have some mixer control to route the output back to the capture device? –  CL. May 19 '13 at 8:37
    
@CL. The only pre-installed mixer that I am aware of is alsamixer. If I select the loopback card within alsamixer (F6 key to select sound card), I receive the message This sound device does not have any controls. If I exit the mixer and return, I find that the sound card is restored from loopback to the default card. Attempting to suspend (ctrl-z) and background (bg) the alsamixer process after selecting loopback does not enable successful recording of audio via the arecord command. –  user001 May 20 '13 at 4:15
    
The card selection in alsamixer does not affect the rest of the system; it just changes which controls are shown. What are the recording selection controls of the Conexant device? –  CL. May 20 '13 at 6:45
    
@CL. For my Conexant device, I have one playback control (Master) and one capture control (Capture) within alsamixer. The capture can be toggled on and off with the spacebar within alsamixer and it is on by default. Please let me know if this is not what you intended. Thanks. –  user001 May 20 '13 at 9:51
add comment

3 Answers 3

I'd suggest using the ALSA loopback driver. To load it:

sudo modprobe snd-aloop

This should add a new capture device to the output from arecord -L.

If you have only one physical soundcard in your computer, you can make the loopback soundcard the default for all apps by creating a file .asoundrc in your home folder with the following content:

pcm.!default {
    type hw
    card 1
    device 0
}

While this file is in place, any sound output from all applications should go to the loopback adapter rather than your actual speakers. Just specify the correct device in your arecord command and once you're done, remove the .asoundrc file to go back to normal.

share|improve this answer
    
Thanks for your suggestions. Despite creating .asoundrc in my home directory and restarting the terminal emulator session, audio is still directed to speakers. The arecord -f cd -t raw | oggenc - -r -o file.ogg command records nothing. Issuing arecord -l provides the same list as before, but with two additional lines for card 1: Loopback (devices 0, 1), each with 8 subdevices (#0-#7). Likewise, arecord -L added the following three lines: sysdefault:CARD=Loopback [newline] Loopback, Loopback PCM [newline] Default Audio Device. Continued in next comment due to character limit. –  user001 May 20 '13 at 3:56
    
Attemping arecord -f cd -t raw --device=sysdefault | oggenc - -r -o file.ogg records a blank audio file for the duration the command is executed (it does not draw audio data from the microphone as before). Unfortunately, sysdefault is degenerate as it is defined to be both CARD=PCH (first line of arecord -L) and CARD=Loopback (last line of arecord -L). Thanks for any follow-up suggestions you are able to provide. –  user001 May 20 '13 at 4:01
    
The loopback allows to record only what is played to its playback device, not to the sound card output. –  CL. May 20 '13 at 6:51
    
Sorry my answer didn't work - it works on my setup. I'd recommend taking a look at this explanation of the asoundrc file: alsa-project.org/main/index.php/Asoundrc I'm fairly sure if you try a few things and play around with different devices a bit more you should get it working. A bit of a kludge, but do you happen to have a physical 3.5mm->3.5mm cable? If so, you could always just connect your headphones output jack to the mic/line in jack. –  andrewthecoder May 20 '13 at 20:28
    
If you can't get it working with asoundrc, these links may provide more info to help figure it out: sabi.co.uk/Notes/linuxSoundALSA.html#tasksRecordPlay forum.vectorlinux.com/index.php?topic=7500.0 If you still can't get it working, you could switch to using PulseAudio instead of ALSA. This answer explains how to do this using PulseAudio: askubuntu.com/questions/171287/… –  andrewthecoder May 20 '13 at 20:30
add comment

Your hardware does not support capturing its output; once the data has gone into the actual playback device, it's gone.

You need to use some software that duplicates the audio data before it is written to the hardware.

I'd suggest using PulseAudio; there you can simply select one of its outputs as capture source: pavucontrol output monitoring

share|improve this answer
    
I installed pavucontrol and tried recording using gnome-sound-recorder. When I open gnome-sound-recorder and begin recoding (Ctrl-R), the stream appears in the PulseAudio Volume Control window. The stream does not actually record any data, however (the final length is 0:00). Also, are you familiar with how to perform the recording through command line instead of a GUI? Thanks . –  user001 May 21 '13 at 22:16
add comment
  1. Go to PulseAudio Volume Control -> Input Devices Tab. At the bottom, choose to show "ALL input devices". Check if "Monitor of Internal Audio Analog Stereo" is not muted and the volume going up and down as you play the audio!!

  2. Use Audio Recorder to record Audio Source = Internal Audio Analog Stereo (Audio Input). See screenshot below.

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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