Jump to content

Option for HDR Tone Map luminance value setting


howzz1854

Recommended Posts

howzz1854

hi, a recent Premium member here. i noticed that emby's default HDR playback (MPV), seems to tone map the Luminance value to something much lower than my HDTV output. this is really annoying, because right now i have to resort to playing all my HDR content to MPC-HC using MadVR. i know that MadVR is no longer part of MPV. but i think if you can provide users an option in a separate HDR section that allow us to set the max display luminance for HDR to SDR conversion playback, i'll be able to playback all my HDR content within Emby and not have to close it, and open up MPC-HC each time when i want to go from playing regular HD content to HDR content. 

 

I playback a lot of HDR demo contents when we have guests over, and i like to loop them. 

right now i am playing HDR contents on my 1080P HDTV until i get a 75 inch Oled. that means, i need all the HDR content to tone map correctly to the right luminance value. and you can tell that there's a huge difference between Emby (MPV)'s default HDR to SDR tone map luminance value, which is something closer to 170~180 nit, vs my display's current 270 nit. this also creates a problem, because lower spectrum of luminance is therefore raised as well. in another word, you get more details in shadows while sacrificing highlights. my display is calibrated to REC 709, max luminance of 270 nits. Currently MadVR is the only option that i can think of that allows me to map the HDR to SDR colorspace while setting the correct Luminance value. so it seems Emby still falls short in this regard. 

 

is adding that option even possible in the future? i am only testing out the Premium membership for a year, but if the development can keep up with the technology, i'd be happy to go full lifetime membership. 

 

 

Link to comment
Share on other sites

Guest asrequested

@@howzz1854 There are many ways to configure mpv using an mpv.conf. If you aren't familiar with setting up an mpv.conf, you can follow this guide. Then you can start to use different configurations. You can look at this thread to have a better idea. I added some configs and info at the end. You can look at the mpv manual to check different options, here. If you scroll up and down from there, you can read about the different settings I've used in the configs I posted. And I'll be happy to help further, if you require that :)

Link to comment
Share on other sites

howzz1854

@ do you have any HDR tips?

thanks guys, i'll have to look into this and study it. 

 

does this custom config solution apply to ALL content including 1080P HD Rec 709 content as well? or just HDR Rec 2020 4K content. I am looking for a solution that only applies to when i playback HDR 4K content. 

 

thanks

Link to comment
Share on other sites

Guest asrequested

thanks guys, i'll have to look into this and study it. 

 

does this custom config solution apply to ALL content including 1080P HD Rec 709 content as well? or just HDR Rec 2020 4K content. I am looking for a solution that only applies to when i playback HDR 4K content. 

 

thanks

 

It can if you want it to, but you can use auto-profiles to specify. That's what I do. Here's how my config looks.

gpu-api=opengl
video-sync=display-vdrop
display-sync-active

hwdec=nvdec

force-seekable=yes

sub-create-cc-track=yes
sub-pos=90
sub-ass-override=no

audio-device=wasapi/SC-95 (NVIDIA High Definition Audio)
af=lavcac3enc=yes:640:2

log-file="D:\mpv logs\Theater mpv log.txt"

[Video Codec]
profile-desc=cond:p["video-codec"]==hevc
deinterlace=no

[HDR]
profile-desc=cond:p["video-params/primaries"]=="bt.2020"
deinterlace=no
hdr-compute-peak=no
tone-mapping=hable
tone-mapping-desaturate=0.0
target-peak=740
hwdec=nvdec

[Interlaced]
profile-desc=cond:p["video-frame-info/interlaced"]
deinterlace=yes
hwdec=nvdec-copy

[720p]
profile-desc=cond:p["width"]==1280
deinterlace=no
scale=ewa_lanczossharp

For that, you'll need the auto-profiles script (attached). Delete the .txt, make a 'scripts' folder in the same place you put the mpv.conf, and put the script in that folder.

Edited by Doofus
Link to comment
Share on other sites

howzz1854

It can if you want it to, but you can use auto-profiles to specify. That's what I do. Here's how my config looks.

gpu-api=opengl
video-sync=display-vdrop
display-sync-active

hwdec=nvdec

force-seekable=yes

sub-create-cc-track=yes
sub-pos=90
sub-ass-override=no

audio-device=wasapi/SC-95 (NVIDIA High Definition Audio)
af=lavcac3enc=yes:640:2

log-file="D:\mpv logs\Theater mpv log.txt"

[Video Codec]
profile-desc=cond:p["video-codec"]==hevc
deinterlace=no

[HDR]
profile-desc=cond:p["video-params/primaries"]=="bt.2020"
deinterlace=no
hdr-compute-peak=no
tone-mapping=hable
tone-mapping-desaturate=0.0
target-peak=740
hwdec=nvdec

