Jump to content


Photo

HDR tone-mapping with mpv


  • Please log in to reply
10 replies to this topic

#1 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 10362 posts
  • Local time: 06:54 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. 

 

All results here, are from using a test build of mpv (attached) that has not yet been merged to master. The present release/Git, doesn't have these developments. 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 :)

Attached Files

  • Attached File  mpv.zip   21.55MB   10 downloads

Edited by Doofus, 14 February 2019 - 10:38 PM.

  • daedalus, Latchmor, PrincessClevage and 1 other like this

#2 DaSilva OFFLINE  

DaSilva

    Advanced Member

  • Members
  • 78 posts
  • Local time: 04:54 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
  • 10362 posts
  • Local time: 06:54 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
  • 10362 posts
  • Local time: 06:54 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: 03:54 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
  • 10362 posts
  • Local time: 06:54 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
  • 10362 posts
  • Local time: 06:54 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
  • 10362 posts
  • Local time: 06:54 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
  • 10362 posts
  • Local time: 06:54 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
  • 119080 posts
  • Local time: 09:54 AM

Posted 17 February 2019 - 10:35 PM

Cool, thanks.

#11 Doofus OFFLINE  

Doofus

    Advanced Member

  • Members
  • 10362 posts
  • Local time: 06:54 AM

Posted 18 February 2019 - 01:59 PM

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


  • markyp likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users