UnicornTranscoder / UnicornFFMPEG

Fake Plex Transcoder to get the arguments for FFMPEG
MIT License
97 stars 14 forks source link

New Tonemapping Function #8

Closed camjac251 closed 4 years ago

camjac251 commented 4 years ago

I had opened an issue about tonemapping in the UnicornTranscoder repo back in 2018 https://github.com/UnicornTranscoder/UnicornTranscoder/issues/29

However at the time, HDR to SDR was not as well documented as today since 4K blu-rays were still relatively new. Jumping to now though, HDR movies are quite a common format and sometimes the highest quality version available. With movie remasters, sometimes they only offer a 4K release and it's counterpart in regular HD would be an older version of the media, which doesn't offer that same quality that the 4K HDR version would have. The problem with HDR to SDR for the longest time was it could not process in realtime. Luckily though I think that might've changed now recently.

Progress was made for realtime HDR > SDR tonemapping by so-rose with Jellyfin users in mind. However it is using ffmpeg in its workflow so it should work here too. https://github.com/jellyfin/jellyfin/issues/415#issuecomment-614956993 They proposed https://github.com/so-rose/fast-hdr which is an inbetween from ffmpeg decoding and ffmpeg encoding. Plex has been attempting to solve the HDR to SDR with using mpv at the client level which would allow for tonemapping to happen in their Mobile/PC apps. However, that only works when someone is using direct play (or direct stream, in plex). Whenever transcoding of an HDR file occurs in plex, the HDR metadata and bit depth of video are never maintained, instead downsampled causing the video to not be able to be tonemapped by any player as it is seen as a regular 8-bit 4:2:0 rec.709 stream.

Would it be possible to explore the possibility of implementing fast-hdr for UnicornFFMPEG based on the video input pixel format?

Maxou44 commented 4 years ago

We don't change the Plex ffmpeg parameters and we can't do it or we'll break compatibility with some apps/players. If I'm right, Plex team is working on this feature since few months, just wait and see 😉

camjac251 commented 4 years ago

I hope they are. Do you happen to have a link about where they talk about it? I must've missed it. My understanding has been that from the forums, transcoding HDR has never been a priority.

Did you happen to take a look at the links I posted? It shouldn't break compatibility with Plex clients as it is a pipe from ffmpeg then piped back to ffmpeg, so the parameters set by Plex should not need to change.

Maxou44 commented 4 years ago

If I'm right it was on a comment about the latest transcoder preview thread

It can break compatibility if clients apps don't receive what they want, we can't do it like that.

camjac251 commented 4 years ago

I'll check out the code of how this ffmpeg works but it should be able to use whatever ffmpeg parameters that plex wanted, after fast-hdr does its thing surely.

I was able to find the mentioning of tonemapping that you were talking about https://forums.plex.tv/t/plex-media-server-1-16-7-1597-updated-new-transcoder-preview/451135

Additionally, this update moves us towards being able to support tone-mapping HDR media to SDR for playback. This isn’t available in this preview, and I can’t make any promises on the timeline on it, but know that it’s something we’re working on 🙂

I hope that this is still is in their list of priorities as the development of Plex has been slowing down in development in recent years.

Maxou44 commented 4 years ago

This repository only contains a fake ffmpeg for the Unicorn Transcoder project, it's not a custom version of ffmpeg