Jump to content

Tone-mapping in transcoding HDR for playback on SDR screens??


griffindodd
Go to solution Solved by Luke,

Recommended Posts

vdatanet
13 minutes ago, sooty234 said:

Yeah, Reinhard is the simplest solution, but BT.2390 is the best, and is now industry standard.

719944516_Screenshot2020-12-27123713.jpg.884db786cb10ea4d81c1b90715d45126.jpg

 

The tonemap_opencl filter has some algorithms available:

1398055135_Capturadepantalla2020-12-27alas21_49_22.png.f18d7229ebc19e5e0b23dbba17660423.png

Quote

tonemap

Set the tone map algorithm to use.

Possible values are:

none

Do not apply any tone map, only desaturate overbright pixels.

clip

Hard-clip any out-of-range values. Use it for perfect color accuracy for in-range values, while distorting out-of-range values.

linear

Stretch the entire reference gamut to a linear multiple of the display.

gamma

Fit a logarithmic transfer between the tone curves.

reinhard

Preserve overall image brightness with a simple curve, using nonlinear contrast, which results in flattening details and degrading color accuracy.

hable

Preserve both dark and bright details better than reinhard, at the cost of slightly darkening everything. Use it when detail preservation is more important than color and brightness accuracy.

mobius

Smoothly map out-of-range values, while retaining contrast and colors for in-range material as much as possible. Use it when color accuracy is more important than detail preservation.

Default is none.

 

 

Link to comment
Share on other sites

sooty234

Here you can see the difference between reinhard and bt.2390

reinhard

464658768_reinhard(Umbrella).thumb.jpg.b4b8bb76079ec102acfb5cb88e372cce.jpg

 

bt.2390

1503700294_bt.2390(Umbrella).thumb.jpg.d6ce6a1a1afd56b4d4814b69add67813.jpg

 

You can see that the white point is higher, retaining more luminance. Also retaining more of the finer detail. You can see more grain in the wood of the violin.

 

Link to comment
Share on other sites

vick1982

so still no HDR  tone mapping on emby ?  

all the things I read from developers on here in the past just veer off talking about quality not making much difference etc... like others have said its just about only needing to keep one file and it can be played on anything. To me it sounds as stupid as someone using windows media centre back in the day that can only play direct files to say there is no need to develop systems that can transcode... just watch your shit at home.

Edited by vick1982
Link to comment
Share on other sites

HDR Tone mapping when transcoding will be in Emby Server 4.6. Stay tuned to the beta channel over the next week if you'd like to help test.

  • Like 4
Link to comment
Share on other sites

sooty234
3 hours ago, Luke said:

HDR Tone mapping when transcoding will be in Emby Server 4.6. Stay tuned to the beta channel over the next week if you'd like to help test.

I'm going to be all over that!

Link to comment
Share on other sites

  • 2 weeks later...

Just be aware it takes a beefy CPU to do tone mapping while transcoding in real-time.

Even with tone mapping built in the vast majority of people will be better off with a normal 1080 version and a 4K version in a library only shared with people who can direct play it.

Link to comment
Share on other sites

sooty234

You'll be surprised at how little tone mapping will add to the processing. All transcoding will be 1080, so it will actually be quite easy. I'll wager that a gen 6, 4 core i5 will do up to 3 consecutive transcodes, depending on the bandwidth it's transcoding down to. 1080 @ 10Mb/s should be easy enough.

  • Like 1
Link to comment
Share on other sites

sooty234

You guys can already get an idea of what it will be like. Just transcode a 4k 10bit SDR video. Tone mapping will be just a bit more than that.

Link to comment
Share on other sites

38 minutes ago, sooty234 said:

You'll be surprised at how little tone mapping will add to the processing. All transcoding will be 1080, so it will actually be quite easy. I'll wager that a gen 6, 4 core i5 will do up to 3 consecutive transcodes, depending on the bandwidth it's transcoding down to. 1080 @ 10Mb/s should be easy enough.

A lot of folks use machines less powerful than that but upon what are you basing these conclusions?

Link to comment
Share on other sites

sooty234
2 minutes ago, ebr said:

A lot of folks use machines less powerful than that but upon what are you basing these conclusions?

Just try my last suggestion.

Link to comment
Share on other sites

sooty234

@softworkz will tell you, reducing from 10bit to 8bit and applying debanding and dithering is the hardest part. Tone mapping is mostly about color accuracy. Of course it adds a bit of processing, but in downscaling with 10 to 8bit conversion is a sizeable render on its own. Adding the tone mapping into the mix doesn't require a lot of heavy lifting.

Link to comment
Share on other sites

4 minutes ago, sooty234 said:

reducing from 10bit to 8bit and applying debanding and dithering is the hardest part

But all of that has to be done as well to accomplish the final result.

Link to comment
Share on other sites

Try it yourself. As an example if I run:

ffmpeg -i "F:\Movies\R\Rogue One A Star Wars Story (2016)\Rogue One A Star Wars Story (2016) - 4K.mp4" -vf zscale=transfer=linear,tonemap=mobius,zscale=transfer=bt709,format=yuv420p test.mkv

image.png.413ec11d0dd3bacf6c8beedd692ad35b.png

Not much going on here and look at the speed of 0.196x

 

Link to comment
Share on other sites

To be clear - we're going to make this work as best we possibly can but I think it is a bit optimistic to think it is going to be a piece of cake on a lot of hardware.  We'll see as the proof will be in the pudding.

Link to comment
Share on other sites

sooty234

Oh I wasn't implying that the process is simple. Looking at the algorithms that haasn has written, it's very complicated. But my general point is that adding tone mapping to an already in place downscaling of 4k to 1080 and reduction of color from 10bit to 8bit shouldn't add a lot more processing.

Link to comment
Share on other sites

Try running what I listed above on one of your HDR 4K files and see if you can get anywhere near a speed of 1x.  I can't on an i7.

In general a lot of people can't transcode a 4K file (tone mapping aside) near real time via CPU.  GPUs are game changers for transcoding power but tone mapping doesn't fit very well in that yet.

The command I used above is pretty basic to boot compared to what a typical transcode line will be when this tone mapping is added on top of what it already has to do.

If I resize first to 720 resolution with "-resize 1280x720" before the input "-i" I can double the speed but it's still to slow on my system for real-time use.

I'm sure there are some optimizations that could be done over these basic command lines but this gives you a good indication of how brutal this is with CPU only.  So a lot of systems may not be able to perform real-time HDR->SDR but could still use this in the background to convert files into other formats which is still a major gain in functionality.

As ebr mentioned the proof is in the pudding.

Link to comment
Share on other sites

sooty234
34 minutes ago, cayars said:

Try it yourself. As an example if I run:

ffmpeg -i "F:\Movies\R\Rogue One A Star Wars Story (2016)\Rogue One A Star Wars Story (2016) - 4K.mp4" -vf zscale=transfer=linear,tonemap=mobius,zscale=transfer=bt709,format=yuv420p test.mkv

image.png.413ec11d0dd3bacf6c8beedd692ad35b.png

Not much going on here and look at the speed of 0.196x

 

I wish you'd at least try and think before you say something. You appear to be rendering to 4k x264. That's absolutely massive (and stupid). No downscaling. At 1080, there'll be 75% less data to render.

Please go away.

Link to comment
Share on other sites

Did you notice the resize command I added?  Did you look at the resolution after it converts?

Do you understand what's being shown?

Edited by cayars
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...