How can I play H.264 RTSP video in Windows 8 Metro C# XAML app?

parsley72 picture parsley72 · Oct 21, 2012 · Viewed 10k times · Source

I have a device that provides an H.264 video stream from a URL like: rtsp://192.168.0.10:554/videoservice

Since this is live video I don't need to be able to control it (pause, rewind, etc), just play. Is this supported by MediaElement or another standard class, do I need something like Smooth Streaming Client SDK or is this a lot more complicated than I thought?

Update: I downloaded Microsoft's Player Framework but this doesn't play the stream either. I can't find anything in the examples about RTSP.

Update: I used Wireshark to compare the packets that VLC Media Player (which works) sends with MediaElement and Player Framework and neither of them seemed to use RTSP protocol. Instead they're sending WPAD packets to a different address, even though I've provided the IP address of the source. Why is this necessary? Is there any way of turning this behaviour off?

Answer

N_A picture N_A · Oct 31, 2012

See the post here. You need to wrap your data in MPEG-4 Part 14 containers and then pass them into MediaElement.SetSource. It appears you can't do this just using the documented API. Here is the important information from the link:

We don't support RTP but rather the MPEG-4 Part 14 container format. You will need to write our own source to be able to parse the data a pass it directly to the Microsoft decoder. At this time we do not have any samples on how to write a custom source and have it loaded from your Metro style app. Unfortunately it is not possible to simply use the documentation to figure out how to do this. I have been talking with Stan and we are trying to figure out how and when we can make this information available. As soon as this information is available I will announce it on my blog http://blogs.msdn.com/mediasdkstuff/.

Here is a list of supported video formats.

There is also an example here of how to extend the media class which might have an example of how to do something similar to what you are asking.

There is a similar example here.