Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
26th June 2020, 03:27 | #1 | Link |
Registered User
Join Date: Jul 2018
Posts: 24
|
Is there a simple way to conserve HDR10 through adobe/handbrake?
Hey there,
I have been trying to learn how to conserve HDR10 metadata that a film/file already has on it but I haven't found a good answer. The most certain answer I have found is to take the original UHD and transcode to DNxHR then use 3DLut plugin through davinci resolve 15/16 to create a tone map and then use davinci resolve 15/16 to combine the tone map with the original video stream and export again as DNxHR (which is HUGE, like 700GB huge, so we are talking 1.4 TB just for the middle workflow) and then finally encoding that DNxHR file into HEVC 10-bit HDR10. There is also a person that claims that they get HDR10 conserved by using this FFmpeg script/code: Code:
ffmpeg -hide_banner \ -i "../storage/My.Source.Movie.2019.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.TrueHD.7.1.Atmos.mkv" \ -pix_fmt yuv420p10le \ -max_muxing_queue_size 9999 \ -map_chapters 0 \ -metadata title="My Awesome Movie (2019)" \ -map 0:0 -metadata:s:v:0 language=eng -metadata:s:v:0 title="My Awesome Movie (2019)" \ -metadata:s:t:0 filename="" -metadata:s:t:0 mimetype="image/jpeg" \ -c:v libx265 -preset fast \ -x265-params crf=18:no-sao=1:aq-mode=3:max-merge=4:keyint=60:bframes=3:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display="G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,500)" \ My.Movie.2019.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.TrueHD.7.1.Atmos.mkv Code:
hdr:max-cll=4000,1000:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1):deblock=-2,-3:strong-intra-smoothing=0:sao=0:hdr-opt Can anyone give me any advice on whether the FFmpeg script above will conserve HDR10 metadata (I know the script is just video, I can easily mux together the audio after the video encodes) before I try it for myself? If not can someone either point me to a thread that goes through how to extract the HDR10 metadata from a UHD file and then re-encode the base video and tone map? The person that posted the info I found on redfox.bz was evidently made into a video that was over 2 hours long to explain the workflow but the video is no longer available and the author stopped replying over 2 years ago now. I can't even get the HDR10 metadata conserved on personal video shot with my Samsung Note10+, if I try to re-encode in anyway the HDR10 info is gone. It's still 10-bit BT.2020 SMPTE ST 2086 HDR10 'compatible' but the HDR10 metadata is gone. I have been looking for an answer to this for a long time, please help point in the right direction if its not too much trouble. Thanks for your time. EDIT: I went ahead and compiled my own FFmpeg for windows with all the extra's and it 'seems' to conserve the HDR10 tags on UHD video but I would still like to hear from community members as to what you do personally to conserve HDR10 metadata in a UHD HDR10 video taken, like I said, for instance, from my Samsung Note10+. Thanks Last edited by BobbyBoberton; 29th June 2020 at 06:45. |
26th June 2020, 19:12 | #2 | Link |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,878
|
I believe Zeranoe's GPL builds include x265. That might be simpler for you.
https://ffmpeg.zeranoe.com/builds/ I'm not quite parsing that script mentally. The metadata is in SEI messages in the elementary stream, so those could be copied forward. Alternatively it could be read from the file with MediaInfo or whatever and then those values specified in the x265 parameters. The static 2086 metadata (NOT HDR10+) shouldn't vary across a title. If you are preserving HDR, a tone mapping step shouldn't be needed. If you're changing the color volume or adjusting video levels, you're changing the metadata and will need to calculate new values. What is your actual source? |
1st July 2020, 09:14 | #3 | Link | |
Lost my old account :(
Join Date: Jul 2017
Posts: 341
|
I'm not sure if I understand the issue, just set the flags that matches the source in your re-encode? I dont understand why you wanna add tone map in the mix? I dont use handbreak though, but I have a hard time believing that newer versions cant handle 10bit input properly.
These are the relevant HDR10 metadata flags in x265 (max-cll and master-display values may differ from source to source), and you can just "extract" them by using mediainfo. Quote:
Last edited by excellentswordfight; 1st July 2020 at 09:33. |
|
1st July 2020, 17:54 | #4 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,878
|
Quote:
That said, I'm not aware of any displays doing anything with the mastering display metadata. MaxCLL is the most used. |
|
2nd July 2020, 01:22 | #5 | Link | ||
Registered User
Join Date: Jul 2018
Posts: 24
|
Quote:
I don't want to bring in the tone mapping stuff if it is not necessary, it is just the best info I have bee able to find or been told on other forums for preserving HDR10 metadata. If I run a video that I shot from my phone through my nVidia shield on my TV it will go into 'HDR' mode but if I run it through handbrake with all the correct options set, Quote:
I have gotten CLI FFmpeg working, I will see if using that properly conserves HDR metadata, but, what I am hearing from you is that I should not go down the road of using UHD.mkv -> DNxHR -> 3dLut with DaVinci Resolve -> export DNxHR with lut applied -> reencode to HEVC. This seemed like a ton of work for something that is relatively simple, its not like its HDR10+ dynamic metadata, so I thought there should be a simple way to do it. |
||
3rd July 2020, 07:40 | #6 | Link | ||
Registered User
Join Date: Jul 2018
Posts: 24
|
Also can someone advise me why I cannot set the profile to Main10 for the CLI version of FFmpeg when I just used it to encode some 4k video without issue. I know that that the hdr10=1 and other tags would auto trigger this profiles use but when I try -profile:v main10 before -x265 params but after -c:v libx265 it doesn't give any errors but the encode still says using main profile, not main 10. Also setting -x265-params profile=main10 or profile="main10" I get a profile option not found error and it defaults back to main.
this is the command I used: Quote:
Thanks EDIt: didn't expect this to post so if mod sees it can you release the message i replied with before this one? Thanks, its in reply the first and second reply. EDITEDIT: I should say the settings that auto triggered the main10 profile was: Quote:
Last edited by BobbyBoberton; 3rd July 2020 at 08:04. Reason: release my other post please |
||
7th July 2020, 21:34 | #8 | Link |
Registered User
Join Date: Jul 2018
Posts: 24
|
Um ok, maybe I misunderstood the documentation but I thought -pix_fmt was to explicitly tell FFmpeg what the format of the incoming file, not the output format, but I guess that makes sense because if I drop the -pix_fmt yuv420p10le then it defaults to yuv420p so ok, thank you.
|
8th July 2020, 22:15 | #9 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,878
|
Quote:
|
|
9th July 2020, 01:06 | #10 | Link | |
Registered Developer
Join Date: Mar 2010
Location: Hamburg/Germany
Posts: 10,368
|
Quote:
If you want to specify any properties for the input file, you need to put them before the -i option. Anything after the -i option specifies the output. An MKV file with presumably h264 or h265 inside, you cannot override the "incoming" format anyway, the encoded bitstream clearly defines that, so that isn't often useful. So yeah, you are specifying the output format, which is going to be passed to x265. Although if your input was already 10-bit, it should've just stuck with that. So your input must've been something else then?
__________________
LAV Filters - open source ffmpeg based media splitter and decoders |
|
11th July 2020, 23:49 | #11 | Link | |
Registered User
Join Date: Jul 2018
Posts: 24
|
Quote:
EDIT: So the original was yuv420p and without explicitly setting pix_fmt to yuv420p10le it defaulted to the same colorspace as the input stream Last edited by BobbyBoberton; 12th July 2020 at 00:46. Reason: clarity |
|
12th July 2020, 01:08 | #12 | Link | |
Registered User
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,428
|
Quote:
Ideally you would use a two pass encode while testing so the files were the same size and you can judge them on quality. To do this you also need to compress enough that you can judge differences in quality. From forum user reports and my limited testing I believe that with x265 the difference in efficiency between 8 and 10 bit is not very significant, it is with x264 where you get a big improvement. However, 10 bit is still better and hardware decoding is much more common for 10 bit HEVC so it is also reasonably practical, unlike 10 bit AVC or 12 bit HEVC. I always encode to 10 bit HEVC, when I encode to HEVC, with 8 or 10 bit sources.
__________________
madVR options explained Last edited by Asmodian; 12th July 2020 at 06:47. |
|
12th July 2020, 01:23 | #13 | Link | |
Registered User
Join Date: Jul 2018
Posts: 24
|
Quote:
Can you explain more? or point me to a resource that would help explain why? |
|
12th July 2020, 06:38 | #14 | Link |
Registered User
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,428
|
Because as soon as you change any settings you end up with different average bitrates or file sizes.
With different size files how do you judge the results? If one file is larger it might look only a little bit better, so the setting is equivalent to lowering CRF a tiny bit (performance becomes the deciding factor). It might instead look a lot better and the setting improves quality even if a slightly higher CRF was used (a good setting, it could be worth lower performance). It could be worse too, increasing both the size and quality but making the encode less efficient, decreasing the CRF value slightly would have produced better quality at the same size. It is really hard to judge if the quality improved enough compared to the bitrate increase to be able to separate these. The same is true with a smaller file, is it simply slightly worse quality? The option might make the encode less efficient while also lowering the size, so is worse then simply raising CRF slightly. The only situation you can judge with any accuracy would be if the larger file was worse quality. The only accurate way is to compare quality at the same average bitrate. As an aside, be careful of judging still frames too. Good quality comparison is actually really hard. I can end up focusing on one aspect and tuning to improve that while missing some other aspect getting worse at the same time. I then come back in a few years and feel like an idiot, all that time figuring out the perfect settings and in total they were probably slightly worse than the preset would have been. Especially when I had less experiance but it is still really easy to do. I use more aggressive compression and two pass encoding when testing settings and then run high bitrate CRF encodes after I have them figured out.
__________________
madVR options explained Last edited by Asmodian; 12th July 2020 at 07:00. |
12th July 2020, 12:42 | #15 | Link | ||||
QfG Group Germany
Join Date: Oct 2018
Location: Germany
Posts: 247
|
I Only known 2 different HDR10 metadatas.
BT2020 and P3D65 If you will reencode a HEVC 10-Bit HDR Stream, use following custom strings for x265: Check in MediaInfo this entry: Quote:
Quote:
Quote:
The above examples looks so in MediaInfo: Quote:
I use LSMash for my DNxHR Intermediates, for HEVC Input in Mkv Container i use DGIndesNV or LWLibAv. I'm using for Encoding StaxRip as Gui and x265 as Encoder. It's faster as FFMPEG.
__________________
Last edited by -QfG-; 12th July 2020 at 12:53. |
||||
14th July 2020, 13:13 | #16 | Link | |
21 years and counting...
Join Date: Oct 2002
Location: Germany
Posts: 716
|
Quote:
F.e. in the source video I have here for testing purposes, I only have these values: Code:
Video Format : HEVC Format/Info : High Efficiency Video Coding Format-Profil : Main 10@L5.1@High HDR_Format/String : SMPTE ST 2086, HDR10 compatible Breite : 3 840 Pixel Höhe : 2 160 Pixel Bildseitenverhältnis : 16:9 Bildwiederholungsrate : 23,976 (24000/1001) FPS ColorSpace : YUV ChromaSubsampling/String : 4:2:0 (Type 2) BitDepth/String : 10 bits verwendete Encoder-Bibliothek : ATEME Titan File 3.7.8 (4.7.8.0) colour_range : Limited colour_primaries : BT.2020 transfer_characteristics : PQ matrix_coefficients : BT.2020 non-constant MasteringDisplay_ColorPrimaries : Display P3 MasteringDisplay_Luminance : min: 0.0000 cd/m2, max: 1000 cd/m2 |
|
14th July 2020, 14:58 | #17 | Link |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,803
|
I've always set --max-cll "0,0" if that one is missing. It seems to be quite common that it is.
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
14th July 2020, 18:50 | #19 | Link | |
21 years and counting...
Join Date: Oct 2002
Location: Germany
Posts: 716
|
Quote:
Also I noticed this line: Code:
ChromaSubsampling/String : 4:2:0 (Type 2) EDIT: Never mind, I found the explanation to that type 2 subsampling. Last edited by LeXXuz; 14th July 2020 at 20:27. |
|
15th July 2020, 08:49 | #20 | Link | |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,803
|
Quote:
"The first value is the max content light level (or 0 if no maximum is indicated), the second value is the maximum picture average light level (or 0)."
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
|
Tags |
conservation, ffmpeg, hdr, hevc, metadata |
Thread Tools | Search this Thread |
Display Modes | |
|
|