[HDR Metadata Passthrough] - Plex HTPC for Windows

Thanks for this tutorial. It makes it very simple for dunces like me to understand what and how I need to do things to make Plex work even better.

Thank you guys for all your work. I will give plexhtpc another try, and hopefully be able to enjoy HDR content properly on my TV.

Note:

1.28.1 has been released which has a GUI checkbox to enable HDR metadata passthrough. This:

  • Sets vo=gpu-next and target-colorspace-hint=yes when you play HDR content (it sets vo=gpu when playing SDR content so if you want to always use vo=gpu-next you should keep this in your mpv.conf file).
  • When switching the display from HDR → SDR and target-colorspace-hint was set along with using a Vulkan GPU context, it will play a short SDR video to kick the drivers out of outputting HDR all the time. This is a workaround for the Vulkan output remaining in HDR even when the display is switched back to SDR.

So, today you should make these changes from what’s stated in the first post (at the time of writing):

  • Remove target-colorspace-hint=yes from your mpv.conf file
  • (optionally) remove vo=gpu-next from your mpv.conf file (keep it if you want to use gpu-next for SDR content)
  • Turn on HDR switching in HTPC’s settings (even if you are using Vulkan)
  • Turn on HDR Metadata Passthrough in HTPC’s settings

This was accomplished by moving the UI window behind the video, capturing an image of the UI whenever it changes (and only on change; no polling), and adding that image as an overlay to MPV. You may notice upon exiting playback that the UI is momentarily in the upper-left quarter of the screen before quickly resizing the the full screen. This is for performance reasons to capture image of the UI at 1080p instead of 4k.

On the non-passthrough front:

In playing with an HDFury Arcana, we have discovered that Windows is pretty consistently outputting MaxFall/CLL values which match what the display indicates in its EDID. Currently missing is MPV reading this values and tone-mapping itself to what Windows is outputting. If this were added (setting target-peak), then MPV it should produce similar (and possibly better) results to HDR metadata passthrough.

3 Likes

Awesome!!! Can’t wait to test this new build!! Thanks!

I will also update my first post in the next few days regarding the necessary changes made to get it working!

1 Like

This is great! So at this point the only value to replacing the mpv-2.dll with a mpv-daily build would be for (unofficial) DoVi color decode, yes?

Any pros/cons for gpu vs gpu-next for SDR?

And DTS-HD decoding (if you use passthrough this doesn’t matter)

gpu-next is the future for MPV but it is new so things may be broken. gpu is better tested.

… and if you need the patched TrueHD mpv build. :wink:

Another pro for using gpu-next for SDR would be if you need to use LUTs for display calibration purposes. As far as I can tell they only work with the new gpu-next vo. Although vo=gpu-next being quite new it is very solid. I personally have no contra. Maybe things could brake unexpectedly when there is a new version…

