问题
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