I need to display a live video stream in a UWP application.
The video stream comes from GoPro. It is carried by UDP messages. I think this is a TS MPEG-2 stream.
I can successfully play it using FFPlay with the following command line:
ffplay -fflags nobuffer -f:v mpegts udp://:8554
I would like to play it using MediaPlayerElement without using a third-party library.
According to the following page:
https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/supported-codecs
UWP should be able to play it. (I installed the "MPEG 2 video extension" in the Windows storage).
I tried using DatagramSocket and MessageReceived to receive UDP packets, it works without problems:
_datagramSocket = new DatagramSocket();
_datagramSocket.MessageReceived += (s, args) =>
{
Debug.WriteLine("message received");
};
await _datagramSocket.BindServiceNameAsync(8554);
Then I create an MseStreamSource:
_mseStreamSource = new MseStreamSource();
_mseStreamSource.Opened += (_, __) =>
{
_mseSourceBuffer = _mseStreamSource.AddSourceBuffer("video/mp2t");
};
this.MediaSource = MediaSource.CreateFromMseStreamSource(_mseStreamSource);
DatagramSocket.MessageReceived MseStreamSource:
using (IInputStream stream = args.GetDataStream())
{
_mseSourceBuffer.AppendStream(stream);
}
AppendStream HRESULT 0x8070000B .
, MediaPlayerElement " ". ( , Windows ).
MseStreamSource ? ?