Jump to content


Photo

HDR tone-mapping with mpv


Best Answer Doofus , 19 March 2019 - 09:45 PM

Here's a starter pack for those who haven't done this, before. This assumes that your desktop coloring looks like a standard desktop. This is important!

1. Download the Adobe attachment, and unzip it to; C:\Windows\System32\spool\drivers\color

2. Download the mpv config attachment, and unzip it to; %AppData%\Roaming

 

3. Replace mpv with the March 10 2019 build 64 bit or 32 bit

 

    Just download it and unzip it to; %AppData%\Roaming\Emby-Theater\system\x64\mpv

 

4. Go play a movie :)

Any questions, ask them, here :)

 

(more information and an updated configuration, can be found here)

Go to the full post


  • Please log in to reply
324 replies to this topic

#1 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 09 February 2019 - 05:52 PM

Ok, so I've posted a bunch of different configs and results, but I'm sure that some of you have gotten a little confused, and are unsure of what you should be doing. So this thread will be a bit more structured in what to use. 

 

For those wanting to use this, I am assuming that you already know how, and are only looking for a config to put in your mpv.conf.

 

There are far too many possible configurations to show them all, here. So I'm going to focus on the elements that I think are most important. 

 

  • tone-mapping  ----------------->  This is the algorithm that decides how the colors are applied
  • tone-mapping-desaturate  --->  Decides how much color to remove
  • hdr-compute-peak  ------------>  Calculates the brightest point of the scene
  • target-peak  -------------------->  You choose the value of the brightest point (these two can work together)
  • target-prim  -------------------->  Chooses the colorspace that you want to use

 

If you were to use the default values in your mpv.conf, it would look like this;

hdr-compute-peak=auto
tone-mapping=hable
target-peak=100
tone-mapping-desaturate=0.5
target-prim=bt.709

This will generally give you a very good picture. If you're using an SDR display with basic color adjustments, it's probably best that you don't change anything. The defaults are designed to work with that kind of display.

 

If you have an HDR display and Windows is in HDR10 at all times, below may be more useful to you. Something I should also mention is that calibration for HDR passthrough may not work with mpv tone mapping. My display comes with a calibrated setting. If I use that and play HDR with madVR and pass the metadata to the display, the colors are correct. But if I use the same settings for mpv, the colors are incorrect. mpv tone-mapping is targeted at SDR displays. So you may want to check that. I calibrated my display to the Windows desktop. If Windows' colors are correct, so will mpv. 

 

 

First, you'll definitely want to use wide color gamut, to have more accurate colors.

target-prim=bt.2020

Test playing an HDR movie with that, so you can decide what (if any) adjustments you want to make.

 

 

Here are some screenshots with the defaults, but in bt.2020

 

LG HDR Demo 'Chess'

5c5f31cdc2aba_mpvshot0001.jpg

 

Interstellar 

5c5f321432daa_mpvshot0002.jpg

 

 

Lost in Space

5c5f3236074b8_mpvshot0003.jpg

 

 

I'm choosing these movies because they have extremes in saturation, light and darkness. As you can see, the results appear very good.

 

 

Now I'll show you what using reinhard instead of hable, will look like. Reinhard stays more faithful to the brightness. You lose more detail, in the brightness.

hdr-compute-peak=yes
tone-mapping=reinhard
target-peak=100
tone-mapping-desaturate=0.5
target-prim=bt.2020

Chess (losing more detail in the brightness)

5c5f347679ada_mpvshot0001.jpg

 

 

Interstellar

5c5f34df65c01_mpvshot0002.jpg

 

 

Lost in Space (more detail due to brightening)

5c5f350db4138_mpvshot0003.jpg

 

 

 

Here's where we go down the rabbit hole a little bit, and I show you how to improve the detail. This is where we start adjusting the desaturation. Using the default config, but increasing desaturation to 2.0. The differences here, are subtle. The Chess video shows it, best.

hdr-compute-peak=yes
tone-mapping=hable
target-peak=100
tone-mapping-desaturate=2.0
target-prim=bt.2020

Chess (notice more shades in the neck piece)

5c5f3ac977a9e_mpvshot0001.jpg

 

 

No perceptible change in Interstellar or Lost in Space.

 

Let's now use reinhard with that.

hdr-compute-peak=yes
tone-mapping=reinhard
target-peak=100
tone-mapping-desaturate=2.0
target-prim=bt.2020

Chess (Too bright but has more detail than with default desaturation)

5c5f3d21aaaff_mpvshot0004.jpg

 

 

Interstellar (also too bright)

