将DirectShow音频设备录制到文件 [英] Record directshow audio device to file

查看:79
本文介绍了将DirectShow音频设备录制到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶然发现了一些代码来枚举我的麦克风设备(得到一些帮助),并且能够从每个设备中获取好记的名称"和"clsid"信息.

I've stumbled through some code to enumerate my microphone devices (with some help), and am able to grab the "friendly name" and "clsid" information from each device.

我已经对GraphEd.exe进行了一些修补,以尝试弄清楚如何从DirectShow中获取音频并将其写入文件(我目前不关心格式,WAV应该可以),并且可以似乎找不到合适的组合.

I've done some tinkering with GraphEd.exe to try and figure out how I can take audio from directshow and write it to a file (I'm not currently concerned about the format, wav should be fine), and can't seem to find the right combination.

我读过的其中一篇文章链接到此Windows SDK示例,但是当我检查代码时,我最终对如何使用该代码感到困惑.设置输出文件,或指定要使用的音频捕获设备.

One of the articles I've read linked to this Windows SDK sample, but when I examined the code, I ended up getting pretty confused at how to use that code, ie. setting the output file, or specifying which audio capture device to use.

我还遇到了

I also came across a codeguru article that has a nicely featured audio recorder, but it does not have an interface for selecting the audio device, and I can't seem to find where it statically picks which recording device to use.

我想我最想知道如何使用Windows SDK示例,但是对这两种方法中的任何一种的解释都是很棒的.

I think I'd be most interested in figuring out how to use the Windows SDK sample, but any explanation on either of the two approaches would be fantastic.

编辑:作为Win32 COM程序员,我的知识和能力在规模上非常低,因此,如果这很容易,请像我五岁时向我解释一下.

Edit: I should mention my knowledge and ability as a win32 COM programmer is very low on the scale, so if this is easy, just explain it to me like I'm five, please.

推荐答案

使用DirectShow将音频记录到文件中需要您构建正确的过滤器图,因为您应该已经知道了.这些部分包括:

Recording audio into file with DirectShow needs you to build the right filter graph, as you should have figured out already. The parts include:

  1. 您可以通过绰号(不是CLSID!)实例化设备本身,通常是PCM格式
  2. 将流转换为容器格式的Multiplexer组件
  3. 文件编写器过滤器,可接收文件兼容的流并将其写入文件

棘手的时刻是#2,因为没有可用的标准组件.但是,Windows SDK示例包含缺少的部分-

The tricky moment is #2 since there is not standard component available. Windows SDK samples however contains the missing part - WavDest Filter Sample. Building it and making it ready for use, you can build a graph that records from device into .WAV file.

您的图表将如下所示,并且它也易于通过编程方式构建:

Your graph will look like this, and it's built easily programmatically as well:

我注意到我在Google Earth上安装了WavDest的一个变体-如果您无法自行构建它,那么您将在寻找预构建的二进制文件.

I noticed that I have a variation of WavDest installed with Google Earth - for the case you have troubles building it yourself and you will be looking for prebuilt binary.

这篇关于将DirectShow音频设备录制到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