5

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

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

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

VLC plays the rtsp stream just fine.

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

Community
  • 1
  • 1
wpfwannabe
  • 14,587
  • 16
  • 78
  • 129
  • did you ever find an alternative that did not require VLC to be installed? – Roger Sep 10 '14 at 22:05
  • Actually, yes. VLC need not be installed. You can have your own copy of VLC (from ZIP) side-by-side with your app/components and reference that instead. I can't recall the details but I am sure I ended up using my own local copy of VLC (which was not registered as a system media player). – wpfwannabe Sep 11 '14 at 11:24

3 Answers3

9

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).

Example:

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

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

reader.Close();
live2
  • 3,771
  • 2
  • 37
  • 46
Denis Stepanenko
  • 510
  • 6
  • 14
  • This is a terribly inefficient library for showing live video (at least in WPF) but it worked perfectly for the project I was working on. – Dan Aug 11 '16 at 13:23
2

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

I hope this helps someone else too.

wpfwannabe
  • 14,587
  • 16
  • 78
  • 129
2

Better late than never; take a look at this 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.

Community
  • 1
  • 1
Sasha Yakobchuk
  • 471
  • 6
  • 12