ffmpeginteropx / FFmpegInteropX

FFmpeg decoding library for Windows 10 UWP and WinUI 3 Apps
Apache License 2.0
205 stars 52 forks source link

Auto select HDR mode #339

Closed lukasf closed 1 year ago

lukasf commented 1 year ago

A new setting was added to allow selection of HDR mode. Default is "Automatic", which will check the display properties to see if HDR is enabled. Only then, HDR metadata will be forwarded.

Note: This currently does not work on WinUI, because it has its own DisplayInformation implementation. We need a separate WinUI build to support this.

brabebhin commented 1 year ago

I think we need to check on every sample, since the user can move the application from a display that has HDR to one without.

lukasf commented 1 year ago

I am not sure if that is even possible. We cannot change the EncodingProperties once the media is opened. We could try to set the parameters directly on the samples instead of the EncodingProperties, but I don't know if this works.

Also, it is possible to either move the player to the right screen before starting, or set HdrSupport to Enabled, then it will always be used. So I am not sure if we really need the dynamic behavior.

brabebhin commented 1 year ago

I wonder if there's a directx interface that can help us here, that's supposed in both winui and uwp.

lukasf commented 1 year ago

The problem is that on WinUI, there can be multiple Windows on a single thread. One Window can be on HDR display, the other on a different display. On UWP, we can just call DisplayInformation.GetForCurrentView(), because there can be only one Window on the thread. But to correctly get HDR information on WinUI, we need a handle to the Window where the media is to be played. We'd need to add that to the Config class, and use it when running on WinUI. Also we need to use the WinUI version of DisplayInformation.

There is no way around a custom WinUI build. We need to use the WinUI DisplayInformation, the WinUI DispatcherQueue,...

brabebhin commented 1 year ago

For winUI/desktop there's support in directx for handling this, which i think it's faster than winRT. I will take a more detailed look next week.