Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play rtsp stream in WPF (or WinForms)

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.

like image 513
wpfwannabe Avatar asked Apr 23 '12 12:04

wpfwannabe


People also ask

How do I play RTSP streams?

Step 1: Download and install VLC Player from http://www.videolan.org/vlc/. Step 2: Open VLC player and select“Open Network Stream”from the Media menu. Step 3: Type the network URL in the dialog box below, and then click Play to play the video with RTSP stream.

Can Windows Media Player play RTSP stream?

Windows Media Player supports RTSP but only from a Microsoft Windows Media Services server as it is a closed streaming media ecosystem.


2 Answers

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();
like image 157
Denis Stepanenko Avatar answered Sep 22 '22 22:09

Denis Stepanenko


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.

like image 38
wpfwannabe Avatar answered Sep 24 '22 22:09

wpfwannabe