Can one Video Mixing Renderer 9 (VMR9) render more video streams?

不打扰是莪最后的温柔 提交于 2019-12-24 02:23:34

问题


I am rendering a number of video streams in a Windows form, using the same number of VMR9 instances. I am doing this in C# using DirectShowLib-2005.

If there is a need to display 100 videos, I will create 100 FilterGraphs (IFilterGraph2) that will hold one VMR9 instance (VideoMixingRenderer9) each, that will each render 1 video stream.

This uses up the RAM quickly...

Can I make one VMR9 filter render more than one video stream, so I have less VMR9 instances, and more number of video streams rendered?

Any help will be appreciated.


回答1:


Well... I figured it out... if someone has a better example, please post it here, I will mark it as an accepted answer.

The graph:

If you render this in GrapgEdit (or something else) it displays the first (Input0) stream and the second one (Input1) underneath it, but I want them to be visible at the same time!

To do this, VMR9 must be configured as such (error handling and some VMR9 configuration omitted):

//Setting VMR9 to run in WINDOWLESS MODE
filterConfig = (IVMRFilterConfig9)vmr;
filterConfig.SetRenderingMode(VMR9Mode.Windowless);

//Number of streams that I want to render together (mix)
filterConfig.SetNumberOfStreams(2);

//Get the MIXER CONTROL that will be used to configure video rendering surfaces
mixerCtrl = (IVMRMixerControl9)vmr;

//*** RENDER THE PINS SO THE GRAPH CONNECTS CORRECTLY (omitted) ***

//Define areas of the clipping window that will be covered by each video stream
NormalizedRect r1 = new NormalizedRect(0,0,0.5f, 0.5f);
NormalizedRect r2 = new NormalizedRect(0.5f, 0.5f, 1f, 1f);

//For each stream (0 and 1) set the output rect
mixerCtrl.SetOutputRect(0, ref r1);
mixerCtrl.SetOutputRect(1, ref r2);

After this, the streams are rendered in top left and bottom right portion of the clipping window, and they are both shown and rendered correctly!!!

If you want to display more video streams, just SetNumberOfStreams accordingly, and configure NormalizedRect for each one. This way I can render more streams with one VMR9 instance, and I don't need to worry about RAM running out.

Now the true coolness of VMR9 shows up... :D xD

PS It looks like 16 streams is the limit...



来源:https://stackoverflow.com/questions/5881812/can-one-video-mixing-renderer-9-vmr9-render-more-video-streams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!