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.
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.
Windows Media Player supports RTSP but only from a Microsoft Windows Media Services server as it is a closed streaming media ecosystem.
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();
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With