views:

263

answers:

1

Hello,

I am very new to the streaming. My requirement is to combine multiple videos/streams in to single video. So output will be single video showing multiple videos simultaneously in single player(Like security camera video).

Here is my sample code---

IGraphBuilder oFilterGraph = (IGraphBuilder)new FilterGraph(); VideoMixingRenderer9 oVideoMixingRenderer = new VideoMixingRenderer9(); oFilterGraph.AddFilter((IBaseFilter)oVideoMixingRenderer, "Video");

            IVMRFilterConfig9 oVMRFilterConfig = (IVMRFilterConfig9)oVideoMixingRenderer;
            oVMRFilterConfig.SetRenderingMode(VMR9Mode.Windowed);
            oVMRFilterConfig.SetNumberOfStreams(2);
            oVMRFilterConfig.SetRenderingPrefs(VMR9RenderPrefs.None);             

            IVMRMixerControl9 oIVMRMixerControl = (IVMRMixerControl9)oVideoMixingRenderer;

            NormalizedRect oNormalizedRect = new NormalizedRect();
            oNormalizedRect.left = 0.0F;
            oNormalizedRect.top = 0.0F;
            oNormalizedRect.bottom = 0.5F;
            oNormalizedRect.right = 0.5F;

            NormalizedRect oNormalizedRect1 = new NormalizedRect();
            oNormalizedRect.left = 0.5F;
            oNormalizedRect.top = 0.5F;
            oNormalizedRect.bottom = 1;
            oNormalizedRect.right = 1;

            int iStreamId1 = oFilterGraph.RenderFile("c:\\file1.wmv", string.Empty);
            int iStreamId2 = oFilterGraph.RenderFile("c:\\file2.wmv", string.Empty);

            oIVMRMixerControl.SetOutputRect(0, ref oNormalizedRect);
            oIVMRMixerControl.SetOutputRect(1, ref oNormalizedRect1);          

            oIVMRMixerControl.SetAlpha(0, 1);
            oIVMRMixerControl.SetAlpha(1, 1);

            IMediaControl oMediaControl = (IMediaControl)oFilterGraph;
            oMediaControl.Run();

I tried with the code but could not succeed. It is showing only one video in control & not showing other one.

A: 

Look at the VideoMixingRenderer in DirectShow.

This link provides an explanation of how to do it using C++:

http://www.codeproject.com/KB/directx/DirectShowVMR9.aspx

A .NET wrapper for DirectShow exists here:

http://directshownet.sourceforge.net/about.html

Goz
Could you please give some .net snippet for VideoMixingRenderer?Where should I get the related information?
Shashank