如何使用WPF MediaKit,或类似的程序,从使用DES上创建一个WPF控件的DirectShow过滤器图形渲染?过滤器、如何使用、控件、创建一个

2023-09-03 22:24:47 作者:清故宸凉

我已经开发使用C#和DirectShow.net一个简单的视频编辑器。截至目前,我已经使用DirectShow编辑服务构建一个DirectShow过滤器图表。我的应用程序控制图,运行,暂停并根据需要停止播放在preVIEW窗口。在编辑会议上,图形被根据用户的要求进行添加,删除或修改的介质改变。

I have developed a simple video editor using C# and DirectShow.net. As of now, I have a DirectShow filter graph built using DirectShow Editing Services. My application controls the graph, runs, pauses and stops the playback in a preview window as needed. In an editing session, the graph gets changed according to user requests to add, remove or modify the media.

目前我用裹成的WindowsFormsHost至preVIEW编辑视频图片框。但我真的想尝试使用耶利米莫雷尔的WPF MediaKit代替。 (HTTP://wpfmediakit.$c$cplex.com)

Currently I use a PictureBox wrapped into WindowsFormsHost to preview edited videos. But I really want to try using Jeremiah Morril’s WPF MediaKit instead. (http://wpfmediakit.codeplex.com)

思想(我的蛮力方法)的初始行是从我的图传的IGraphBuilder和宜宾到在WPF MediaKit MediaUriPlayer.cs的开放源代码()函数,使VMR9渲染器,并将连接到现有图而不是创建一个新的图,因为它是在原来的开源做的()。这并没有制定出很好的,我尝试各种组合,大部分的时间去错误与其基础RCW分离的COM对象后,就放弃了。

The initial line of thought (my brute force approach) was to pass IGraphBuilder and IPin from my graph to the OpenSource() function in MediaUriPlayer.cs in WPF MediaKit, so that a VMR9 renderer is added and connected to my existing graph instead of creating a new graph as it is done in the original OpenSource(). This did not work out nicely, and I gave up after trying various combinations and most of the time getting the "COM object separated from its underlying RCW" error.

在最初的失败,我搜索,碰到莫里尔的类似VideoRendererElement在 HTTP://videorendererelement.$c$ cplex.com 。看来,它不会太难样本采集卡添加到我的DirectShow图形,并用它来发送样品VideoRendererElement。这将是就像附带VideoRendererElement摄像头的例子。

Following the initial failure, I searched and came across Morrill’s similar VideoRendererElement at http://videorendererelement.codeplex.com. It seems that it won’t be too hard to add a sample grabber to my DirectShow graph and use it to send samples to VideoRendererElement. It would be just like the webcam example that is included with VideoRendererElement.

最后,我想知道,如果它不会是可能使用任何从WPF MediaKit较新的控件以同样的方式,即通过将样品从样品采集卡在我的图到MediaUriElement,DvdPlayerElement,或从WPF MediaKit收集另一个控制。从本质上讲,我的问题是:谁能推荐使用WPF MediaKit或VideoRenderingElement来实现这个样本采集方案?或者,也许有人可以建议我的DES制成的过滤图一个更好的方式来呈现到一个WPF控件...

Finally, I’m wondering if it would not it be possible to use any of the newer controls from WPF MediaKit in the same way, that is by passing samples from a sample grabber in my graph to a MediaUriElement, DvdPlayerElement, or another control from the WPF MediaKit collection. Essentially my question is: Can anyone recommend using WPF MediaKit or VideoRenderingElement to implement this sample grabber scenario? Or perhaps someone can suggest an even better way for my DES made filter graph to render into a WPF control ...

推荐答案

从内存中执行此操作。

因为它听起来就像你有一个自定义的DirectShow图形。我只想肠道WPF MediaKit几件事情:

Since it sounds like you have a custom DirectShow graph. I would just gut WPF MediaKit for a few things:

取D3DRenderer基类。这应该可以很容易地使D3D内容D3DImage。就拿VMR9分配器和D3D9互操作的东西。

Take the D3DRenderer base class. This should make it easy to render D3D content with D3DImage. Take the VMR9 allocator and D3D9 interop stuff.

我假设你正在使用的VideoMixingRenderer9 ......因此,在您code当您创建VMR9,得到VMR9界面,可以让你设置一个自定义分配器(一个例子应该是在基类的CreateRenderer方法。 CS)。实例化从MediaKit抬高自定义的分配器,并把它传递到接口。该分配器有一个事件触发时,它得到一个新的D3D表面,当一个新的帧准备present。确保D3DRenderer类获取这些事件(新的表面,新帧)。应该是90%,复制和粘贴操作:)

I assume you are using the VideoMixingRenderer9...So in your code when you create the VMR9, get the VMR9 interface that lets you set a custom allocator (an example should be in the CreateRenderer method in the baseclass.cs). Instantiate the custom allocator you jacked from MediaKit and pass it to the interface. That allocator has an event that fires when it gets a new d3d surface and when a new frame is ready to present. Make sure the D3DRenderer class gets these events (new surface, new frame). Should be a 90% copy and paste operation :)