开发者

How can I use WPF MediaKit, or a similar program, for rendering from a DirectShow filter graph created with DES on to a WPF control?

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.

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)

The initial line of thought (my bru开发者_C百科te 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.

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.

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 ...


Doing this from memory.

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

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

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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