在 DirectShow 之外使用 DirectShow 过滤器?
我目前正在处理 Windows Media Foundation。但是,由于 Microsoft H.264 解码器存在一些问题,并且缺少一些自定义格式的解码器,我想知道是否可以直接使用 CLSID 实例化 DirectShow 解码器,并围绕它构建一个公开 IMFTransform 的代理获取媒体基金会的解码器。所以这是我的问题:
我可以直接实例化 Directshow 过滤器(最好是解码器)并使用它们进行解码(即放置一些压缩帧并获取未压缩的帧)以创建 MFT?
我知道如何使用过滤器的 CLSID 实例化过滤器本身。但是,我不知道如何使用实际的解码功能。
任何想法、提示、链接都将不胜感激。谢谢,
J。
I'm currently dealing with Windows Media Foundation. However, due to some problems with the Microsoft H.264 decoder and some missing decoders for custom format, I'd like to know if it would be possible to instantiate a DirectShow Decoder directly using CLSID, and build a proxy around it that exposes IMFTransform to get a decoder for Media Foundation. So here is my question:
Can i instantiate a Directshow filter (preferrably decoders) directly and use them for decoding (i.e. put some compressed frames and get uncompressed ones) to create a MFT?
I know how to instantiate the filter itself using its CLSID. However, I have no clue how to use the actual decoding functionality.
Any ideas, hints, links whatever will be appreciated. Thanks,
J.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(免责声明:我从未真正这样做过,但我认为没有技术原因无法做到这一点。所以 YMMV)
如果解码器是 DMO 过滤器,那么它会容易得多 - 你可以通过 IMediaObject。这与 DirectShow 使用 DMO 的方式没有太大区别;它只是用另一个处理媒体类型协商和样本传递的转换过滤器包装 DMO,但没有什么真正阻止您在自己的应用程序中执行此操作。
有一个问题:对于 IMediaObject::ProcessInput 和 IMediaObject::ProcessOutput,您需要自己的缓冲区类来实现 IMediaBuffer。但它是一个非常基本的界面,所以我认为您在实现它时不会遇到太多麻烦。这是基本实现。
对于常规的 directshow 过滤器,这实际上要困难得多,因为大多数 DirectShow 过滤器实际上依赖于可用的外部图(举个例子:所有的 directshow 事件都假定该图的存在)。如果您确实想独立使用单个 DShow 过滤器,您可能必须包装整个过滤器图表,然后使用自定义源过滤器来输入样本。您可以使用样本采集器(或自定义渲染过滤器)来从图表中提取样本并暴露给应用程序的其余部分。 (一种疯狂的想法甚至是将这个图包装在 DMO 过滤器实现中,然后使用 IMediaObject 与之对话 - 然而,这可能很棘手)
幸运的是,大多数解码器都倾向于实现作为 DMO 过滤器,所以我认为您很有可能只使用 IMediaObject。
(disclaimer: I have never actually done this, but I see no technical reason it cannot be done. So YMMV)
If the decoder is a DMO filter, then it'll be a lot easier--you can talk to it through IMediaObject. This isn't really much different from how DirectShow uses DMOs; it simply wraps the DMO with another transform filter that handles the media type negotiation and sample passing, but there's nothing really stopping you from doing this in your own application.
There's one catch: for IMediaObject::ProcessInput and IMediaObject::ProcessOutput, you'll need your own buffer class that implements IMediaBuffer. But it's a pretty basic interface, so I don't think you'll have too much trouble implementing it. Here's a basic implementation.
For regular directshow filters, it's actually going to be a lot more difficult, because most DirectShow filters really depend on there being an external graph available (case in point: all of the directshow eventing sort of presumes the existence of this graph). If you really want to use a single DShow filter standalone, you'd probably have to wrap the entire filter graph, and then have a custom source filter to feed samples in. You could use the sample grabber (or a custom render filter) to yank samples out of the graph and expose to the rest of the application. (one sort of crazy idea would even be to wrap this graph in a DMO filter implementation, and then use IMediaObject to talk to it--this might be tricky, however)
Luckily most decoders tend to be implemented as DMO filters, so I think there's a strong likelihood that you can just use IMediaObject.
我不确定你为什么要这样做。您真的不希望过滤器位于图表之外。
如果您不想使用传统的文件/网络源过滤器或传统的渲染器,您可以编写缓冲区渲染器和缓冲区源过滤器,将指针传递给它们并从中获取指针。然后,您可以将整个混乱放入图表中并运行它,并且几乎直接使用解码器而无需任何其他操作。这并不难做到。不过,解码器可能期待 PES 数据包流。
I'm unsure as to why you would want to do this. You don't really want a filter living outside of a graph.
If you don't want to use the traditional file / network source filters, or the traditional renderers, you can write buffer renderers, and buffer source filters, that you pass pointers to, and get pointers from. Then you can drop the whole mess into a graph and run it, and get the use of the decoder pretty much directly without anything else. This wouldn't be difficult to do. The decoder is probably expecting a PES packet stream though.