如何在 directshow 中分割音频或编写解复用器过滤器?
我需要将最多 16 个通道的 PCM 音频流拆分为多个立体声流。 由于我还没有找到任何能够做到这一点的东西,所以我正在尝试编写我的第一个 directshow 过滤器。
任何能够分割音频的东西都会非常受欢迎,但我假设我必须这样做,所以这就是我所做的:
首先,我尝试创建一个基于 ITransformFilter 的过滤器。然而,似乎它考虑了只有一个输入引脚和一个输出引脚的滤波器。由于我需要多个输出引脚,因此我忽略了它,但是也许它可以比我想象的更容易调整,因此非常感谢任何建议。
然后,我开始基于 IBaseFilter。我设法做了一些事情。当输入引脚连接时,我创建必要的输出引脚,并在输入断开时销毁它们。然而,当我将任何输出引脚连接到 ACM 包装器(只是为了测试它)时,输入会尝试重新连接,从而破坏了我的所有输出引脚。 我试图不破坏它们,但后来我检查了输入引脚的媒体类型,它已更改为立体声流。我没有从我的代码中调用 QueryAccept。
我怎样才能避免重新连接,或者进行多路分配器过滤器的正确方法是什么?
编辑2010-07-09: 我回到了 ITransformFilter,但我正在创建必要的引脚。然而,我遇到了与 IBaseFilter 相同的问题:当我将输出引脚连接到 ACM 包装器时,输入引脚将其媒体类型更改为 2 个通道。 现在不知道如何继续...
I need to split a PCM audio stream with up to 16 channels into several stereo streams.
As I haven't found anything capable of doing that, I'm trying to write my first directshow filter.
Anything capable of splitting the audio would be very welcomed but I'm assuming that I must do it so there's what I've done:
At first, I tried to create a filter based on ITransformFilter. However, it seems that it's made thinking of filters with only one input pin and one output pin. As I need several output pins, I disregarded it, however perhaps it can be adapted more easily than I thought, so any advice is highly appreciated.
Then, I begin basing on IBaseFilter. I managed to do something. I create the necessary output pins when the input pin gets connected, and destroy them when the input gets disconnected. However, when I connect any output pin to an ACM Wrapper (just to test it), the input tries to reconnect, destroying all my output pins.
I tried to just not destroy them, but then I checked the media type of my input pin and it had changed to a stereo stream. I'm not calling QueryAccept from my code.
How could I avoid the reconnection, or what's the right way to do a demuxer filter?
Edit 2010-07-09:
I've come back to ITransformFilter, but I'm creating the necessary pins. However I've encountered the same problem as with IBaseFilter: When I connect my output pin to an ACM Wrapper, the input pins changes its mediatype to 2 channels.
Not sure how to proceed now...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看Windows Server 2003 R2 Platform SDK中的DMOSample。它也包含在较旧的 directx sdk 中,但不包含在较新的 windows sdk 中。您可以在 Samples\Multimedia\DirectShow\DMO\DMOSample 中找到它。 此处是此示例的文档。
我见过有人基于此创建了一个滤波器,它有一个立体声输入和两个单声道输出。不幸的是我无法发布源代码。
You can take a look at the DMOSample in the Windows Server 2003 R2 Platform SDK. It is also included in older directx sdk's, but not in newer windows sdk's. You can locate it in Samples\Multimedia\DirectShow\DMO\DMOSample. Here is the documentation of this sample.
I have seen someone create a filter based on this which had a stereo input and two mono outputs. Unfortunately I cannot post the sourcecode.