如何将多个直播(视频)流合并为一个流?这样输出将是单个视频中的多个(分割)视频?
我对流媒体非常陌生。 我的要求是将多个视频/流组合成单个视频。 因此输出将是在单个播放器中同时显示多个视频的单个视频(如安全摄像头视频)。
这是我的示例代码——
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看DirectShow中的VideoMixinRenderer。
此链接提供了如何使用 C++ 执行此操作的说明:
http://www.codeproject .com/KB/directx/DirectShowVMR9.aspx
DirectShow 的 .NET 包装器位于此处:
http ://directshownet.sourceforge.net/about.html
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