如何将多个直播(视频)流合并为一个流?这样输出将是单个视频中的多个(分割)视频?

发布于 2024-08-30 11:25:55 字数 1459 浏览 5 评论 0原文

我对流媒体非常陌生。 我的要求是将多个视频/流组合成单个视频。 因此输出将是在单个播放器中同时显示多个视频的单个视频(如安全摄像头视频)。

这是我的示例代码——

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

香草可樂 2024-09-06 11:25:55

看看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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文