Windows shell: how can I get the sound device name?

I'm not sure if this is strictly a programming matter, unless I mind using additional software to solve the problem as long as it remains scriptable or command line accessible (this: not a GUI solution). Anyway, I posted another (slightly different) question on SuperUser . By the way, I'll update here if I find an answer.

My Windows program (shell script only) calls the VLC command to record audio from the audio card and issue it like:

vlc dshow:// :dshow-vdev=none :dshow-adev="SoundMAX HD Audio I" :std{mux=ts,access=http,dst=:8080} :sout-keep [rest of the cmdline not relevant]

      

As long as there may be multiple audio devices on the computer (webcam, multiple sound cards, bluettoth devices ... etc), I need to programmatically get the name from them.

I have used FFMPEG so far:

ffmpeg -list_devices true -f dshow -i dummy

      

... but sometimes it doesn't work fine, for example:

d:\Utils\FFMPEG\bin>ffmpeg -list_devices true -f dshow -i dummy
ffmpeg version N-72460-g11aa050 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --ena
ble-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 26.100 / 54. 26.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 34.100 / 56. 34.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[dshow @ 0000000000363520] DirectShow video devices (some may be both video and
audio devices)
[dshow @ 0000000000363520] Could not enumerate video devices (or none found).
[dshow @ 0000000000363520] DirectShow audio devices
[dshow @ 0000000000363520] Could not enumerate audio only devices (or none found
).
dummy: Immediate exit requested

      

Command line tool SystemInfo

doesn't work:

C:\>systeminfo | find "audio" /i

C:\>

      

Searching inside regedit

found nothing about my soundcard example ( SoundMAX HD Audio I

).

Isn't there another more reliable way to programmatically get the name of the sound device ?

If possible, I would prefer to get answers for both Windows XP and Vista or later.

Additional tests performed :

  • Installed latest MicroSoft.NET FrameWork v4.5.2 and rebooted.
  • Tested old versions of FFMPEG: v4.8 (2014) and v4.7 (2013).
  • UAC elevated test prompt.
+3


source to share


1 answer


The answer is derived (thanks @Karan) from the above SuperUser thread.

First, FFMPEG must return the value of the device name. If not, try:

  • FFMPEG update to the latest version.
  • Update .NET FrameWork.
  • Please try a different version . Note that v4.7.3 doesn't seem to need the .NET Framework if that was the issue (pulled from this thread ).
  • For microphone devices, make sure the jack is plugged in. On some systems, the device appears to be disabled (disappears) if not. Of course, this does not apply to portable devices with a built-in (built-in) microphone.

As a second option, working (as of June 2015) for Vista and up and not requiring the 30-40MB FFMPEG download, you can try NirSoft 's SoundVolumeView. Send the values ​​to a .txt file and filter:

SoundVolumeView /scomma Audio.txt
for /f "tokens=1 delims=," %d in ('type Audio.txt ^| find "Capture"') do @echo Default recording device is: "%d"

      

As a third option, still for Vista and up, all audio input devices (capture and recording) can be deregistered (explained here by @Karan) by issuing this command line:



for /f "tokens=9 delims=\" %a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture" /s ^| find "\Properties"') do @for /f "tokens=2*" %k in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture\%a\Properties" /v "{a45c254e-df1c-4efd-8020-67d146a850e0},2"') do @echo "%l"

      

Note. Remember that when writing such devices, you may find special localized characters , such as the Spanish word Micrófono

for Microphone

. For example, FFMPEG will show it as rather odd Micrófono

.

All three of the above methods, including NirSoft, work fine on a remote console (like SSH).

Additional points:

  • Note that this answer solves the sound device name issue for writer / I / O devices only , so (except in the case of FFMPEG, maybe) the above methods are not valid or should be changed accordingly if you are looking for gaming.
0


source







All Articles