Results 1 to 6 of 6

Thread: Playing with Webcam USB mic

  1. #1
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,429
    Blog Entries
    34

    Default 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:
    Code:
    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 :
      Code:
        --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 recording
    Now "-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:
    Code:
    arecord -l
    the USB mic section of the output was:
    Code:
    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 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:
    Code:
    arecord -D hw:1,0 -d 5 test.wav
    which gave me the error (with no recording):
    Code:
    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:
    Code:
    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 !!

  2. #2
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,429
    Blog Entries
    34

    Default Re: Playing with Webcam USB mic

    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:

  3. #3
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,429
    Blog Entries
    34

    Default Re: Playing with Webcam USB mic

    A short video clip ... illustrating success: YouTube - recording with USB mic using gucview

  4. #4
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,429
    Blog Entries
    34

    Default Re: Playing with Webcam USB mic

    Quote Originally Posted by oldcpu View Post
    In short, I have it working with 'arecord'. The command line I used for a short 5 second recording is:
    Code:
    arecord -f cd -D hw:1,0 -d 5 test.wav
    I forgot to mention, the Logitech HD Pro Webcam C910 I used for the above (from 'lsusb') is a UVC compliant webcam:
    Code:
    Bus 002 Device 002: ID 046d:0821 Logitech, Inc.

  5. #5
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,429
    Blog Entries
    34

    Default Re: Playing with Webcam USB mic

    Quote Originally Posted by oldcpu View Post
    I had previous tried to get the USB mic working under Linux with my old Phillips Webcam, and I failed miserably.
    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:
    Code:
    Bus 003 Device 002: ID 0471:0311 Philips PCVC740K ToUcam Pro [pwc]
    and when I type:
    Code:
    arecord -l
    I get:
    Code:
    card 2: U0x4710x311 [USB Device 0x471:0x311], device 0: USB Audio [USB Audio]
      Subdevices: 0/1
      Subdevice #0: subdevice #0
    So I successfull tried:
    Code:
    arecord -f cd -d hw:2,0 -d 5 testwebcammic.wav
    The above worked !!

    ... 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)


    Setting-2 (I'm not 100% certain this was necessary, but without it I do not believe the recording was working):


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

  6. #6
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    18,913
    Blog Entries
    14

    Default Re: Playing with Webcam USB mic

    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.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •