lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
544 stars 25 forks source link

Processing HDR10 4k Content #81

Closed TehMaster closed 3 years ago

TehMaster commented 3 years ago

Hey All,

I k now @donmelton has mentioned he does not have a lot of 4k content, but how is everyone else handling transcoding 4k HDR10 content? It seems other_transcode drops the required HDR metadata (listed below), but the output file is indeed still HDR and will play as such if you manually switch on HDR. MediaInfo does not show the transcoded file as HDR10.

Metadata removed from transcoded file (with example data): HDR format : SMPTE ST 2086 Mastering display color primaries : Display P3 Mastering display luminance : min: 0.0001 cd/m2, max: 1000 cd/m2

So i've researched that this is because you cannot write the -x265 options as needed (like -masterdisplay) when using hardware, but you can when using software. This obviously defeats the purpose of hardware transcoding and the speed benefits it provides, so i continued to research. It seems FFMPEG HDR10 is a popular topic...

I ran into a project (https://github.com/SK-Hardwired/nv_hevc_hdr_patcher) that was created for this exact issue and writes back the metadata after encoding which seems to be working for my tests thus far. I took the output from other_transcode (.mkv), pulled the video track out into a .h265, ran HDR Patch command, and combined the file back into the mkv. The metadata is now almost identical to the original, and shows properly as HDR10. Playing this file automatically switches on HDR for my receiver/Projector.

So - I know this is a bunch of random info, but i cant be the only one trying to best figure out how to transcode my 4k library and preserve the correct HDR metadata, right? If anyone else is going through this or has better ways please do share as the above process is not ideal.

EDIT - It seems plex has some trouble playing the test files above. I've had 1 of 3 play fine while the other 2 stuttered. MPC plays them fine. Some I merged with ffmpeg, some with mkvtoolnix, so i'll collect some additional data and play around.

khaosx commented 3 years ago

@TehMaster Greetings! Sorry for the delay in getting back to you on this, but I will see if I can shed any additional light on the subject for you. I say additional, because you've already sussed out the major issues and workarounds.

The long and short of it is that we're at the mercy of ffmpeg for the hardware conversions. As they improve their support for things like HDR, they will be integrated into other-video-transcode as soon as we have time to build out test cases and @donmelton can code in the support. Until then, we're in the same boat as you, relying on some metadata shenanigans to side load the correct info to make the playback device behave. HDR10 is pretty simple, since the metadata required is global, affecting the whole video stream. DolbyVision is another matter entirely, implementing a per-frame scheme that can't really be done with the currently available tool chain.

A couple of us have patched together scripts that do exactly what you describe above, with varying degrees of success. I have seen the issues you're describing with Plex - about half of the films I've tried seem to have one difficulty or another. There's no good answer right now, but as the tools improve support, I think we'll be able to bake that support in.

For reference, my script (in Powershell) can be found here. It's a brute force effort, but it more-or-less works.

Hope this was helpful, feel free to ask any questions that come up, or pass along the results of your research.

lisamelton commented 3 years ago

@khaosx Thank you for that excellent answer, sir!

TehMaster commented 3 years ago

Thanks @khaosx for the details. I kind of got that feeling during the last several days of research.. Man what a hole this turned out to be. I quite enjoy your PS script and will be adding it to my process. I suppose i'll simply wait for the tools to catch up, but patience is definitely not my best quality... :)

So the real question is do I pick up another harddrive to store a bunch of 4k files waiting for their chance at transcoding glory, or delete them and go through the process of re-ripping.. Fun times!

Appreciate you guys as always.

asheimo commented 3 years ago

I have found with this project you are always going to be in the market for more storage :)

mikebm commented 3 years ago

@khaosx The script works great for copying HDR10 metadata into my other_transcode 4k rips, but it doesn't seem to copy HDR10+ (Dolby Vision), has anyone found any script to copy that metadata over? Thanks, and thanks Don for such an awesome script. It made my ripping so much better, just wish I found other-transcode before transcode_video

klogg416 commented 3 years ago

@mikebm, I don't have a script for you, but I do have a pedantic clarification which may help in your future searches. There are currently three HDR standards:

All this to say, if you are scouring the larger interwebs for Dolby Vision based solutions, "HDR10+" will lead you astray. Good luck!