5c5f3d4f98972_mpvshot0001.jpg

 

 

Lost in Space (You can see more detail)

5c5f3d84d8804_mpvshot0002.jpg

 

 

So we lost detail in bright scenes, but gained it in the dark scenes. I think we want to balance that, right? So here's where we introduce changing the target-peak. I find that 250 works on my display. You'll want to experiment a little with that value. Higher=darker, lower=brighter. 100 is the default.

hdr-compute-peak=yes
tone-mapping=reinhard
target-peak=250
tone-mapping-desaturate=2.0
target-prim=bt.2020

Chess (retaining the brightness and detail)

5c5f3f8fa6cc9_mpvshot0001.jpg

 

 

Interstellar

5c5f3fe958149_mpvshot0002.jpg

 

 

Lost in Space

5c5f403518a2c_mpvshot0003.jpg

 

 

So now we're deep in the rabbit hole. The differences are very subtle and you may not care about them. I have increased the desaturation in my config, to 4.0. This gives more detail in some scenes, like the Chess lady.

hdr-compute-peak=yes
tone-mapping=reinhard
target-peak=250
tone-mapping-desaturate=4.0
target-prim=bt.2020

Chess

5c5f41c51276f_mpvshot0005.jpg

 

 

Now that you're using target-peak, you'll probably want to keep using peak detection. This will keep dark scenes bright enough to see more details.

 

Lost in Space (hdr-compute-peak=yes)

5c5f438872653_mpvshot0001.jpg

 

 

Lost in Space (hdr-compute-peak=no)

5c5f43f7d55db_mpvshot0002.jpg

 

 

There are many more ways to adjust the picture. I don't use mobius, as I think it's too bright, especially on an HDR display in HDR10. Your results will vary, because each display has different capabilities with different calibrations.

 

Happy viewing :)


Edited by Doofus, 15 August 2019 - 11:41 PM.

  • daedalus, Latchmor, PrincessClevage and 1 other like this

#2 DaSilva OFFLINE  

DaSilva

    Advanced Member

  • Members
  • 80 posts
  • Local time: 06:17 PM

Posted 11 February 2019 - 08:24 AM

Thanks @Doofus for the work you’ve put into this.
I have a Sony X940E with a peak brightness of around 1100.
So should I use 1100 as a value for the target peak?
And if you put your windows desktop in HDR mode constantly with your settings will SDR look ok or should we change the config for watching regular SDR like tv shows etc?

Edited by DaSilva, 11 February 2019 - 08:27 AM.


#3 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 11 February 2019 - 11:24 AM

Thanks @Doofus for the work you’ve put into this.
I have a Sony X940E with a peak brightness of around 1100.
So should I use 1100 as a value for the target peak?
And if you put your windows desktop in HDR mode constantly with your settings will SDR look ok or should we change the config for watching regular SDR like tv shows etc?

If your display has been calbrated to 1100 then you can try setting it to 1100. But if it's not, then the picture will be dark. And you'll want to use reinhard. That's why I said that results will differ. You'll probably want to disable peak detection, too. SDR will look good as long as you adjust the color as I described, above. If your desktop looks correct, then mpv will be too. And put target-prim=bt.2020 at the top of your mpv.conf

Edited by Doofus, 11 February 2019 - 01:56 PM.


#4 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 11 February 2019 - 02:23 PM

If any of you are wanting to adhere to using HDR in the same way you pass the metadata, then you need to make sure your Windows UI colors are correct. Meaning that it looks like a regular SDR desktop, but calibrated to the brightness you want. Then disable peak detection and set the target-peak to your requirement, and use reinhard. You'll likely need to experiment a little with the peak value. Just because your display supports 1000 nits, doesn't necessarily mean that it's calibrated for that. If it isn't specifically calibrated to a luminance, and you don't know what that value is, you'll have to experiment to find where the peak is. There is no one size fits all. Every display will be different. What I've given you is a starting point that you can work from.


Edited by Doofus, 13 February 2019 - 11:42 PM.


#5 vonkobalus OFFLINE  

vonkobalus

    Newbie

  • Members
  • 1 posts
  • Local time: 05:17 PM

Posted 14 February 2019 - 04:35 AM

@Doofus thanks for this post ... I've searched a lot and this is the best explanation of how to test HDR on Windows10.

 

