Playing with Webcam USB mic

I put this in the “chit-chat” area, because I am not looking for help, and because I do not, by any stretch, know enough about this subject to write a How-To, and I most definitely do NOT know enough to answer questions on configuring some one else’s mic (which is invariably what happens if one writes a How To). So instead, I thought I would just write my experience in chit-chat.

I had previous tried to get the USB mic working under Linux with my old Phillips Webcam, and I failed miserably. I now have a newer Logitech HD Pro Webcam C910 that comes with a USB mic and I thought I would try with it.

Recording with a USB mic

In short, I have it working with ‘arecord’. The command line I used for a short 5 second recording is:

arecord -f cd -D hw:1,0 -d 5 test.wav 

**Detail: **

The first question I always have when I see some confusing Linux command line is, OK, sure it works, but what does it mean ??

If one types “man arecord” one gets an explanation of the arecord arguments that is very confusing with a zillion options, and so to save some effort I note:

  • -f
    :```
    –format=FORMAT
    Sample format
    Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE
    U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUB-
    FRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM
    Some of these may not be available on selected hardware
    There are also two format shortcuts available:
    -f cd (16 bit little endian, 44100, stereo -f S16_LE -c2 -r44100]
    -f dat (16 bit little endian, 48000, stereo) -f S16_LE -c2 -r48000]
    If no format is given U8 is used.

  - **-D**
 : --device=NAME, Select PCM by name
  - **-d**
 : duration (in seconds) - Interrupt  after # seconds.  A value of zero means infinity.  The default is zero, so if this option is omitted then the arecord process will run until it is killed. 
  - **test.wav**
 is where the audio is stored after recordingNow "-d" is easy, but the other two difficult.

At first, I struggled with "-D". How does one know what to put there?  I noted from the "man arecord" page, that I typed: 

arecord -l

 the USB mic section of the output was:

card 1: U0x46d0x821 [USB Device 0x46d:0x821], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Great, BUT that did not help me. :(  ... then I stumbled across this internet page:  [Linux: How to determine your audio card's, or USB mic's, maximum sampling rate - voxforge.org](http://voxforge.org/home/docs/faq/faq/linux-how-to-determine-your-audio-cards-or-usb-mics-maximum-sampling-rate) which told me to pay attention to the card# and the device#, which is "1" and "0" respectively. Ergo this is "**hw:1,0**" where "1" is the card, and "0" the device.

So I then tried (and failed) to get a 5 second recording:

arecord -D hw:1,0 -d 5 test.wav

which gave me the error (with no recording):

Recording WAVE ‘test.wav’ : Unsigned 8 bit, Rate 8000 Hz, Mono
arecord: set_params:979: Sample format non available

... Hmmm "sample format non available". Wav not available?  How sad !  So I looked again at the "man arecord" for formats, noting it stated "***Some of these may not be available on selected hardware***" and also noting it stated "***There are also two format shortcuts available***" "-f cd" and "-f dat". So I decided to try the first, and tried for a 5 second recording:

arecord -f cd -D hw:1,0 -d 5 test.wav


And it worked !

So there is no rocket science above.  Rather just the record of a humble Linux user trying to learn a command line function to get the mic on my new webcam working. And it works !!

I should also mention, that BEFORE I tried recording, I did go to kmix (my KDE mixer) and ensure my webcam was selected for recording. I set it up as noted below:
http://thumbnails35.imagebam.com/10463/4bd504104624284.jpg](http://www.imagebam.com/image/4bd504104624284)

A short video clip … illustrating success: https://www.youtube.com/watch?v=TvlvbhK609M)

I forgot to mention, the Logitech HD Pro Webcam C910 I used for the above (from ‘lsusb’) is a UVC compliant webcam:

Bus 002 Device 002: ID 046d:0821 Logitech, Inc.

I used this newly gained experience to successfully recorder audio with my old Phillips Webcam,which I noted had stumped me before in my efforts.

Some details for this second test … this Phillips webcam is a:

Bus 003 Device 002: ID 0471:0311 Philips PCVC740K ToUcam Pro [pwc]

and when I type:

arecord -l

I get:

card **2**: U0x4710x311 [USB Device 0x471:0x311], device **0**: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

So I successfull tried:

arecord -f cd -d hw:2,0 -d 5 testwebcammic.wav

The above worked !! :slight_smile:

… I confess I did not succeed immediately, because I had the mixer mis-configured. I was testing this on a laptop (the one you see in the back ground in the above video link) and this laptop has openSUSE-11.1 with Gnome, and I don’t know Gnome very well. Configuring the mixer in Gnome was a challenge. In the end to get Gnome to record with this mic I had to apply these two mixer settings:

Setting-1 (note the red arrow - that is the important setting)
http://thumbnails8.imagebam.com/10464/0fcc9a104635757.jpg](http://www.imagebam.com/image/0fcc9a104635757)

Setting-2 (I’m not 100% certain this was necessary, but without it I do not believe the recording was working):
http://thumbnails37.imagebam.com/10464/fcbddc104635759.jpg](http://www.imagebam.com/image/fcbddc104635759)

I confess I struggle with Gnome, and I am still very much a KDE user.

Thanks for sharing, Lee. I bookmarked this one, it’s a nice example of how to get things to work on linux. Nice to see you working on it in the video.