我不确定这是否严格属于编程问题,只要我不介意使用其他软件来解决问题,并且保持可脚本化或命令行(即非GUI解决方案)。无论如何,我在 SuperUser 上发布了另一个(稍有不同)的问题。顺便说一句,如果我在那里得到答案,我会在这里更新。
只要计算机上有多个音频设备(网络摄像头,多个音频卡,蓝牙设备等),我需要以编程方式获取它们的名称。
到目前为止,我一直使用FFMPEG:
命令行工具
我的Windows程序(只是一个shell脚本)调用VLC命令行,以便从音频卡录制音频并将其流式传输出去,例如:
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]
只要计算机上有多个音频设备(网络摄像头,多个音频卡,蓝牙设备等),我需要以编程方式获取它们的名称。
到目前为止,我一直使用FFMPEG:
ffmpeg -list_devices true -f dshow -i dummy
...但有时它不能正常工作,例如:
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
命令行工具
SystemInfo
无法正常工作:C:\>systeminfo | find "audio" /i
C:\>
在regedit
中搜索并没有找到我的声卡示例(SoundMAX HD Audio I
)。
难道没有其他更可靠的方式可以通过编程方法获取声音设备名称吗?
如果可能的话,我希望获得Windows XP和Vista或更高版本的答案。
进行了其他测试:
- 安装了最新的MicroSoft .NET FrameWork v4.5.2并重新启动。
- 测试旧版FFMPEG:v4.8(2014)和v4.7(2013)。
- 测试了UAC提升提示。