recording sound from webcam using ffmpeg
11,256
Solution 1
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.
Solution 2
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
Author by
user1545779
Updated on July 10, 2022Comments
-
user1545779 almost 2 years
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
-
user1545779 almost 12 yearsThanks for the suggestion. I am still receiving the same error for the sound/audio portion of the command, the audio hardware cannot be identified<br/><br/> italic **bold "ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card [alsa @ 0xb0e7620] cannot open audio device hw:2,0 (No such file or directory)<br/> hw:2,0: Input/output error"
-
user1545779 almost 12 yearsI am having problems trying to format the stuff that I put up here. I have so far not been successful. I find the help instructions to be too terse. I could use some clearer tutorial to mark up what I put up here. Cheers