在 WPF(或 WinForms)中播放 rtsp 流

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10280794/
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-09-08 23:23:55  来源:igfitidea点击:

Play rtsp stream in WPF (or WinForms)

wpfwinformsrtspmediaelement

提问by wpfwannabe

Is there a way to play a rtsp:// stream in WPF (or alternatively WinForms)?

有没有办法在 WPF(或 WinForms)中播放 rtsp:// 流?

I have tried MediaElementand MediaUriElementand none of them worked. I have also read a lot about WMP being able to play rtsp (which should translate to MediaElementtoo) but in reality WMP doesn't play it on a Windows 7 x64. I have seen thisbut I am hoping that is not a definite answer.

我试过了MediaElementMediaUriElement但没有一个奏效。我还阅读了很多关于 WMP 能够播放 rtsp(也应该转换为MediaElement)的内容,但实际上 WMP 不能在 Windows 7 x64 上播放。我已经看到了这个,但我希望这不是一个明确的答案。

Has this anything to do with the video codec being used?

这与正在使用的视频编解码器有关吗?

VLC plays the rtsp stream just fine.

VLC 播放 rtsp 流就好了。

I am looking for either a WPF or WinForms component or an alternative solution.

我正在寻找 WPF 或 WinForms 组件或替代解决方案。

采纳答案by wpfwannabe

I have found VideoLan DotNet for WinForm, WPF & Silverlight 5which seems to do the trick for now. The downside is that you need to have VLC installed. It is not a standalone thing.

我找到了适用于 WinForm、WPF 和 Silverlight 5 的 VideoLan DotNet,它现在似乎可以解决问题。缺点是您需要安装 VLC。它不是一个独立的东西。

I hope this helps someone else too.

我希望这对其他人也有帮助。

回答by Denis Stepanenko

Try Accord.Net (http://accord-framework.net/). It has a very simple interface and is available as a nuget package (Accord.Video.FFMPEG). It can be used to retrieve a Bitmap instance which can be used in WinForms/WPF. The downside is that it doesn't support Mono (not sure what platform you're targeting).

试试 Accord.Net ( http://accord-framework.net/)。它有一个非常简单的界面,可以作为 nuget 包 (Accord.Video.FFMPEG) 使用。它可用于检索可在 WinForms/WPF 中使用的位图实例。缺点是它不支持 Mono(不确定您的目标平台是什么)。

Example:

例子:

VideoFileReader reader = new VideoFileReader();
reader.Open("rtsp://192.168......");

while (true)
{
   Bitmap frame = reader.ReadVideoFrame();
   //Do whatever with the frame...
}

reader.Close();

回答by Sasha Yakobchuk

Better late than never; take a look at this control: http://www.codeproject.com/Articles/885869/Stream-Player-control

迟到总比不到好; 看看这个控件:http: //www.codeproject.com/Articles/885869/Stream-Player-control

It is a FFmpeg-based stream player control, which can do the following:

  1. Play a RTSP/RTMP video stream
  2. Retrieve the current frame being displayed by the control

The control has no additional dependencies and a minimalistic interface.

Requirements

  1. The WinForms version of the control is implemented using .NET Framework 2.0
  2. The WPF version of the control is implemented using .NET Framework 4 Client Profile

Both versions are built using the x86 platform target.

它是一个基于FFmpeg的流播放器控件,可以做以下事情:

  1. 播放 RTSP/RTMP 视频流
  2. 检索控件显示的当前帧

该控件没有额外的依赖项和简约的界面。

要求

  1. WinForms 版本的控件是使用 .NET Framework 2.0 实现的
  2. 该控件的 WPF 版本是使用 .NET Framework 4 Client Profile 实现的

两个版本都是使用 x86 平台目标构建的。