How to Use FFmpeg dshow on Windows

This guide explains how to use the DirectShow (-f dshow) input device in FFmpeg on Windows to capture live audio and video from webcams, microphones, and capture cards. You will learn how to locate your connected hardware devices, formulate commands to record or stream their inputs, and configure essential capture settings like resolution and frame rate.

Step 1: List Available Devices

Before capturing media, you must identify the exact names of your audio and video input devices as recognized by Windows DirectShow.

Run the following command in your Command Prompt or PowerShell:

ffmpeg -list_devices true -f dshow -i dummy

FFmpeg will output a list of directshow video and audio devices. The output will look similar to this:

[dshow @ 0000021b...] DirectShow video devices (some may be both video and audio devices)
[dshow @ 0000021b...]  "Integrated Camera"
[dshow @ 0000021b...]     Alternative name "@device_pnp_\\?\usb#vid_04f2..."
[dshow @ 0000021b...] DirectShow audio devices
[dshow @ 0000021b...]  "Microphone (Realtek High Definition Audio)"

Note down the exact names inside the quotation marks (e.g., "Integrated Camera" and "Microphone (Realtek High Definition Audio)").

Step 2: Capture Video or Audio

Once you have the device names, you can use the -f dshow option to record from them.

Record Video Only

To record video from your webcam, use the -i video="Device_Name" syntax:

ffmpeg -f dshow -i video="Integrated Camera" output.mp4

Record Audio Only

To record audio from your microphone, use the -i audio="Device_Name" syntax:

ffmpeg -f dshow -i audio="Microphone (Realtek High Definition Audio)" output.mp3

Record Video and Audio Together

To capture both sources simultaneously, combine them into a single input separated by a colon, or use multiple inputs:

ffmpeg -f dshow -i video="Integrated Camera":audio="Microphone (Realtek High Definition Audio)" output.mkv

Step 3: Configure Capture Settings

Default settings may not always yield the best quality. You can specify options like video size, frame rate, and pixel format before the input flag.

Set Resolution and Frame Rate

To capture video at a specific resolution (e.g., 1280x720) and frame rate (e.g., 30 FPS):

ffmpeg -f dshow -video_size 1280x720 -framerate 30 -i video="Integrated Camera" output.mp4

List Supported Device Formats

If you do not know what resolutions or frame rates your webcam supports, you can query the device directly:

ffmpeg -list_options true -f dshow -i video="Integrated Camera"

This command displays all supported resolutions, pixel formats, and frame rates for the specified camera, allowing you to choose the optimal settings for your recording.