如何在单个流中组合多个实时(视频)流?这样输出将是单个视频中的多个(分割)视频?

时间:2010-04-30 06:47:36

标签: c# directx video-streaming

我对流媒体很新。 我的要求是将多个视频/流组合到单个视频中。 因此输出将是单个视频,在单个播放器中同时显示多个视频(如安全摄像机视频)。

这是我的示例代码---

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();

我尝试使用代码,但无法成功。它只显示一个控制和视频中的视频。没有显示其他人。

1 个答案:

答案 0 :(得分:0)

在DirectShow中查看VideoMixingRenderer。

此链接提供了如何使用C ++执行此操作的说明:

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

DirectShow的.NET包装器存在于此处:

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