Version 30 (modified by rogerdpack, 5 years ago) (diff)



FFmpeg can take input from "directshow" devices on your Windows computer. See the FFmpeg dshow input device documentation for more information.

Example to list dshow input devices:

c:\> ffmpeg -list_devices true -f dshow -i dummy
ffmpeg version N-45279-g6b86dd5... --enable-runtime-cpudetect
  libavutil      51. 74.100 / 51. 74.100
  libavcodec     54. 65.100 / 54. 65.100
  libavformat    54. 31.100 / 54. 31.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
[dshow @ 03ACF580] DirectShow video devices
[dshow @ 03ACF580]  "Integrated Camera"
[dshow @ 03ACF580]  "screen-capture-recorder"
[dshow @ 03ACF580] DirectShow audio devices
[dshow @ 03ACF580]  "Internal Microphone (Conexant 2"
[dshow @ 03ACF580]  "virtual-audio-capturer"
dummy: Immediate exit requested

Example to use a dshow device as an input:

c:\> ffmpeg -f dshow -i video="Integrated Camera" out.mp4

You can also pass the device certain parameters that it needs, for instance a webcam might allow you to capture it in 1024x768 at up to max 5 fps, or allow you to capture at 640x480 at 30 fps.

Example to print a list of options from a selected device:

c:\> ffmpeg -f dshow -list_options true -i video="Integrated Camera"
ffmpeg version N-45279-g6b86dd5 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 10 2012 17:30:47 with gcc 4.7.1 (GCC)
  libavutil      51. 74.100 / 51. 74.100
  libavcodec     54. 65.100 / 54. 65.100
  libavformat    54. 31.100 / 54. 31.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
[dshow @ 01D4F3E0] DirectShow video device options
[dshow @ 01D4F3E0]  Pin "Capture"
[dshow @ 01D4F3E0]   pixel_format=yuyv422  min s=640x480 fps=15 max s=640x480 fps=30
[dshow @ 01D4F3E0]   pixel_format=yuyv422  min s=1280x720 fps=7.5 max s=1280x720 fps=7.5
[dshow @ 01D4F3E0]   vcodec=mjpeg  min s=640x480 fps=15 max s=640x480 fps=30
[dshow @ 01D4F3E0]   vcodec=mjpeg  min s=1280x720 fps=15 max s=1280x720 fps=30
video=Integrated Camera: Immediate exit requested

You can see in this particular instance that it can either stream it to you in a "raw pixel_format" (yuyv422 in this case), or as an mjpeg stream.

ffmpeg -f dshow -video_size 1280x720 -framerate 7.5 -pixel_format yuyv422 -i video="Integrated Camera" out.avi

You can specify the type (mjpeg) and size (1280x720) and frame rate to tell the device to give you (15 fps) (note for instance, in this instance, the camera can give you a higher frame rate/size total if you specify mjpeg):

ffmpeg -f dshow -video_size 1280x720 -framerate 15 -vcodec mjpeg -i video="Integrated Camera" out.avi

You can specify "-vcodec copy" to stream copy the video instead of re-encoding, if you can receive the data in some type of pre-encoded format, like mjpeg in this instance.

Example audio list options:

c:\> ffmpeg -f dshow -list_options true -i audio=virtual-audio-capturer
ffmpeg version N-50911-g9efcfbe Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 13 2013 21:26:48 with gcc 4.7.2 (GCC)
  libavutil      52. 19.100 / 52. 19.100
  libavcodec     55.  0.100 / 55.  0.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    54.  4.100 / 54.  4.100
  libavfilter     3. 45.103 /  3. 45.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[dshow @ 0215bc00] DirectShow audio device options
[dshow @ 0215bc00]  Pin "Capture Pin"
[dshow @ 0215bc00]   min ch=2 bits=16 rate= 44100 max ch=2 bits=16 rate= 44100
audio=virtual-audio-capturer: Immediate exit requested

Also this note that the input string is in the format video=<video device name>:audio=<audio device name>. It is possible to have two separate inputs (like -f dshow -i audio=foo -f dshow -i video=bar) though some limited tests had shown a difference in synchronism between the two options.

Also note that you can only at most have 2 streams at once (one audio and one video, like -i video=XX:audio=YY). Ask if you want this improved. You can have multiples one after the other, however, like -f dshow -i video=XX:audio=ZZ -f dshow -i video=ZZ:audio=QQ etc. FFmpeg can also "merge/combine" audio inputs using its amix filter.

See the FFmpeg dshow input device documentation for a list of more dshow options you can specify. For instance you can decrease latency on audio devices, or specify a video by "index" if two have the same name, etc.

Specifying input framerate

You can set framerate like ffmpeg -f dshow -framerate 7.5 -i video=XXX. This instructs the device itself to send you frames at 7.5 fps [if it can].

