Mayank Kumar
Mayank Kumar

Reputation: 1

How can I set YUV420p byte array as source in MediaPlayerElement of WinUI3

Exactly what the title says - I am receiving raw YUV byte arrays (in planar YUV4:2:0 format) which I want to set as a source in MediaPlayerElement for my WinUI3 application. Since this is a real-time video feed, I want to avoid delay in rendering as much as possible. What is the best (and fastest) way to do this?

Thanks for your help

Upvotes: 0

Views: 189

Answers (1)

Blindy
Blindy

Reputation: 67447

You can't, MediaPlayerElement handles rendering real video files (avi, mp4, mkv, etc). What you have is raw frame data.

You have many options, the one I personally went with (albeit not for winui3) is using OpenGL to stream the three data channels as textures and decode them in a fragment shader to RGB colors.

For WinUI3 specifically, you have a couple of options if you care about efficiency (as you should for video rendering):

  • Similarly to my approach, there's the SwapChainPanel class that gives you a DX11 object you can render with. You can then implement exactly what I described above.
  • You can also use a WriteableBitmap approach, but you'll have to decode the streams to RGB on the CPU yourself first. Less efficient, but easier to implement.

Upvotes: 0

Related Questions