One question: the way I currently see HDR is that it requires lot's of manual config/tuning/etc. and hardware/software support is far from being complete. What I would wish for is a straightforward pass-through (assuming one has a display capable of HDR, at least HDR10). Just similar to when it comes to audio ... if one has a receiver with support for latest Dolby 5.1/7.1/ATMOS 11.2/DTS/etc. just make everything pass-through and it will just work, no tweaking needed (and IT ACTUALLY works). Is this too much to ask when it comes to HDR? Will we see this any time soon? Even in Windows 10 ... when one enables HDR we all know that everything becomes too bright with not accurate colors. Can't windows tell to the display -> hey, HDR is on, display it properly? I would really like to understand more about this HDR magic, thx!



#6 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 14 February 2019 - 11:33 AM

@Doofus thanks for this post ... I've searched a lot and this is the best explanation of how to test HDR on Windows10.
 
One question: the way I currently see HDR is that it requires lot's of manual config/tuning/etc. and hardware/software support is far from being complete. What I would wish for is a straightforward pass-through (assuming one has a display capable of HDR, at least HDR10). Just similar to when it comes to audio ... if one has a receiver with support for latest Dolby 5.1/7.1/ATMOS 11.2/DTS/etc. just make everything pass-through and it will just work, no tweaking needed (and IT ACTUALLY works). Is this too much to ask when it comes to HDR? Will we see this any time soon? Even in Windows 10 ... when one enables HDR we all know that everything becomes too bright with not accurate colors. Can't windows tell to the display -> hey, HDR is on, display it properly? I would really like to understand more about this HDR magic, thx!


On a Windows machine I doubt that it will ever be that straight forward. You'll always have to configure something. The closest you might get is using software like PowerDVD, and you have a display that has an option that is already calibrated for HDR. But then you'll have problems with SDR. I actually think that passing HDR metadata to the display is an I'll conceived mechanism. I favor just being able to play anything easily, without having to switch mechanisms. Using mpv the way I have it configured, pretty much gets me there. SDR, HDR, audio passthrough, audio transcoding/resampling, all happen with one config. No switching, anything. For HDR, I've been trying to find a tone mapping config that will work well for all mastering. Everything I've tried now plays almost identically to passing the metadata to the display, without the headache of color discrepancies between SDR and HDR. I enjoy testing this stuff, so hopefully you guys can take advantage of that, and the configs I post help some of you.

#7 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 16 February 2019 - 06:33 PM

If any of you want to test your output, add this to your mpv.conf. When there is something that is out of your gamut range, it will be inverted so it's highlighted.

gamut-warning

It will look like this

 

5c688fce350fa_mpvshot0001.jpg



#8 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 16 February 2019 - 06:40 PM

Using this config

hdr-compute-peak=yes
target-peak=230
tone-mapping=reinhard
tone-mapping-desaturate=2.0
target-prim=bt.2020

If I raise the desaturation above 2.0, it's started pushing things out of range. So this is a useful tool to check your settings.



#9 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 17 February 2019 - 07:58 PM

@Luke, the PR just got merged to master. Jeeb just approved it and merged it.



#10 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 140491 posts
  • Local time: 11:17 AM

Posted 17 February 2019 - 10:35 PM

Cool, thanks.

#11 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 18 February 2019 - 01:59 PM

The latest Git build now has all the new goodies :)


  • markyp likes this

#12 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 24 February 2019 - 12:41 AM

Here's something. You could try just using the OS ICC. I use my desktop, so this doesn't work for me (desktop is too dark) . But you can simply use this, instead of a more complicated mpv.conf

icc-profile-auto

https://mpv.io/manua...cc-profile-auto

 

Your display will need to be calibrated to HDR10 if that is how you have Windows, configured. Or everything will look terrible (over-saturated if normal desktop coloring etc). Theater UI will look terrible, but the video should look good. You just use that one line, but your display calibration must match the ICC profile.


Edited by Doofus, 24 February 2019 - 10:52 PM.


#13 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 24 February 2019 - 10:50 PM

More info on that. I've spent the better part of the day experimenting with the use of ;

icc-profile-auto

It actually works better than the configs I have posted, above. It's just a little more tricky to get it dialed in. 

 

The icc profile is what Windows configures and uses for the application of color, light etc, to the UI. As near as I can tell, Windows gets it's data from your hardware (don't quote me on that). The upshot is that it's more accurate. Through trial and error, I learned that you need to calibrate your display (this applies to SDR displays, also), then reboot your machine to have it fully applied. I wasn't doing this at first. I would adjust the display, then configure my mpv.conf to get the picture, correct, only to discover that after reboot, the picture would be different. 

 

So once you get the display dialed in and reboot, you can start adjusting/applying your mpv configuration. 

 

The easiest config is simply use  just that line. On an SDR display, that's probably all you need to do, unless you want to adjust the desaturation (see above).

 

