How to Capture Webcam on Windows Using FFmpeg DirectShow
This guide provides a straightforward walkthrough on how to use
FFmpeg’s DirectShow (dshow) input device to capture video
and audio from a webcam on Windows. You will learn how to list your
connected hardware devices, construct the basic capture command, and
configure settings like resolution, framerate, and audio integration for
a high-quality recording.
Step 1: List Your Available Devices
Before capturing, you must find the exact names of your webcam and microphone as recognized by Windows. Run the following command in your Command Prompt or PowerShell:
ffmpeg -f dshow -list_devices true -i dummyThis command will output a list of DirectShow devices. Look for the
alternative names under the “DirectShow video devices” and “DirectShow
audio devices” sections. For example, your webcam might be named
"Integrated Camera" and your microphone might be named
"Microphone (Realtek Audio)".
Step 2: Capture Video Only
To capture only the video feed from your webcam and save it to an MP4
file, use the following command structure. Replace
"Your Webcam Name" with the exact video device name you
found in Step 1:
ffmpeg -f dshow -i video="Your Webcam Name" output.mp4To stop the recording at any time, press q on your
keyboard.
Step 3: Capture Video and Audio Together
To record both your webcam video and your microphone audio
simultaneously, map both devices in the input argument using a colon
(:) separator:
ffmpeg -f dshow -i video="Your Webcam Name":audio="Your Microphone Name" output.mp4Step 4: Configure Resolution and Framerate
Webcams support specific resolutions and frame rates. To see what formats your webcam supports, run:
ffmpeg -f dshow -list_options true -i video="Your Webcam Name"Once you identify the supported configurations, you can force FFmpeg
to capture at a specific resolution (e.g., 1280x720) and framerate
(e.g., 30 fps) by adding the -video_size and
-framerate flags before the input flag:
ffmpeg -f dshow -video_size 1280x720 -framerate 30 -i video="Your Webcam Name":audio="Your Microphone Name" output.mp4