如何在不同的文件中重用 DirectShow 过滤图
我有一个使用 filterGraph.RenderEx() 创建 directshow 图形的应用程序; 由于1可能需要很长时间才能启动并运行图表,因此我想在应用程序启动时创建一些图表,然后通过更改源文件来重用它们。即
- 播放 file1.wmv
- 等待文件完成 将
- 图表更改为指向 file2.wmv
- 播放 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
- play file1.wmv
- wait for file to finish
- change the graph to point to file2.wmv
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.