[Interlaced]
profile-desc=cond:p["video-frame-info/interlaced"]
deinterlace=yes
hwdec=nvdec-copy

[720p]
profile-desc=cond:p["width"]==1280
deinterlace=no
scale=ewa_lanczossharp

For that, you'll need the auto-profiles script (attached). Delete the .txt, make a 'scripts' folder in the same place you put the mpv.conf, and put the script in that folder.

 

 

i am still reading the manual. it's long. but i noticed that in your above script, you have custom perimeters for HDR. 

 

does that mean if i use 

 

[HDR] flag and put "target-peak=740" after that, it'll only apply target peak to HDR material?

Link to comment
Share on other sites

Guest asrequested

i am still reading the manual. it's long. but i noticed that in your above script, you have custom perimeters for HDR. 

 

does that mean if i use 

 

[HDR] flag and put "target-peak=740" after that, it'll only apply target peak to HDR material?

 

The target peak value should be what your display supports. You can set it much higher if you want. The way that works is everything within that value won't be tone-mapped, and will simply be applied. If the movie has a higher peak than that value, everything above that value will be tone-mapped. I have an HDR display, so my nits are higher than your SDR display. You said your display is 270 nits, so you'll want something like this;

[HDR]
profile-desc=cond:p["video-params/primaries"]=="bt.2020"
deinterlace=no
hdr-compute-peak=no
target-peak=270

If that doesn't give you what you want, you can use mobius to tone-map. That will brighten the whole image, but you may experience clipping with some very bright images.

Link to comment
Share on other sites

howzz1854

The target peak value should be what your display supports. You can set it much higher if you want. The way that works is everything within that value won't be tone-mapped, and will simply be applied. If the movie has a higher peak than that value, everything above that value will be tone-mapped. I have an HDR display, so my nits are higher than your SDR display. You said your display is 270 nits, so you'll want something like this;

[HDR]
profile-desc=cond:p["video-params/primaries"]=="bt.2020"
deinterlace=no
hdr-compute-peak=no
target-peak=270

If that doesn't give you what you want, you can use mobius to tone-map. That will brighten the whole image, but you may experience clipping with some very bright images.

 

 

 

 

ok, so the above script will only apply to HDR files correct? basically what i was asking is if the initial "[HDR]" tag is part of the script that tells Emby to apply the following commands to HDR files only. or is [HDR] tag simply just a description. i'd rather leave as many settings to stock as possible. since i really like the quality of the current built in setting for my SDR movies, i don't want to mess that up. i only want a custom luminance to be mapped/ton mapped when playing HDR file. thanks 

Edited by howzz1854
Link to comment
Share on other sites

Guest asrequested

ok, so the above script will only apply to HDR files correct? basically what i was asking is if the initial "[HDR]" tag is part of the script that tells Emby to apply the following commands to HDR files only. or is [HDR] tag simply just a description. i'd rather leave as many settings to stock as possible. since i really like the quality of the current built in setting for my SDR movies, i don't want to mess that up. i only want a custom luminance to be mapped/ton mapped when playing HDR file. thanks 

 

Yes, that profile is specific to HDR. It's differentiated by the bt.2020 characteristic. Anything you play that isn't bt.2020, won't be affected by that profile.

Edited by Doofus
  • Like 1
Link to comment
Share on other sites

howzz1854

Yes, that profile is specific to HDR. It's differentiated by the bt.2020 characteristic. Anything you play that isn't bt.2020, won't be affected by that profile.

 

thanks, i'll test it tonight and report back if i have any questions. 

 

and thanks for linking the status update on this issue in git. it's good to know that at least someone is looking into this. 

Link to comment
Share on other sites

howzz1854

sorry, i am diving into the "auto-profiles.lua" script you posted above. is this even needed?

 

if i just want 

 

[HDR]
profile-desc=cond:p["video-params/primaries"]=="bt.2020"
deinterlace=no
hdr-compute-peak=no
target-peak=270

 

can't i just put that straight into the conf file and wouldn't MPV just recognize the command based on color space (Rec 2020)? 

Link to comment
Share on other sites

Guest asrequested

sorry, i am diving into the "auto-profiles.lua" script you posted above. is this even needed?

 

if i just want 

 

[HDR]

profile-desc=cond:p["video-params/primaries"]=="bt.2020"

deinterlace=no

hdr-compute-peak=no

target-peak=270

 

can't i just put that straight into the conf file and wouldn't MPV just recognize the command based on color space (Rec 2020)? 

 

The script is what enables the profile. You need the profile and the script.

Link to comment
Share on other sites

howzz1854