@Mitzsch FYI, we have a patch to our version of MPV which allows OSD images to be scaled on display (player/command: Added ability to scale overlay. by gbooker ¡ Pull Request #10713 ¡ mpv-player/mpv ¡ GitHub) Without it, when using HDR metadata passthrough the UI will only appear in the upper-left quadrant.

1 Like

Ah, thanks for pointing this out! I will patch my truehd build regarding this and will make some noise over at the github page so maybe this can be merged soon. This is probably useful for others too.

I now finally had time to test the build and the new setting. Metadata passthrough works perfectly, every value present in the file is forwarded correctly as it should be and the image looks phenomenal. Awesome! The playback controls/ overlay also behaves fine, it’s fast enough and usable. The resolution difference of the UI is also not visible at a normal viewing distance.

The only problem I encountered is the “bad-ish” performance of playback when the HDR metadata passthrough setting is enabled. With it on I get 50 to 60 dropped frames in half an hour of playback which destroys the playback experience quite a bit. With the setting turned off I only get 0 to 2 per hour which is not noticeable at all.

Do you have a clue what could be the problem? Can this be improved?

2 Likes

Same, this is why I have not switched to Plex HTPC yet.
Really want to because the AppleTV 4k cannot passthrough TrueHD, etc.

Hmm, that’s odd. I’ve tested this on both NVIDIA and Intel GPUs and in both cases I didn’t see frame drops (except the Intel had some startup transients). On NVIDIA I was using Vulkan and on Intel D3D11. It sets vo=gpu-next and target-colorspace-hint=yes and reorders the windows to put MPV in front but that’s all it really does.

Well, I did not test Vulkan but I will next time I have some time. On the D3D11 side, I don´t think it has something to do with vo=gpu-next and target-colorspace-hint=yes as I have run Plex HTPC for many months without any serious performance issues with these settings. Maybe it has something to do with the reordering? Can you please also try D3D11 with your Nvidia setup?

I’ve seen frame drops in D3D11 in vo=gpu-next for a long time now on NVIDIA (maybe it just needed the option in the other thread). It’s one of the reason I use Vulkan in the first place.

Do you recall how many there were on your setup? (Can you please retest this if you have some time? maybe with the swapchain-depth=1 setting set?)

How many dropped frames do you get with the new option and Vulkan?

On my system, I had more dropped frames with Vulkan than with D3D11, maybe that has changed by now. There are also two other things that I have noticed with Vulkan (also affects mpv cli, so no Plex HTPC issue). 1. not all HDR metadata values are transmitted, the color primaries and the white point are not correctly forwarded, the arcana says “unknown”. No idea if they are really needed but I guess when they are present in the file, they should also be transmitted to the displaying device. I will open a GitHub issue on that one shortly, maybe that can be fixed. (I hope it’s not a Vulkan API limitation) The second one is VRAM efficiency. On my system, I have seen Vulkan using more VRAM than D3D11. On 1080p/4K files with an 8Gb VRAM video card, it’s not a problem, but regarding future support for 8K and AV1, the difference is huge. I tried playing an 8KHDR60pAV1 file on the RTX3050 pc with mpv cli and D3D11. It used about 2,5Gb out of 8Gb available, (madVR with D3D11 used 4,5/8) and mpv with Vulkan all 8Gb and it probably would have used more if available. The playback experience between D3D11 and Vulkan was the same but with fewer system resources needed with D3D11. (many dropped frames but somewhat watchable, on my main pc without AV1 hw decoding support but 32 cores it was not even in the range of being watchable)

It was uncommon. The frame drops were not recorded by MPV so I don’t have any exact numbers but it was on the order of 1-2 an hour. To be clear, this was with vo=gpu-next and with the MPV that ships with HTPC.

Zero. I don’t see frame drops at all when using Vulkan.

I see the unknown on one of the values but it appears it may actually have a whitepoint in my case. It’s hard to tell because the display cuts it off and it’s not in the data export.

Note it should be on libplacebo in this case and not MPV.

I have seen the same but given the dramatic drop in GPU usage it was worth it in my case. I do wonder if Vulkan is able to achieve this higher efficiency through increased RAM usage. If it properly handles limitations on the RAM (by maybe increasing GPU core usage to D3D11 levels), then this is very much desirable. Unused GPU memory is effectively a waste so if you can get better performance by using it then it is better to do so so long as you can handle limits on it.

I would expect 8k anything without hardware decode to be unusable.

1 Like

Just a heads up for @gbooker02 – it appears the multimonitor scaling issue came back only when “Enable HDR Metadata Passthrough” is enabled. More details here:
[bug] UI zoom issues with latest Plex HTPC - Plex Players / Desktop Players - Plex Forum

That sounds like the number I got/get when using D3D11 (without experimental HDR passthrough). Have you tried it with D3D11 and experimental HDR passthrough yet? How many dropped frames do you get there?

Oh well, that sounds amazing. I will absolutely try Vulkan next time I have access to my setup!

Yes, I should have written, “I will open an issue on GitLab shortly, where libplacebo lives!” :wink:

On the topic of frame drops.
I got 13 (output) during 60 minutes of playback - so a dropped frame every

This is my mpv.conf

vo=gpu-next
gpu-context=winvk
tls-ca-file=C:\Program Files\Plex\Plex HTPC\resources\cacert.pem

I know that @gbooker02 isnt a fan, but for comparison I want to mention that with madvr I get 1 dropped frame every 60 minutes.

Should I not use gpu-next / vulkan with mpv?

I now have tried running Plex HTPC with Vulkan and indeed I get fewer dropped frames. Unfortunately not 0 but <4/1h which is okay-ish. Some seem to only occur when user input/interaction with Plex HTPC was done - but most of the time they just happen even when there shouldn´t be a reason for dropping a frame. Frametimes are perfect. (2000-7000¾s) It sometimes also behaves weirdly, when starting a file I might get 0 dropped frames or 1 dropped frame every 3/4 minutes. The latter can sometimes be resolved by skipping inside the file and resume playback. D3D11 would in any case drop 1 frame every 40 seconds or so.
This is for the Nvidia system… On my AMD system, experimental passthrough enabled and D3D11 seem to work just fine together. I was not able to see some abnormal frame dropping. This leads me to think it could be an Nvidia driver “issue”. (The latest Nvidia driver 527.56 now correctly sends the white point information when using Vulkan)

(Nvdec with 1080p file is perfect - sometimes I only get 1 dropped frame for an entire 2h+ feature film - only when opening the playback bar I get some (also visible) frame dropping - it was not that extreme with d3d11 but I guess it’s fine)

However, while testing all this I found a bug. When exiting playback while the movie is stopped, the display is not switched out of HDR and 23p. This only happens with Vulkan enabled. I tried playing a new movie (while stuck in the HDR/23p mode) but it would just spin infinitely. The Plex HTPC debug overlay showed this =>

It is somehow stuck while playing the sdrBlack file which should fix the Vulkan “stuck in HDR” issue. Only exiting Plex HTPC switches the TV back out of HDR and back to 60p.
All this happens with the shipped mpv.dll and my modified one. It also only occurs when exiting an already paused file, exiting playback while the movie is playing works fine. The TV is switched back to SDR and back to 60p as you would expect.

1 Like