DirectShow:Graph在GraphEdit中工作,而不是在代码中工作

时间:2023-02-02 08:01:39

I've built the following graph in GraphEdit: Logitech Webcam -> Infinite Tee Pin Filter -> VideoRenderer. This works fine (with GraphEdit automatically inserting a few intermediate filters between the TEe filter and the VideoRenderer filter).

我在GraphEdit中构建了以下图形:Logitech Webcam - > Infinite Tee Pin Filter - > VideoRenderer。这很好用(GraphEdit自动在TEe过滤器和VideoRenderer过滤器之间插入一些中间过滤器)。

I've tried doing the same thing in code, and it fails when trying to connect the Tee filter to the VideoRenderer. I connect the webcam to the tee filter first, which works (the webcam turns on and I get S_OK), and then I attempt to connect the single output pin from the tee filter to the first, which fails (the error is that it could not find a set of intermediate filters to connect them). I've tried connecting them with both IGraphBuilder::Connect as well as ICaptureGraphBuilder2::RenderStream, with the same effect. To enumerate the pins, I use hr = _CaptureGraphBuilder.FindPin(theFilter, PinDirection.Input, null, null, true, 0, out thePin); for the video renderer, and the same except with PinDirection.Output for the Tee Filter (this is in C#, but the construct maps exactly to C++).

我尝试在代码中做同样的事情,并且在尝试将Tee过滤器连接到VideoRenderer时失败了。我首先将网络摄像头连接到tee过滤器,这是有效的(网络摄像头打开,我得到S_OK),然后我尝试将tee过滤器的单个输出引脚连接到第一个,这是失败的(错误是它可以没有找到一组中间过滤器来连接它们)。我尝试将它们与IGraphBuilder :: Connect以及ICaptureGraphBuilder2 :: RenderStream连接起来,效果相同。为了枚举引脚,我使用hr = _CaptureGraphBuilder.FindPin(theFilter,PinDirection.Input,null,null,true,0,out thePin);对于视频渲染器,除了使用Tee Filter的PinDirection.Output之外(这是在C#中,但构造完全映射到C ++)。

Any ideas?

1 个解决方案

#1


Found the problem. Apparently, the Webcam filter doesn't update its output media types correctly until the graph is started. So starting the graph, then restarting the graph once everything is done did the trick.

发现了问题。显然,Webcam过滤器在图表启动之前不会正确更新其输出媒体类型。因此,启动图表,然后在完成所有操作后重新启动图表就可以了。

#1


Found the problem. Apparently, the Webcam filter doesn't update its output media types correctly until the graph is started. So starting the graph, then restarting the graph once everything is done did the trick.

发现了问题。显然,Webcam过滤器在图表启动之前不会正确更新其输出媒体类型。因此,启动图表,然后在完成所有操作后重新启动图表就可以了。

相关文章