For those with an HDR display, this is where it gets tricky. I'll use my display as an example. I have a setting that is calibrated to HDR10. If I use that with icc-profile-auto, any video I play is correct, and there's nothing more to do. But that calibration setting makes my Windows UI dim and with little color. What that means is the Theater UI will also look crap. So if your display is calibrated in such a way, and you want to have a correctly colored UI, this is what you do.

 

icc-profile-auto overrides target-prim and target-trc. So if you have target-prim=bt.2020 in your config, replace it with

icc-profile-auto

If you are using auto-profiles, I suggest you don't use it in a profile. Instead, put it at the top of your mpv.conf, as it will apply to everything you play.

 

Now for the HDR profile. At this point, your colors could be over-saturated, as it's expecting the display to be calibrated for HDR10, but it isn't. So the saturation and possibly brightness will need to be compensated for. As I said, I've spent most of the day on this. To try and help you from going down the same rabbit hole that I did, try starting with this config.

hdr-compute-peak=yes
tone-mapping=reinhard
tone-mapping-param=0.3
tone-mapping-desaturate=2.0

If you disable compute-peak, you will likely dive deep into that rabbit hole. I tried with a lot a config variations, and I got a lot of picture variation. Disable it at your own risk.

 

Now to compensate for saturation and brightness. This is easy, just add this:

saturation=-20
brightness=5

Those are the values that I use. Zero is the default value. <-100 to 100> I'd suggest leaving brightness at zero, until you get the saturation where you want it. They are global settings, so add them at the top, not in a profile (if you're using auto-profiles). Use these only if needed. I like my desktop with a lot of color, you may not :)

 

If you have questions, fire away :)

 

I made a blunder on this. With further testing, it appears that icc (at least in my case) is not correctly setting the color space. I was getting the oversaturation for SDR content. Using target-prim=bt.2020 is the better option for SDR.


Edited by Doofus, 28 February 2019 - 02:25 AM.


#14 lorac OFFLINE  

lorac

    Advanced Member

  • Members
  • 426 posts
  • Local time: 08:17 AM
  • LocationVancouver, Canada

Posted 24 February 2019 - 11:10 PM

Sounds promising! I'll be sure to give it a shot. I've adjusted my display for what the recommended settings are for SDR but haven't changed anything for HDR.

Sent from my ONEPLUS A6003 using Tapatalk

#15 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1057 posts
  • Local time: 02:17 AM

Posted 25 February 2019 - 04:49 AM

More info on that. I've spent the better part of the day experimenting with the use of ;

icc-profile-auto

It actually works better than the configs I have posted, above. It's just a little more tricky to get it dialed in.

The icc profile is what Windows configures and uses for the application of color, light etc, to the UI. As near as I can tell, Windows gets it's data from your hardware (don't quote me on that). The upshot is that it's more accurate. Through trial and error, I learned that you need to calibrate your display (this applies to SDR displays, also), then reboot your machine to have it fully applied. I wasn't doing this at first. I would adjust the display, then configure my mpv.conf to get the picture, correct, only to discover that after reboot, the picture would be different.

So once you get the display dialed in and reboot, you can start adjusting/applying your mpv configuration.

The easiest config is simply use just that line. On an SDR display, that's probably all you need to do, unless you want to adjust the desaturation (see above).

For those with an HDR display, this is where it gets tricky. I'll use my display as an example. I have a setting that is calibrated to HDR10. If I use that with icc-profile-auto, any video I play is correct, and there's nothing more to do. But that calibration setting makes my Windows UI dim and with little color. What that means is the Theater UI will also look crap. So if your display is calibrated in such a way, and you want to have a correctly colored UI, this is what you do.

icc-profile-auto overrides target-prim and target-trc. So if you have target-prim=bt.2020 in your config, replace it with
icc-profile-auto
If you are using auto-profiles, I suggest you don't use it in a profile. Instead, put it at the top of your mpv.conf, as it will apply to everything you play.

Now for the HDR profile. At this point, your colors could be over-saturated, as it's expecting the display to be calibrated for HDR10, but it isn't. So the saturation and possibly brightness will need to be compensated for. As I said, I've spent most of the day on this. To try and help you from going down the same rabbit hole that I did, try starting with this config.
hdr-compute-peak=yes
tone-mapping=reinhard
tone-mapping-param=0.3
tone-mapping-desaturate=2.0
If you disable compute-peak, you will likely dive deep into that rabbit hole. I tried with a lot a config variations, and I got a lot of picture variation. Disable it at your own risk.