thanks, i just tested with the script and the profile. it bumped up the highlight and it's a lot better, however, there's still issue with MPV, and how it map/tone map the curve. no matter what tone-mapping method i chose, Mobius/Reinhard/hable etc, the peak highlight is still missing in the picture. and it's very clearly visible in one of LG oLED's public demo material called "chess". in that demo, you can tell that a lot of the peak highlight is simply missing, and not rendered regardless of what render method i chose. i first tried the default suggested above

 

[HDR]
profile-desc=cond:p["video-params/primaries"]=="bt.2020"
deinterlace=no
hdr-compute-peak=no


target-peak=270

 

this misses the peak highlights. 

 

 

 

 

then i tried

[HDR]
profile-desc=cond:p["video-params/primaries"]=="bt.2020"
deinterlace=no
hdr-compute-peak=no

tone-mapping=hable
tone
-mapping-desaturate=0.0

target-peak=270

 

but this blasted everything more to near peak highlight and looks to be raising the 75% overal level higher than it should. i then tried to play around with the desaturate value, and that brought some of the over saturated colors back down a little at 0.5 value. 

 

simply put, between all the combinations of hable, mobius, hdr-compute-peak= yes/no, tone-mapping-desaturate values. none of the combination will produce the same picture as what MPC-HC MadVR can do. a lot of the peak highlight info is just not showing. 

 

The good news is, after tuning, by just using the basic commands of Target-peak=270, hdr-compute-peak=no, it is a lot better than before with the default settings. colors seem to be the same as MPC-HC/MadVR; mid tone and Shadows are the same. it's just that clearly the brightest highlights are missing, or being truncated. 

 

this remains to be a problem. as i will still need to use MPC-HC/MadVR for HDR content playback. :( very unfortunate. hopefully this will be addressed in the future releases. 

 

thanks for the help Doofus

Edited by howzz1854
Link to comment
Share on other sites

Guest asrequested

1050Ti

 

What hardware acceleration were you using? Also, you can try using a different gpu-api. Using nvdec is fixed in the mpv git builds. And I use gpu-api=opengl

Edited by Doofus
Link to comment
Share on other sites

howzz1854

What hardware acceleration were you using? Also, you can try using a different gpu-api. Using nvdec is fixed in the mpv git builds. And I use gpu-api=opengl

 

Thanks for the suggestion. i just tried D3D11, D3D11COPYBACK, DXVA2, DXVA2COPYBACK to be completely honest, i wasn't expecting any result to be different. and sure enough. it had nothing to do with the api. although i did uncover more problems with the way MPV handles api's. 

 

with DXVA2, there is something wrong with the colorspace, things look more washed out. and sure enough, i remember seeing this being mentioned in the MPV manual. but MPC-HC Direct Show has no such problem rendering with DXVA2. 

 

also i noticed MPV handles HEVC differently, quite differently. the color red and yellow are slightly boosted. i busted out my i1Display Pro and strangely both MPV and MPC-HC came out with identical grey scale and color spectrum when i did a full sweep in both environment using my trusted H264/AVC calibration source. for a while i thought i was going crazy. until i did side by side comparison of both MPV (FFmpeg) and MPC-HC (Direct Show) renders and discovered that with H264/AVC they both render identical R709 space and exact same grey scale. however, when the source is HEVC, MPV pushes the yellow and red up higher on the Rec 709, somewhere around maybe 3~4 delta on the spectrum. which is quite significant for anyone to notice comparing side by side. i also noticed this with HDR HEVC UHD sources, which explains my result earlier today when messing around with HDR playback, that MPV tend to have more saturated look. 

 

sigh... i just feel like the more i mess around with this, the more problems i discover and the deeper the hole i dig. i am going to stop here. i feel like i am just going to cause myself more headaches if i keep going down. 

 

i completely understand the decision for Emby Devs to go with FFmpeg based solution in the first place vs Direct Show based solution. but it just seems that MPV's FFmpeg solution just hasn't caught up with the quality and standard of its Direct Show counter part. 

 

maybe in the future you guys can give us the Direct Show madVR option back as an Advanced option for more advanced users like us. 

Edited by howzz1854
Link to comment
Share on other sites

Guest asrequested

Thanks for the suggestion. i just tried D3D11, D3D11COPYBACK, DXVA2, DXVA2COPYBACK

 

Then that should be fine. There shouldn't be much difference if you use nvdec. And you'd have to hack the playbackhandler.js to be able to use it, anyway.

 

But you can still try using gpu-api=opengl in your mpv.conf

Edited by Doofus
Link to comment
Share on other sites

howzz1854

Then that should be fine. There shouldn't be much difference if you use nvdec. And you'd have to hack the playbackhandler.js to be able to use it, anyway.

 

But you can still try using gpu-api=opengl in your mpv.conf

 

yes, i defaulted back to NVdec, see my edited post above. i previously hit submit too early by accident. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...