Wpf – Play rtsp stream in WPF (or WinForms)

mediaelementrtspwinformswpf

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.

Best Answer

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();
Related Topic