Now to compensate for saturation and brightness. This is easy, just add this:
saturation=-20
brightness=5
Those are the values that I use. Zero is the default value. <-100 to 100> I'd suggest leaving brightness at zero, until you get the saturation where you want it. They are global settings, so add them at the top, not in a profile (if you're using auto-profiles). Use these only if needed. I like my desktop with a lot of color, you may not :)

If you have questions, fire away :)
Should I use gpu-api=opengl with icc-profile-auto?

#16 markyp OFFLINE  

markyp

    Advanced Member

  • Members
  • 242 posts
  • Local time: 05:17 PM

Posted 25 February 2019 - 04:54 AM

More info on that. I've spent the better part of the day experimenting with the use of ;

icc-profile-auto

It actually works better than the configs I have posted, above. It's just a little more tricky to get it dialed in.

The icc profile is what Windows configures and uses for the application of color, light etc, to the UI. As near as I can tell, Windows gets it's data from your hardware (don't quote me on that). The upshot is that it's more accurate. Through trial and error, I learned that you need to calibrate your display (this applies to SDR displays, also), then reboot your machine to have it fully applied. I wasn't doing this at first. I would adjust the display, then configure my mpv.conf to get the picture, correct, only to discover that after reboot, the picture would be different.

So once you get the display dialed in and reboot, you can start adjusting/applying your mpv configuration.

The easiest config is simply use just that line. On an SDR display, that's probably all you need to do, unless you want to adjust the desaturation (see above).

For those with an HDR display, this is where it gets tricky. I'll use my display as an example. I have a setting that is calibrated to HDR10. If I use that with icc-profile-auto, any video I play is correct, and there's nothing more to do. But that calibration setting makes my Windows UI dim and with little color. What that means is the Theater UI will also look crap. So if your display is calibrated in such a way, and you want to have a correctly colored UI, this is what you do.

icc-profile-auto overrides target-prim and target-trc. So if you have target-prim=bt.2020 in your config, replace it with
icc-profile-auto
If you are using auto-profiles, I suggest you don't use it in a profile. Instead, put it at the top of your mpv.conf, as it will apply to everything you play.

Now for the HDR profile. At this point, your colors could be over-saturated, as it's expecting the display to be calibrated for HDR10, but it isn't. So the saturation and possibly brightness will need to be compensated for. As I said, I've spent most of the day on this. To try and help you from going down the same rabbit hole that I did, try starting with this config.
hdr-compute-peak=yes
tone-mapping=reinhard
tone-mapping-param=0.3
tone-mapping-desaturate=2.0
If you disable compute-peak, you will likely dive deep into that rabbit hole. I tried with a lot a config variations, and I got a lot of picture variation. Disable it at your own risk.

Now to compensate for saturation and brightness. This is easy, just add this:
saturation=-20
brightness=5
Those are the values that I use. Zero is the default value. <-100 to 100> I'd suggest leaving brightness at zero, until you get the saturation where you want it. They are global settings, so add them at the top, not in a profile (if you're using auto-profiles). Use these only if needed. I like my desktop with a lot of color, you may not :)

If you have questions, fire away :)

Interestingly, I just tried this and it made no difference to my desktop... and no difference to the chess video...

I didn’t trim the brightness like you suggested either!

#17 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1057 posts
  • Local time: 02:17 AM

Posted 25 February 2019 - 05:34 AM

Neither do I, in fact I would like more detail in dark areas of film

#18 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 25 February 2019 - 11:32 AM

Should I use gpu-api=opengl with icc-profile-auto?


One has nothing to do with the other, so you can use that. I do.

#19 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 12651 posts
  • Local time: 08:17 AM

Posted 25 February 2019 - 12:01 PM

Interestingly, I just tried this and it made no difference to my desktop... and no difference to the chess video...
I didn’t trim the brightness like you suggested either!


One has nothing to do with the other, so you can use that. I do.


Doing this won't change your desktop, you have do that yourself if you haven't, already.

You guys both have Nvidia GPUs, right?. In the control panel, are you both using Nvidia color? Like 4:2:2 12bit? I switched to using the default setting. And if you change any display settings, you'll need to reboot the machine.

What it should do is give you better color and light accuracy. I find I get better contrast, better black. More natural skin tone etc.

But if you're happy with what you have, you can stick with that.

#20 markyp OFFLINE  

markyp

    Advanced Member

  • Members
  • 242 posts
  • Local time: 05:17 PM

Posted 25 February 2019 - 01:03 PM

Yeah, nvidia GPU set to 12-bit colour...

Maybe as my display was dialed in already I didn’t notice much difference...

Edited by markyp, 25 February 2019 - 01:03 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users