how to specify capture audio device in VLC?

I need to capture from my webcam. It has a mic too.

I can specify video input device as /dev/video0.

I specified input audio device as /dev/dsp2 ( OSS device, corresponding to USB Webcam), Now VLC throws an error, “VLC is unable to open the MRL ‘alsa:///dev/dsp2’. Check the log for details”

Thinking it wants an alsa device, I specify device as /dev/snd/pcmC2D0c. (got it from kinfocenter and dolphin). Now again an error, “VLC is unable to open the MRL ‘alsa:///dev/snd/pcmC2D0c’. Check the log for details.”.

I try with any device, the same error. I have added myself to audio device so that I can read/write to the mentioned devices.

I see no way of switching VLC to use OSS. And I see no information (documentation on net) on it’s expected device listing for audio.

If I do not specify device, the default mic is used which is not good

How to specify audio device for VLC?

If you are not fixated on vlc, there are webcam applications that provide this capability (such as guvcview).

I provided in my (new) openSUSE blog a means of capturing video and audio of the entire desktop: Capturing video of one’s desktop - Blogs - openSUSE Forums

If you are using openSUSE-11.4 then rather than try to specify a device such as ‘alsa:///dev/dsp2’ you could you not simply specify ‘pulse’ ? You may need the application phonon-backend-vlc for this to work ( I’m not so sure on that ).

And you may need to install ‘pavucontrol’ (pulse audio volume control) so as to control the input/output of pulse audio. The ‘pavucontrol’ application provides superb control over the device/application direction in one’s audio which IMHO was only possible before with more advanced applications such as ‘jack’.

I have not tried to do with what you have attempted with vlc (because I have easier/better applications to do this). But if I do get arround to attempting it and succeed, I’ll post here.

Replying to my own post (?) < gulp … that’s a bit Freudian > I don’t think my blog entry will likely be of much help. Sorry. But when it comes to tuning pulse audio, you may find this thread of use: Looking (maybe) for audio mixer for use with Pulse Audio starting in post#4.

Ok, I took a look at this specific question, and I think it is straightforward and easy (once one knows how, and difficult if one does not know how - which is always the case. Sorry 'bout that! ).

Type in a terminal:


arecord -l

and pay attention to your hardware devices.

For example, on my PC I get:


**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device **0**: AD198x Analog [AD198x Analog]
  Subdevices: 3/3
  Subdevice #0: subdevice #**0**
  Subdevice #1: subdevice #**1**
  Subdevice #2: subdevice #**2**
card 1: U0x46d0x821 [USB Device 0x46d:0x821], device **0**: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

From that you can see my regular mic is “hw:0,0” and my webcam mic: “hw:1,0”.

So for my webcam mic I would put: hw:1,0

Check out that concept and see if it works.

I confess I do not know how to stream to a file with vlc (likely easy once one knows how).

Thanks oldcpu for such detailed help. It was useful

Yes, specifying audio device as ’ hw:x,y’ works in vlc. But when I specified my USB webcam Audio like that, it produces a harsh sound for a few seconds and then the sound dies in the capture. Also, inexplicable, vlc stops streaming after a few secs sometimes. Sometimes it works.

I tried wxcam which is an excellent application, small, compact. works very well, though I did not like having wxwidgets support for this application. It produces best sound, best picture.

With ffmpeg, I had no succes, however. I was disappointed for it’s failure. It complains like below.

[video4linux2 @ 0x80862e0] The V4L2 driver ioctl set standard(NTSC) failed
[video4linux2 @ 0x80862e0] Could not find codec parameters (Invalid Codec type -1)
[video4linux2 @ 0x80862e0] Estimating duration from bitrate, this may be inaccurate
/dev/video0: could not find codec parameters

The pixel format of the video from webcam is identified as YUY2 by vlc and YUYV by wxcam. Both capture it well. But this is not automatically recognised by ffmpeg. After I got the info from vlc, I changed my command line as,

ffmpeg --f rawvideo -pix_fmt uyvy422 -i /dev/video0 out.mpg
[IMGUTILS @ 0xbfc43cc4] Picture size 0x0 is invalid
[IMGUTILS @ 0xbfc43bd4] Picture size 0x0 is invalid
[rawvideo @ 0x80862e0] Could not find codec parameters (Video: rawvideo, uyvy422)
[rawvideo @ 0x80862e0] Estimating duration from bitrate, this may be inaccurate
/dev/video0: could not find codec parameters

ffmpeg -f video4linux2 -f rawvideo -pix_fmt yuyv422 -i /dev/video0 out.mpg
[IMGUTILS @ 0xbfc43cc4] Picture size 0x0 is invalid
[IMGUTILS @ 0xbfc43bd4] Picture size 0x0 is invalid
[rawvideo @ 0x80862e0] Could not find codec parameters (Video: rawvideo, yuyv422)
[rawvideo @ 0x80862e0] Estimating duration from bitrate, this may be inaccurate
/dev/video0: could not find codec parameters

But it does not stop complaining !! I do not know what I am missing. It seems to have support for this packed YUV compresssed format of raw video, but I accnot figure out what more to specify.

Thanks,

Are you certain its the audio capture causing the problem, and possibly not also the video ? What can you tell us about your webcam ? ie what is the output for the webcam line from running the command:


lsusb

I am NOT skilled with the ffmpeg command, although I have managed to get it working for some neat things (such as a complete screen capture of my desktop).

I note that the errors you get with ffmpeg that there is a BUG in the packman packaged ffmpeg (which originated upstream) and the command you used gives the error:

The V4L2 driver ioctl set standard(NTSC) failed 

and we need to wait for the fix to come downstream.

I note this reference for the bug report (dated 28-May-2011): FFmpeg-users - Problem with video4linux2

You could post about this bug on the Packman mailing list and ask they rebuild ffmpeg with from the latest git version.

= = =

As an aside, you may be interested that this command will capture the entire screen with audio:

ffmpeg -f alsa -ac 2 -i hw:1,0 -f x11grab -r 15 -s 1920x1200 -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.avi 

Where "hw:1,0: is my webcam mic. I am capturing at 15 fps. And I am capturing at the resolution of 1920x1200.