In this post, I will show you how to list all connected media devices in Windows. We will use ffmpeg for the job.
Make sure to download it for your Windows, click to download.
To list all connected media devices in Windows, use the following command:
$ ffmpeg -list_devices true -f dshow -i dummy
[dshow @ 000000000050a400] DirectShow video devices (some may be both video and audio devices)
[dshow @ 000000000050a400] "Logitech Webcam C920 [Fixed]"
[dshow @ 000000000050a400] Alternative name ...
[dshow @ 000000000050a400] DirectShow audio devices
[dshow @ 000000000050a400] "Internal Microphone Array (IDT "
[dshow @ 000000000050a400] Alternative name ...
Have fun!
A Mutable Log
A blog by Devendra Tewari
Project maintained by tewarid
Hosted on GitHub Pages — Theme by mattgraham
A quick post to document how audio and video can be captured on Windows using FFmpeg into different container formats like MKV, MP4 and WebM.
List DirectShow devices
The following command lists the names of audio and video devices currently installed
ffmpeg -list_devices true -f dshow -i dummy
Capture from webcam and microphone
With container format mkv the default video codec is H.264 and audio codec is Vorbis. With the mp4 container format (change output.mkv to output.mp4) the video codec is H.264 and audio code is MPEG AAC. With the webm container format the video codec is the Google/On2 VP8 and audio codec is Vorbis.
ffmpeg -f dshow -i video="video device name":audio="audio device name" -r 25 -s 320x240 output.mkv
I added the -s
video size and -r
video frame rate options because I was getting lots of dropped frames with mkv and mp4.
Reference ffmpeg directshow
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Sign up
One, foreword
This series describes the ffmPEG command line support and use of -devices input and output devices.
-
Input Devices are used to collect/capture data from multimedia devices connected to the system, such as microphone/microphone audio sampling data, desktop screen image data, camera/camera image data, etc.
-
Output devices are used to write multimedia data to the output devices of the system, such as audio player devices, Windows, graphics rendering devices (openGL context, SDL), etc.
Ii. Reference materials
This article is from ffMPEG official documentation: ffmpeg.org/ffmpeg-devi…
How to download and install FFMPEG
- Windows Platform download:
Ffmpeg.org/download.ht…
- MAC Platform download:
Ffmpeg.org/download.ht…
- Linux Platform download:
Linux distributions support ffMPEG. Ffmpeg provides two download links from ffmpeg.org/download.ht… And johnvansickle.com/ffmpeg/
How to view all input and output devices supported by FFMPEG
Use the ffmpeg command to list all devices supported by FFmpeg
ffmpeg.exe -devices
Note: The list of devices supported by FFMPEG depends on the system environment and device environment of each machine, and each machine may be different.
List of devices supported by FFMPEG
Input Devices
1. alsa
ALSA (Advanced Linux Sound Architecture) input device. To enable this input device during configuration, you need to have Libasound installed on your system. This device allows capture from an ALSA device. The name of the device to capture must be an ALSA card identifier.
Alsa details: www.alsa-project.org/alsa-doc/al…
1.1 ffmpeg command
ffmpeg -f alsa -i hw:0 alsaout.wav
1.2 Parameter Description
hw:CARD[,DEV[,SUBDEV]]
The three parameters are CARD, DEV, and SUBDEV in sequence.
- CARD: Specifies the CARD number or identifier
- DEV: indicates the device ID
- SUBDEV: indicates the subdevice number (-1 indicates any number).
2. android_camera
Android camera input device.
Based on the Android Camera2 NDK API, which is available on devices with API level 24+. The availability of Android_camera is automatically detected during configuration.
The device allows capture from all cameras on Android devices integrated in the Camera2 NDK API. The available cameras are enumerated internally and can be selected using the camerA_index parameter. The input file string will be discarded. Typically, the rear camera has an index of 0 and the front camera has an index of 1.
3. avfoundation
AVFoundation is Apple’s current recommended multimedia framework for streaming image and audio capture on OSX> = 10.7 and iOS. You can use ffmpeg-f avfoundation-list_devices true -i “” to list the supported fetching device names and corresponding device index numbers on the current macOS or iOS.
3.1 ffmpeg command
Ffmpeg-f avfoundation -i “0:0” out.avi
Record the video device with index 0 and the audio device with index 0 into an out.avi video file
3.2 Parameter Description
-i “[[VIDEO] : [AUDIO]]”
Video: video device index audio: Audio device index Number Run the ffmpeg -f avfoundation-list_devices true -i “” command to query the index number.
4. bktr
BSD video input device.
5. decklink
The DeckLink input device provides capture capabilities for the Blackmagic DeckLink device.
6.dshow
Windows DirectShow input device used to collect video and audio devices in Windows. Run the ffmpeg-list_devices true -f dshow -i dummy command to view the list of supported devices, including device names and device types.
6.1 ffmpeg command
Ffmpeg-f dshow -I video= “Camera” :audio= “Microphone”
Turn on the camera and microphone
6.2 Parameter Description
TYPE=NAME[:TYPE=NAME]
- TYPE: indicates the device TYPE, video or audio
- NAME: device NAME (corresponding to device NAME output in ffmpeg-list_devices true -f dshow -i dummy)
7. fbdev
Linux frame buffer input device. Linux frame buffers are graphics abstraction layers independent of graphics hardware that are used to display graphics on computer monitors, usually on consoles. It is accessed through the file device node (typically /dev/fb0).
For details: linux-fbdev.sourceforge.net/
8.gdigrab
Win32 GDI based screen capture device. You can capture the screen image of the Windows desktop display area, including the Windows window display screen.
8.1 ffmpeg command
Capture the screen image of the specified area of the desktop screen (without -offset_x and -offset_y to capture the full screen)
ffmpeg -f gdigrab -framerate 6 -offset_x 10 -offset_y 20 -video_size vga -i desktop out.mpg
Captures the calculator window screen image
ffmpeg -f gdigrab -framerate 6 -i title=Calculator out.mpg
8.2 Parameter Description
Title = WINDOW_title: Window_title is the title of the Windows window, note that it is not the process name. Draw_mouse: whether to draw the mouse, 0: 1: draws the mouse (default: 1 if the mouse is empty). -offset_x: captures the X coordinate of the captured area. The upper left corner of the screen is the starting coordinate (0,0), and the lower right corner is (screenSize,screenSize)
9. iec61883
Use libiEC61883 FireWire DV/HDV input device.
10. jack
JACK input device
11. kmsgrab
KMS video input device. Captures the KMS scan output frame buffer associated with the specified CRTC or plane as a DRM object and passes it to other hardware functions. DRM master or CAP_SYS_ADMIN is required to run.
12. lavfi
Libavfilter Enter the virtual device. The input device reads data from the open output pad of the LibavFilter graph. For each output that the FilterGraph opens, the input device creates a corresponding stream that maps to the generated output. Currently, only video data is supported. The filter diagram is specified by the options diagram.
13. libcdio
Audio CD input device based on Libcdio. To enable this input device during configuration, you need to have Libcdio installed on your system. It requires the configuration option – enable-libcdio. This device allows playback and scraping from audio CDS.
14. libdc1394
IIDC1394 input device, based on libdc1394 and libraw1394.
15. openal
The OpenAL input device provides audio capture on all systems with an effective OpenAL 1.1 implementation. OpenAL headers and libraries should be provided as part of the OpenAL implementation or as another download (SDK).
16. oss
Turn on the sound system input device. The file name supplied to the input device is the device node representing the OSS input device, usually set to /dev/dsp.
17. pulse
PulseAudio input device. The file name supplied to the input device is the source device or the string “default”.
18. sndio
Sndio input devices. The file name supplied to the input device is the device node representing the SNdio input device, usually set to /dev/audio0.
19. video4linux2, v4l2
Video4Linux2 inputs video devices. “V4l2” can be used as an alias for “Video4Linux2”. If FFmpeg is built with v4l-utils support (by using the -enable-libv4l2 configuration option), it can be used with the -use_libv4l2 input device option. The name of the device to be captured is the file device node, which is typically created automatically by Linux when a device (such as a USB webcam) is inserted into the system, and is named /dev/videon, where N is the number associated with the device. Video4Linux2 devices typically support a limited set of widthxheight sizes and frame rates. You can use -list_Formats all to see what the Video4Linux2 device supports. Some devices, such as TV cards, support one or more standards. You can use -list_standards all to list all supported standards. The time base of the time stamp is 1 microsecond. Depending on the kernel version and configuration, the timestamp may come from a real-time clock (Unix era origin) or a monotonic clock (typically originating at boot time and not affected by NTP or manually changing the clock). The -timestamps ABS or -ts abs option can be used to force a real-time clock.
20. vfwcap
VfW (Windows Video) capture input devices. The file name passed as input is the capture driver number, which ranges from 0 to 9 and is generally used to capture camera images. You can use list as the file name to view the list of supported devices. Any other file name will be interpreted as device number 0.
2.1 ffmpeg command
View the list of supported devices
ffmpeg -y -f vfwcap -i list
Capture camera images and save them as mp4 files
ffmpeg -y -f vfwcap -i 0 out.mp4
20.2 Parameter Description
Video_size: set the size of the image to be captured (for example, 800×600). Framerate: framerate, default 30 frames
21. x11grab
X11 video input device. Can capture the X11 display area.
Output devices
1. alsa
ALSA (Advanced Linux Sound Architecture) output device.
2. AudioToolbox
AudioToolbox output equipment. Allows native output to CoreAudio devices on OSX.
3. caca
CACA output device. This output device allows the video stream to be displayed in the CACA window. Only one CACA window is allowed per application, so there can only be one instance of this output device in an application.
4. decklink
The DeckLink output device provides playback capabilities for Blackmagic DeckLink devices.
5. fbdev
Linux frame buffer output device. Linux frame buffers are graphics abstraction layers independent of graphics hardware that are used to display graphics on computer monitors, usually on consoles. It is accessed through the file device node (typically /dev/fb0). For more details about linux-fbdev.sourceforge.net/
6. opengl
OpenGL output device. This output device allows rendering to the OpenGL context. Context can be provided by the application or a default SDL window can be created.
7. oss
OSS (Open Sound System) output devices.
8. pulse
PulseAudio output device. For more information: www.pulseaudio.org.
9. sdl
SDL (Simple DirectMedia Layer) output device. Sdl2 can be used as an alias for SDL. This output device allows the video stream to be displayed in an SDL window. Only one SDL window is allowed per application, so there can only be one instance of this output device in an application. More information about SDL can be found at www.libsdl.org/
10. sndio
Sndio audio output device.
11. v4l2
Video4Linux2 output device.
12. xv
XV (XVideo) output device. Video streams can be displayed in the X Window System Window.
Here, keeping some ffmpeg commands handy as I tend to forget if I don’t use them quite often. (please pardon me if links dont work)
- To list the audio-video devices connected to the system
- To query specific (audio) device:
- To record audio from the mic (without encoding):
To list the audio-video devices connected to the system:
ffmpeg -list_devices true -f dshow -i dummy
>ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -list_devices true -f dshow -i dummy
ffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: –disable-static –enable-shared –enable-gpl
–enable-version3 –enable-dxva2 –enable-libmfx –enable-nvenc
–enable-avisynth –enable-bzlib –enable-fontconfig –enable-frei0r
–enable-gnutls –enable-iconv –enable-libass –enable-libbluray
–enable-libbs2b –enable-libcaca –enable-libfreetype –enable-libgme
–enable-libgsm –enable-libilbc –enable-libmodplug –enable-libmp3lame
–enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libopenh264
–enable-libopenjpeg –enable-libopus –enable-librtmp –enable-libsnappy
–enable-libsoxr –enable-libspeex –enable-libtheora –enable-libtwolame
–enable-libvidstab –enable-libvo-amrwbenc –enable-libvorbis
–enable-libvpx –enable-libwavpack –enable-libwebp –enable-libx264
–enable-libx265 –enable-libxavs –enable-libxvid –enable-libzimg
–enable-lzma –enable-decklink –enable-zliblibavutil 55. 43.100 / 55. 43.100
libavcodec 57. 70.100 / 57. 70.100
libavformat 57. 61.100 / 57. 61.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
[dshow @ 00000000004832a0] DirectShow video devices (some may be both video
and audio devices)[dshow @ 00000000004832a0] “Logitech HD Pro Webcam C920”
[dshow @ 00000000004832a0] Alternative name
“@device_pnp_\\?\usb#vid_046d&pid_082d&mi_00#7&10c84974&0&0000#{65e8773d-8f56-
11d0-a3b9-00a0c9223196}\{bbefb6c7-2fc4-4139-bb8b-a58bba724083}”[dshow @ 00000000004832a0] DirectShow audio devices
[dshow @ 00000000004832a0] “Microphone (HD Pro Webcam C920)”
[dshow @ 00000000004832a0] Alternative name
“@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\Microphone (HD Pro Webcam
C920)”dummy: Immediate exit requested
To query specific (audio) device:
ffmpeg -list_options true -f dshow -i audio="Microphone (HD Pro Webcam C920)"
>ffmpeg -list_options true -f dshow -i audio=”Microphone (HD Pro Webcam C920)”
ffmpeg -list_options true -f dshow -i audio=”Microphone (HD Pro Webcam C920)”
ffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: –disable-static –enable-shared –enable-gpl
–enable-version3 –enable-dxva2 –enable-libmfx –enable-nvenc
–enable-avisynth –enable-bzlib –enable-fontconfig –enable-frei0r
–enable-gnutls –enable-iconv –enable-libass –enable-libbluray
–enable-libbs2b –enable-libcaca –enable-libfreetype –enable-libgme
–enable-libgsm –enable-libilbc –enable-libmodplug –enable-libmp3lame
–enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libopenh264
–enable-libopenjpeg –enable-libopus –enable-librtmp –enable-libsnappy
–enable-libsoxr –enable-libspeex –enable-libtheora –enable-libtwolame
–enable-libvidstab –enable-libvo-amrwbenc –enable-libvorbis
–enable-libvpx –enable-libwavpack –enable-libwebp –enable-libx264
–enable-libx265 –enable-libxavs –enable-libxvid –enable-libzimg
–enable-lzma –enable-decklink –enable-zliblibavutil 55. 43.100 / 55. 43.100
libavcodec 57. 70.100 / 57. 70.100
libavformat 57. 61.100 / 57. 61.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
[dshow @ 00000000005933c0] DirectShow audio only device options (from audio
devices)[dshow @ 00000000005933c0] Pin “Capture” (alternative pin name “Capture”)
[dshow @ 00000000005933c0] min ch=1 bits=8 rate= 11025 max ch=2 bits=16 rate=
44100Last message repeated 22 times
audio=Microphone (HD Pro Webcam C920): Immediate exit requested
To record audio from the mic (without encoding):
ffmpeg -f dshow -i audio="Microphone (HD Pro Webcam C920)" -vn -sn -acodec copy DTMFToneSample2.wav
>ffmpeg -f dshow -i audio=”Microphone (HD Pro Webcam C920)” -vn -sn -acodec
copy DTMFToneSample2.wavffmpeg -f dshow -i audio=”Microphone (HD Pro Webcam C920)” -vn -sn -acodec
copy DTMFToneSample2.wavffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: –disable-static –enable-shared –enable-gpl
–enable-version3 –enable-dxva2 –enable-libmfx –enable-nvenc
–enable-avisynth –enable-bzlib –enable-fontconfig –enable-frei0r
–enable-gnutls –enable-iconv –enable-libass –enable-libbluray
–enable-libbs2b –enable-libcaca –enable-libfreetype –enable-libgme
–enable-libgsm –enable-libilbc –enable-libmodplug –enable-libmp3lame
–enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libopenh264
–enable-libopenjpeg –enable-libopus –enable-librtmp –enable-libsnappy
–enable-libsoxr –enable-libspeex –enable-libtheora –enable-libtwolame
–enable-libvidstab –enable-libvo-amrwbenc –enable-libvorbis
–enable-libvpx –enable-libwavpack –enable-libwebp –enable-libx264
–enable-libx265 –enable-libxavs –enable-libxvid –enable-libzimg
–enable-lzma –enable-decklink –enable-zliblibavutil 55. 43.100 / 55. 43.100
libavcodec 57. 70.100 / 57. 70.100
libavformat 57. 61.100 / 57. 61.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, dshow, from ‘audio=Microphone (HD Pro Webcam C920)’:
Duration: N/A, start: 664890.821000, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Output #0, wav, to ‘DTMFToneSample2.wav’:
Metadata:
ISFT : Lavf57.61.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo,
s16, 1411 kb/sStream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 1550kB time=00:00:08.53 bitrate=1489.0kbits/s speed= 1x q
size= 1550kB time=00:00:08.53 bitrate=1489.0kbits/s speed=0.992x
video:0kB audio:1550kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.004913%
To be continued…