user1545779
user1545779

Reputation: 468

recording sound from webcam using ffmpeg

Using ffmpeg arecord -L, I am able to identify my Logitech usb webcam as:

hw:CARD=U0x46d0x821,DEV=0
    USB Device 0x46d:0x821, USB Audio
    Direct hardware device without any conversions
plughw:CARD=U0x46d0x821,DEV=0
    USB Device 0x46d:0x821, USB Audio
    Hardware device with all software conversions

when I go into /dev/snd/by-id, the webcam is described as:

usb-046d_0821_6813BFD0-00 -> ../controlC1

I know that the command to use a sound device in ffmpeg is

ffmpeg -f alsa -i $ALSA_DEVICE_NAME..

I have tried

ffmpeg -f alsa -i "hw:CARD=U0x46d0x821,DEV=0"

and

ffmpeg -f alsa  -i "plughw:CARD=U0x46d0x821,DEV=0"

and in both cases I receive the same error message:

ALSA lib pcm.c:2208:(snd_pcm_open_noupdate) Unknown PCM hw=CARD=U0x46d0x821,DEV=0
[alsa @ 0x9c96580] cannot open audio device hw=CARD=U0x46d0x821,DEV=0 (No such file or directory)
hw:CARD=U0x46d0x821,DEV=0: Input/output error

I have also tried:

ffmpeg -f alsa -i "usb-046d_0821_6813BFD0-00"

and

ffmpeg -f alsa -i "usb-046d_0821_6813BFD0-00,DEV=0"

and have still received error message

Could you please help in formulating the correct format of the command

Upvotes: 4

Views: 13555

Answers (2)

user1545779
user1545779

Reputation: 468

I have finally been able to use the sound portion of the webcam under ffmpeg. The correct way to do it is NOT to enclose the hardware value in quotes. Do not enclose the hardware in quotes:

ffmpeg -f alsa -i plughw:CARD=U0x46d0x821,DEV=0

instead of:

ffmpeg -f alsa -i "plughw:CARD=U0x46d0x821,DEV=0"

I hope this helps someone else.

Upvotes: 2

Ionică Bizău
Ionică Bizău

Reputation: 113335

Maybe this works:

ffmpeg -f alsa -r 16000 -i hw:2,0 -f video4linux2 -s 800x600 -i /dev/video0 -r 30 -f avi -vcodec mpeg4 -vtag xvid -sameq -acodec libmp3lame -ab 96k output.avi

Source

Upvotes: 1

Related Questions