I am not sure if this is strictly a programming question, as long as I don't mind to use additional software in order to solve the problem, as long as it keeps being scriptable or command-line (this is: a not GUI solution). Anyway, I have posted another (a bit different) question at SuperUser. By the way, I will update here if I get the answer there.
我的 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 或更高版本的答案。
执行的其他测试:
最佳答案
从上述 super 用户线程获得的答案(感谢@Karan)。
首先,FFMPEG 应该返回设备名称值。如果没有,请尝试:
作为第二个选项,仅适用于 Vista 及更高版本(截至今天,2015 年 6 月),并且不需要下载 30-40MB 的 FFMPEG,您可以尝试 SoundVolumeView来自 NirSoft。将值发送到 .txt 文件并通过执行以下操作进行过滤:
SoundVolumeView /scomma Audio.txt
for /f "tokens=1 delims=," %d in ('type Audio.txt ^| find "Capture"') do @echo Default recording device is: "%d"
作为第三个选项,仍然适用于 Vista 及更高版本,所有音频输入(捕获和录制)设备都可以通过发出此命令从寄存器中提取(由@Karan 解释 here)行:
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"
注意:请记住,在为此类设备编写脚本时,您会发现特殊的本地化字符,例如Microphone 的西类牙语单词Microfono。例如,FFMPEG 会将其显示为一些相当奇怪的 Microfono。
上述所有三种方法,包括 NirSoft 的方法,都可以在远程控制台(例如 SSH)上正常工作。
补充点:
关于Windows shell : How can I get the audio device(s) name(s)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30563471/
我正在使用这个:4.times{|i|assert_not_equal("content#{i+2}".constantize,object.first_content)}我之前声明过局部变量content1content2content3content4content5我得到的错误NameError:wrongconstantnamecontent2这个错误是什么意思?我很确定我想要content2=\ 最佳答案 你必须用一个大字母来调用ruby常量:Content2而不是content2。Aconstantnamestart
“输出”是一个序列化的OpenStruct。定义标题try(:output).try(:data).try(:title)结束什么会更好?:) 最佳答案 或者只是这样:deftitleoutput.data.titlerescuenilend 关于ruby-on-rails-更好的替代方法try(:output).try(:data).try(:name)?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.c
这个问题在这里已经有了答案:Whatdoes`if__FILE__==$0`meaninRuby(6个答案)关闭6年前。我在审查Ruby代码时偶然发现了这个语法。代码是:if__FILE__==$PROGRAM_NAME#somecode...end我想__FILE__是一个变量,可以让我获取我所在文件的名称?但是$PROGRAM_NAME简化了什么?另外,为什么这个if语句是必需的,因为程序可以使用或不使用它?
我知道还有其他相同的问题,但他们没有解决我的问题。我不断收到错误:Aws::Errors::MissingRegionErrorinBooksController#create,缺少区域;使用:region选项或将区域名称导出到ENV['AWS_REGION']。但是,这是我的配置开发.rb:config.paperclip_defaults={storage::s3,s3_host_name:"s3-us-west-2.amazonaws.com",s3_credentials:{bucket:ENV['AWS_BUCKET'],access_key_id:ENV['AWS_ACCE
我遇到了一些Ruby代码,我试图理解为什么变量在initialize方法声明中的名称末尾有冒号。冒号有什么原因吗?attr_reader:var1,:var2definitialize(var1:,var2:)@var1=var1@var2=var2end 最佳答案 那些是关键字参数。您可以按名称而非位置使用它们。例如ThatClass.new(var1:42,var2:"foo")或ThatClass.new(var2:"foo",var1:42)Anarticleaboutkeywordargumentsbythoughtbot
我希望生成一个链接,该链接的前缀附加到命名路由本身。像这样显示路径“/old/recipes”:recipes_path(:prefix=>"old/")#thecorrectwayshouldshow"/old/recipes"我不想动routes.rb文件,而是修改带前缀的命名路由。这可能吗?您将如何正确地做到这一点?编辑:我正在使用Rails3。添加可选前缀的原因是我也想使用普通的recipes_path。所以我想同时使用“/recipes”和“/old/recipes”。 最佳答案 如果您不想触及路由文件,您将会遇到很多麻烦
例如,:符号-我正在尝试弄清楚:的含义,以及它与@的区别也没有任何符号。如果有真正有用的指南! 最佳答案 它是一个符号,是一种Ruby语言结构。符号类似于字符串,但thisblogpost解释细节。@表示类的实例变量:它基本上是一个在类实例的所有方法之间共享的变量。它与:无关。 关于ruby-:meaninrailsbeforeavariablename?是什么,我们在StackOverflow上找到一个类似的问题: https://stackoverflow
我的应用程序有一个名为User的模型(它包括电子邮件地址、用户名……)我想创建一个模型Message它应该有两个字段sender和recipient。两者都是对User模型的引用。我试过这个:railsgeneratemodelMessagesender:referencesrecipient:referencesRails生成了这个:classMessage但我不想要两种不同的模型。这两个字段都应引用User。我正在运行Ruby2.0.0和Rails4.0.2。非常感谢任何帮助。如果您需要有关我的问题的更多信息,请询问我。 最佳答案
完成这个有困难。我正在使用seed.rb+factory_girl来使用rakedb:seed填充数据库。(我知道固定装置存在,但我想以这种方式完成,这只是一个示例,数据库将填充复杂的关联对象。)我的种子.rb:require'factory_girl_rails'["QM","CDC","SI","QS"].eachdo|n|FactoryGirl.create(:grau,nome:n)end还有我的/factories/graus.rbFactoryGirl.definedofactory:graudonomeendend但是当我运行时:rakedb:seed我得到:rakeab
我有一个表单,我想出现在每个页面的顶部,所以我将它包含在/app/views/layouts/application.html.erb文件中,但我收到错误undefinedmethodmodel_name'forNilClass:Class`尝试加载页面时。这是application.html.erb中的表单片段Addnewcontact这是我的/app/controllers/user_controller.rbclassUserController我认为我遇到了这个错误,因为表单位于application.html.erb文件中,我需要以某种方式指定路径,但话又说回来,我对Rail