Feature request: HDR to SDR tonemapping

Yep, I’ve played around a lot with this. There are a few ways to convert HDR to SDR using ffmpeg but none of them are usable for real-time transcoding. This isn’t a Plex issue per say, just the state of tools it uses.

more info

https://stevens.li/guides/video/converting-hdr-to-sdr-with-ffmpeg/

The problem with this approach is that it doesn’t support anything near real-time use since it’s hampered by single core speed.

Tone mapping can be done on the gpu.

The creator of dgindexnv has made a tone mapper dll that decodes from a Nvidia Gpu.
http://rationalqm.us/board/viewtopic.php?f=5&p=8506&sid=34dc0b7b047aa7cbb60afe8d3baa824b#p8506

He pulls 200fps+.

1 Like

You can do it without a GPU as well. Problem is that it’s not a lot of help to Plex or other media server companies until this type of feature is built into ffmpeg at the core level or the various players that are used. They also need to do real-time or better speeds while also supporting the current processing the files need to do.

We’ll get there but it’s going to be while yet.

Why would you do it with a CPU… waste of encoding power when another device can do it… and MUCH better.

If plex just uses what ffmpeg does then we should be finding those forums.

Typically because GPU’s can’t touch the quality of CPU at the same bitrates.

The best option would be to support both if possible so everyone is happy. :slight_smile:

@cayars said:
Typically because GPU’s can’t touch the quality of CPU at the same bitrates.

The best option would be to support both if possible so everyone is happy. :slight_smile:

Not sure what you are referring too? We are talking about Tonemapping… Which can be done at the GPU level… and encoding can still be done at the CPU level. Also GPU encoding is fine at HIGH bitrates… Low ones I do agree with you… It sucks.

1 Like

Yes, quite aware of this. However when tonemapping via ffmpeg the tone-mapping algorithm place 100% load on a single CPU core.

@cayars said:
Yes, quite aware of this. However when tonemapping via ffmpeg the tone-mapping algorithm place 100% load on a single CPU core.

Then it sucks. Plex can make there own algorithm and make it decode on a GPU level. That’s what DGIndexNV guy did… and hes one guy.

Sure they could but that would require them to completely change the pipeline of how Plex works and would no doubt cause a ton of new issues. Just not worth it. A lot of people want this functionality and it will eventually get added to ffmpeg which will allow it to get used in Plex.

It’s far more complicated then you think it is. DGIndexNV does one thing in one controlled situation. It isn’t trying to convert the video to HLS for streaming, it isn’t downscaling when needed or enforcing bit rate caps and all the other things you take for granted when using Plex.

The tonemapping is a “filter” and just one part of a much larger conversion that takes place and needs to be able to work as such.

Yes the current situation DOES suck.HOWEVER, you will want to keep in mind that real-time conversion including HDR to SDR will never look as good as a properly mastered 1080p file. From a quality standpoint ONLY you are far better off having two versions of the file. One is 1080p and the other is 4K/HDR. You then use the appropriate file mastered for the display you are using.

If you only have the 4K as source then you can semi-“master” your own version using ffmpeg or other tools offline to create a good version usable for 1080p but it’s unlikely you will do better then a studio release since they have very expensive equipment used specifically for this purpose.

Most of us who venture into 4K will keep two versions of the file that are direct playable on different devices so we always have the best version available without taking a downgrade due to transcoding.

Life is full of compromised and this is one of them. :slight_smile:

Once upon a time many of us had to do the same thing with DVD and BR releases. When BR was first released many people still had analog CRT TVs that could only play SD content. Not unlike 4K today and 8K in a few years. We have to learn to adapt our media needs and uses to accommodate the technology that is available. We can do this now at the expense of additional storage (cheap considering).

There are a few topics online on how to use ffmpeg to tonemap,

Does that mean we’re near getting this feature implemented?

From my understand Plex Media Player on Windows has an HDR to SDR converter in the player. Can this be added at the server level? or even android level…

1 Like

I would like to see tone mapping as well.

1 Like

Yes, I’ve tested Plex’s implementation of HDR > SDR in their windows player and the results were a huge improvement. I switched back and forth between the 1080p release and the 4k hdr release (tone mapped by plex), and they looked almost identical. This is very encouraging. They’ve clearly found success in windows, I wonder if we can expect to see it on other platforms in the near future.

I’m really looking forward as well. I know tone mapping will never look as good as a properly mastered file, but for the TVs I would like tone mapping to work for I don’t care about quality as much.

1 Like

Tonemapping on the PMP exists thanks to the backend player MPV. MPV is cross platform so it should work the same on Linux and Mac. Nvidia Shield on the new Oreo firmware supports tonemapping. What we need is Plex to use ffmpeg to tonemap the screenshots and transcodes, or at least transcode an HDR stream instead of converting the HDR stream to an SDR stream without tonemapping. FFmpeg supports tonemapping filters in its current version but Plex needs to implement them. x265 (HEVC) support would be a nice bonus for HDR transcodes.

4 Likes

Any update on the progress?

3 Likes

Any update on this ISSUE needed badly as 4K content is becoming more and more

1 Like

If only plex better supported multiple qualities of media and was smarter about choosing the appropriate file for the applicable client.

IE given
movie (2018) - 4khdr.mkv → stream only to 4k/hdr capable devices
movie (2018) - 1080p.mkv → stream/transcode to all other devices

this would likely need support at both the client and server;

server to client: i have multiple qualities of media available, what is highest supported quality (resolution/bitrate/etc)

and/or

client to server: i can support up to #### resolution, please send appropriate quality content, or otherwise do not send or transcode higher than ####
server: from multiple choice of qualities available, choose native lower quality direct stream closest to client capabilities, avoid transcoding 4k

or simply option to prevent 4k/hdr transcoding for non 4k/hdr streams, even if this blocks the media entirely (ie no alternative quality available).

3 Likes