Capturing from a Webcam with v4l2-ctl: What It Records and Where the Microphone Fits
How v4l2-ctl captures frames from a V4L2 webcam or loopback device on Linux, why it records no audio, and how to capture the webcam microphone alongside it.
The short answer
v4l2-ctl, part of the v4l-utils package, can capture frames from any Video4Linux2 (V4L2) device, including physical webcams and v4l2loopback virtual cameras. It captures video only. V4L2 is the Linux video interface, and a webcam's built-in microphone is not exposed through it. On Linux, a USB webcam microphone normally appears as a separate sound device handled by ALSA, which PulseAudio or PipeWire then present as an input source. Capturing speech from a webcam therefore needs a second tool, such as arecord, pw-record or ffmpeg, working alongside or instead of v4l2-ctl.
No device-specific evidence was supplied for this guide. It describes documented tool behavior and general Linux audio and video principles, not tested results for any particular webcam. The formats, resolutions and sample rates your hardware supports must be read from the device itself, using the commands below.
Find the video device and its formats
Start by listing V4L2 devices. A single webcam often creates more than one /dev/video node, and only some of them deliver image frames; others may carry metadata. The format listing shows which node actually offers capture formats.
v4l2-ctl --list-devices
v4l2-ctl -d /dev/video0 --list-formats-ext
v4l2-ctl -d /dev/video0 --all
The --list-formats-ext output lists pixel formats such as YUYV (uncompressed) or MJPG (Motion JPEG, compressed), each with the resolutions and frame intervals the driver reports. Choose a combination from that list rather than assuming one.
Capture frames with v4l2-ctl
Set a format the device reports, then stream a fixed number of frames to a file using memory-mapped buffers:
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=MJPG
v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=100 --stream-to=capture.mjpeg
The output is a sequence of raw frames with no container, no timestamps in a playable form and no audio track. Concatenated MJPEG frames can be opened by some players. Uncompressed YUYV data must be described explicitly to a player, for example:
ffplay -f rawvideo -pixel_format yuyv422 -video_size 1280x720 capture.yuv
Because of this, v4l2-ctl capture is best suited to checking that a device delivers frames, testing formats and adjusting controls. It is not a recording workflow for meetings or spoken content.
Camera controls versus audio controls
v4l2-ctl --list-ctrls and --set-ctrl adjust image settings the driver exposes, such as brightness, exposure or focus. Microphone gain, mute and capture volume are not V4L2 controls. They are mixer controls on the sound side, adjusted with alsamixer, amixer, pactl or wpctl, or in your desktop sound settings.
Capturing the webcam microphone
To record speech from the webcam's microphone, identify it as a sound device and check what it supports before recording. The hardware parameter dump shows the sample formats, rates and channel counts the device accepts. The sample rate is the number of audio samples taken per second. Many webcam microphones are mono (one channel), but confirm this from the dump rather than assuming it.
arecord -l
arecord -D hw:1,0 --dump-hw-params -d 1 /dev/null
arecord -D hw:1,0 -f S16_LE -r 48000 -c 1 speech.wav
Replace hw:1,0 with the card and device numbers shown by arecord -l. Replace the format, rate and channel values with ones the dump lists. On systems running PipeWire or PulseAudio, pactl list short sources shows the webcam microphone as a named source, and pw-record or parecord can record from it without taking exclusive control of the hardware.
Recording video and speech together
When you need picture and voice in one file, a tool that reads both subsystems is more practical than v4l2-ctl. ffmpeg can open the V4L2 node and the ALSA or PulseAudio input at the same time and write them into a single container:
ffmpeg -f v4l2 -input_format mjpeg -video_size 1280x720 -i /dev/video0 \
-f alsa -i hw:1,0 \
-c:v libx264 -c:a aac recording.mkv
Audio and video come from separate devices with separate clocks, so lip sync is not guaranteed and can drift over long recordings. Check sync on a test recording before relying on the setup for anything important.
Loopback devices and virtual cameras
The v4l2loopback kernel module creates a virtual V4L2 device. One program writes frames into it, and conferencing or browser applications read from it as if it were a camera. v4l2-ctl can inspect and capture from a loopback node in the same way as from a physical webcam. It can also feed an output-capable device using its stream-out options, although tools like ffmpeg or OBS are more commonly used as the source.
sudo modprobe v4l2loopback devices=1 video_nr=10 card_label="Virtual Cam" exclusive_caps=1
v4l2-ctl -d /dev/video10 --all
A loopback camera carries video only. Routing a virtual camera through it does not carry any microphone signal with it. The meeting application keeps using whatever audio input it is set to, so select the webcam microphone, or another microphone, separately in that application's audio settings. If you also want processed audio, such as noise suppression, the Linux equivalent is a virtual audio source created in PipeWire or PulseAudio, which is independent of v4l2loopback.
What this guide cannot tell you
- Which pixel formats, resolutions or frame rates a specific webcam supports: read them with --list-formats-ext.
- Which sample rates or channel counts a specific webcam microphone supports: read them with arecord --dump-hw-params.
- How good any particular webcam microphone sounds for speech: no measurements or listening tests were supplied, so voice quality has to be judged from your own test recordings.
- How much audio-video drift a given setup produces: this depends on the hardware and software and must be checked in practice.