Be careful *not* to specify framerate with the "-r" parameter, like this ffmpeg -f dshow -r 7.5 -i video=XXX. This actually specifies that the devices incoming PTS timestamps be *ignored* and replaced as if the device were running at 7.5 fps [so it runs at default fps, but its timestamps are treated as if 7.t fps]. This can cause the recording to appear to have "video slower than audio" or, under high cpu load (if video frames are dropped) it will cause the video to fall "behind" the audio [after playback of the recording is done, audio continues on--and gets highly out of sync, video appears to go into "fast forward" mode during high cpu scenes].

If you want say 10 fps, and you device only supports 7.5 and 15 fps, then run it at fps then "downsample" to 10 fps. There are a few ways to do this--you could specify your output to be 10 fps, like this: ffmpeg -f dshow -framerate 15 -i video=XXX -r 10 output.mp4 or insert a filter to do the same thing for you: ffmpeg -f dshow -framerate 15 -vf fps=15 output.mp4.


By default FFmpeg captures frames from the input, and then does whatever you told it to do, for instance, re-encoding them and saving them to an output file. By default if it receives a video frame "too early" (while the previous frame isn't finished yet), it will discard that frame, so that it can keep up the the real time input. You can adjust this by setting the -rtbufsize parameter, though note that if your encoding process can't keep up, eventually you'll still start losing frames just the same (and using it at all can introduce a bit of latency). It may be helpful to still specify some size of buffer, however, otherwise frames may be needlessly dropped possibly.

See StreamingGuide for some tips on tweaking encoding (sections latency and cpu usage). For instance, you could save it to a very fast codec, then re-encode it later.

There is also an option audio_buffer_size. Basically if you're capturing from a live mic, the default behavior for this hardware device is to "buffer" 500ms (or 1000ms) worth of data, before it starts sending it down the pipeline. This can introduce startup latency, so setting this to 50ms (msdn suggests 80ms) may be a better idea here. The timestamps on the data will be right, it will just have added (unneeded) latency if you don't specify this.


If you have a video capture card (ex: AverMedia, possibly some BlackMagic, though it may be a separate unrelated problem, and also some BlackMagic cards don't have the right inputs set up ask on the zeranoe forum), it may not work (yet) out of the box with FFmpeg, as it lacks crossbar support presently. The work around currently is to install the AmerecTV software, which presents the capture card as directshow devices, then input the AmerecTV directshow devices into your FFmpeg as a workaround.

Using DirectShow with libav*

You can use dshow input via the libavXXX libraries (i.e. directly into your own program) instead of calling out to ffmpeg.exe. See Using libav* for an intro to using libav. See also

How to programmatically enumerate devices

FFmpeg does not provide a native way to do this yet, but you can lookup the devices yourself or just parse standard out from FFmpeg:


AviSynth Input

FFmpeg can also take DirectShow input by creating an avisynth file (.avs file) that itself gets input from a graphedit file, which graphedit file exposes a pin of your capture source or any filter really, ex (yo.avs) with this content:

DirectShowSource("push2.GRF", fps=35, audio=False, framecount=1000000)

Running ffmpeg.exe without opening a console window

If you want to run your ffmpeg "from a gui" without having it popup a console window which spits out all of ffmpeg's input, a few things that may help:

  • If you can start your program like rubyw.exe or javaw.exe then all command line output (including child processes') is basically not attached to a console.
  • If your program has an option to run a child program "hidden" or the like, that might work. If you redirect stderr and stdout to something you receive, that might work (but might be tricky because you may need to read from both pipes in different threads, etc.)

ffdshow tryouts

ffdshow tryouts is a separate project that basically wraps FFmpeg's core source (libavcodec, etc.) and then presents them as filter wrappers that your normal Windows applications can use for decoding video, etc. It's not related to FFmpeg directly at all.


You can ask questions/comments about DirectShow on the Zeranoe FFmpeg Forum.

Known Bugs/Feature Requests

Send a message to if you want to discuss these issues.

  • unable to specify device by guid (but you can use name/index currently, sometimes this isn't enough for certain names not console friendly)
  • "could not enumerate video devices" -> "could not enumerate or none installed"
  • video property enumeration using -video_device_number appears to be broken (is using it broken too?)
  • does not work with crossbar devices (see above mention of amarectv)
  • may not work with devices that somehow share audio and video together DirectShow Capture Source and FFmpeg
  • if you have -i audio=x:video=x and video comes too frequently ("dropping packet") it might start dropping audio packets too, which may not be desired (ping me if you want this fixed).
  • currently there is no ability to "push back" against upstream sources if ffmpeg is unable to encode fast enough, this might be nice to have.
  • currently no ability to select "i420" from various yuv options:
  • cannot use audio pins on certain "combined" video/audio sources
  • json output?