如何多播使用 DirectShow 捕获的流?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/361220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:32:52  来源:igfitidea点击:

HowTo Multicast a Stream Captured with DirectShow?

c#videostreamingdirectshowmulticast

提问by

I have a requirement to build a very simple streaming server. It needs to be able to capture video from a device and then stream that video via multicast to several clients on a LAN.

我需要构建一个非常简单的流媒体服务器。它需要能够从设备捕获视频,然后通过多播将该视频流式传输到 LAN 上的多个客户端。

The capture part of this is pretty easy (in C#) thanks to a library someone wrote with DirectShow.Net (http://www.codeproject.com/KB/directx/directxcapture.aspx).

由于有人用 DirectShow.Net ( http://www.codeproject.com/KB/directx/directxcapture.aspx)编写的库,捕获部分非常容易(在 C# 中)。

The question I have now is how to multicast this? This is the part I'm stuck on. I'm not sure what to do next, or what steps to take.

我现在的问题是如何多播这个?这是我坚持的部分。我不确定接下来要做什么,或要采取什么步骤。

回答by faulty

To achieve that you need to setup/write some kind of video streaming server.

为此,您需要设置/编写某种视频流服务器。

I've used VideoCapXfor the same purpose on my project. The documentation and support is not top notch, but it's good enough. It's using WMV streaming technology. The stream is called MMSstream. You can view it with any most media player. I've tested with Windows Media Player, Media Player Classics and VLC. If you would like to see it's capability without writing any code just yet, take a look at U-Broadcast, it uses VideoCapX to do the job behind the scene.

我在我的项目中出于同样的目的使用了VideoCapX。文档和支持不是一流的,但已经足够了。它使用 WMV 流媒体技术。该流称为MMS流。您可以使用任何大多数媒体播放器查看它。我已经使用 Windows Media Player、Media Player Classics 和 VLC 进行了测试。如果您想在不编写任何代码的情况下查看它的功能,请查看U-Broadcast,它使用 VideoCapX 来完成幕后的工作。

I've been using DirectShow.Net for almost 2 years, and I still find it hard to write a streaming server myself, due to the complexity of DirectShow technology.

我已经使用 DirectShow.Net 将近 2 年了,由于 DirectShow 技术的复杂性,我仍然发现自己很难编写流媒体服务器。

Other than WMV, you can take a look at Helix Serveror Apple Streaming Server. The latter one is not free, so is WMV Streaming Server from Microsoft.

除了 WMV,您还可以看看Helix Server或 Apple Streaming Server。后者不是免费的,微软的 WMV Streaming Server 也是免费的。

You can also take a look at VLC or Windows Media Encoderto do streaming straight from the application. But so far I find U-Broadcast out do both of the above. VLC has some compatibility issue with codec and playback from non VLC player, WME has problem with starting up capturing device.

您还可以查看 VLC 或Windows Media Encoder以直接从应用程序进行流式传输。但到目前为止,我发现 U-Broadcast 可以做到以上两点。VLC 与非 VLC 播放器的编解码器和播放存在一些兼容性问题,WME 在启动捕获设备时存在问题。

Good Luck

祝你好运

NOTE: I'm not associated with VideoCapX or it's company, I'm just a happy user of it.

注意:我与 VideoCapX 或其公司无关,我只是它的快乐用户。

回答by Quassnoi

There are no filters available that you can plug and use.

没有可供您插入和使用的过滤器。

You need to do three things here:

你需要在这里做三件事:

  1. Compress the video into MPEG2 or MPEG4
  2. Mux it into MPEG Transport Stream
  3. Broadcast it
  1. 将视频压缩为 MPEG2 或 MPEG4
  2. 将其复用为 MPEG 传输流
  3. 广播它

There are lots of codecs available for part 1, and some devices can even output compressed video.

第 1 部分有很多可用的编解码器,有些设备甚至可以输出压缩视频。

The part 3 is quite simple too.

第3部分也很简单。

Main problem goes with part 2, as MPEG Transport Stream is patented. It is licensed so that you cannot develop free software based on it (VLC and FFMPEG violate that license), and you have to pay several hundred dollars just to obtain a copy of specification.

主要问题出现在第 2 部分,因为 MPEG 传输流已获得专利。它已获得许可,因此您不能基于它开发自由软件(VLC 和 FFMPEG 违反了该许可),并且您必须支付数百美元才能获得规范的副本。

If you have to develop it, you need to:

如果你必须开发它,你需要:

  • Obtain a copy of ISO/IEC 13818-1-2000 (you may download it as PDF from their site), it describes MPEG Transport Stream
  • Develop a renderer filter that takes MPEG Elementary Streams and muxes them into Transport Stream
  • 获取 ISO/IEC 13818-1-2000 的副本(您可以从他们的站点下载 PDF 格式),它描述了 MPEG 传输流
  • 开发一个渲染器过滤器,它接收 MPEG 基本流并将它们混合到传输流中

It has to be a renderer as Transport Stream is not a transform filter. There are some kind of outband data (program allocation tables and reference clocks) that need to be sent on a regular basis, and you need to keep a worker thread to do that.

它必须是渲染器,因为传输流不是转换过滤器。有一些带外数据(程序分配表和参考时钟)需要定期发送,您需要保留一个工作线程来执行此操作。

回答by rogerdpack

http://www.codeproject.com/KB/directx/DShowStreamingServer.aspxmight help, and http://en.wikipedia.org/wiki/VLC_media_player#cite_note-14

http://www.codeproject.com/KB/directx/DShowStreamingServer.aspx可能会有所帮助,而http://en.wikipedia.org/wiki/VLC_media_player#cite_note-14

VLC also "should" be able to stream from any device natively.

VLC 还“应该”能够从本机从任何设备流式传输。