如何在不同的文件中重用 DirectShow 过滤图

发布于 2024-11-03 01:32:02 字数 1178 浏览 4 评论 0原文

我有一个使用 filterGraph.RenderEx() 创建 directshow 图形的应用程序; 由于1可能需要很长时间才能启动并运行图表,因此我想在应用程序启动时创建一些图表,然后通过更改源文件来重用它们。即

  1. 播放 file1.wmv
  2. 等待文件完成 将
  3. 图表更改为指向 file2.wmv
  4. 播放 file2

如何更改源文件,以便不必为下一个文件重新创建整个图表?

编辑:::

我不是想连续播放文件,而是重叠播放文件。这些图形实际上是作为 d3d 应用程序的一部分渲染到texture2d 对象。

这就是我正在做的事情。 我使用以下方法添加源过滤器:

IBaseFilter sourceFilter;
int hr = filterGraph.AddSourceFilter(file, file, out sourceFilter);
/* We will want to enum all the pins on the source filter */

IEnumPins pinEnum;
hr = sourceFilter.EnumPins(out pinEnum);
DsError.ThrowExceptionForHR(hr);

IntPtr fetched = IntPtr.Zero;
IPin[] pins = { null };

/* Counter for how many pins successfully rendered */
int pinsRendered = 0;

/* Loop over each pin of the source filter */
while (pinEnum.Next(pins.Length, pins, fetched) == 0)
{
     if (filterGraph.RenderEx(pins[0], AMRenderExFlags.None, IntPtr.Zero) >= 0)
         pinsRendered++;

     Marshal.ReleaseComObject(pins[0]);
}
Marshal.ReleaseComObject(pinEnum);

当文件播放完毕后,在将来的某个时刻,我想将源过滤器设置为另一个文件(相同类型),因此我不必完全重建图表创建起来可能会非常慢。 有什么我可以将 sourceFilter 对象转换为允许我将其设置为另一个文件的东西吗?

I have an application the creates directshow graphs using filterGraph.RenderEx();
since 1it can take a long time to get the graph up and running, I would like to create a few graphs at the start of the app and then reuse them by changing the source file. ie

  1. play file1.wmv
  2. wait for file to finish
  3. change the graph to point to file2.wmv
  4. play file2

How do you change the source file so you do not have to recreate the entire graph for the next file?

Edit:::

I am not trying to play files back to back, but overlapping. The graphs are actually rendering to texture2d objects as part of a d3d application.

Here is what I am doing.
I am adding a sourceFilter using:

IBaseFilter sourceFilter;
int hr = filterGraph.AddSourceFilter(file, file, out sourceFilter);
/* We will want to enum all the pins on the source filter */

IEnumPins pinEnum;
hr = sourceFilter.EnumPins(out pinEnum);
DsError.ThrowExceptionForHR(hr);

IntPtr fetched = IntPtr.Zero;
IPin[] pins = { null };

/* Counter for how many pins successfully rendered */
int pinsRendered = 0;

/* Loop over each pin of the source filter */
while (pinEnum.Next(pins.Length, pins, fetched) == 0)
{
     if (filterGraph.RenderEx(pins[0], AMRenderExFlags.None, IntPtr.Zero) >= 0)
         pinsRendered++;

     Marshal.ReleaseComObject(pins[0]);
}
Marshal.ReleaseComObject(pinEnum);

When the file is done playing, at some point in the future,I would like to set the source filter to another file(of the same type), so i don't have to completely rebuild the graph which can be very slow to create.
Is there something i can cast the sourceFilter object to that allows me to set it to another file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯角 2024-11-10 01:32:02

GMFBridge 可用于此目的。 AFAIK 有 .NET 端口。查看 http://directshownet.sourceforge.net/about.html

使用智能连接可能会减慢速度图形构建过程。使用直接连接也可以加快该过程。

The GMFBridge can be used for this. There are ports to .NET AFAIK. Have a look at the GMFPlay application mentioned at http://directshownet.sourceforge.net/about.html.

Using intelligent connect can slow down the graph building process. Using direct connections should speed up the process as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文