erazortt / DoViBaker

Bake the DoVi into your clip
GNU General Public License v3.0
45 stars 7 forks source link

A few questions #3

Closed danbezerra closed 6 months ago

danbezerra commented 2 years ago

Sorry, I couldn't find another way to reach out and ask these questions:

  1. Does this project allow the creation of a RPU.bin file with the FEL enhancements, allowing devices that today can't process the FEL layer to take advantage of it?

  2. Where do I find the cube files you mentioned in the readme file?

Thanks

erazortt commented 2 years ago

Hey,

  1. I don't think I understand your question. Can you rephrase it?
  2. It depends on what you want to achive. For example you might convert to SDR or to HLG. In case you want to convert to HLG take a look into this project: https://github.com/wswartzendruber/hlg-tools

Greets

danbezerra commented 2 years ago

Sorry, I am catching up on the DV details. Is it correct to say that the goal of DoViBaker is to "bake" the FEL improvements into the BL? So for titles where the BL is poorly encoded (such as Total Recall), all improvements from FEL could be injected into the BL and therefore available to players that can't process FEL as of today?

I also don't have experience with AVISynth so I need to get my feet wet here. If you have any step by step guidance would be greatly appreciated!

erazortt commented 2 years ago

Yes, the idea is to bake in as much of the DV as possible. This means, all processing indicated by EL(both FEL and MEL) are baked into the BL. The resulting stream is PQ12 (aka, HDR10 without metadata but at 12 bits per component). The information needed for the metadata can be manually reentered during the encoding with the new maxcll information from the RPU which can be shown by DoViAnalyzer.

Tell me what you try to achieve and perhaps I can help with avisynth.

Am 19.09.2022 um 01:37 schrieb danbezerra @.***>:  Sorry, I am catching up on the DV details. Is it correct to say that the goal of DoViBaker is to "bake" the FEL improvements into the BL? So for titles where the BL is poorly encoded (such as Total Recall), all improvements from FEL could be injected into the BL and therefore available to players that can't process FEL as of today?

I also don't have experience with AVISynth so I need to get my feet wet here. If you have any step by step guidance would be greatly appreciated!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

danbezerra commented 2 years ago

Thanks! I first tried with the 32-bit version of AVISynth but then I learned I needed AVISynth+ with 64-bit support. (I also tried to recompile DoViBaker in x86 but hit some issues so I abandoned this idea).

The DoViBaker_x64.dll plugin is successfully loaded when I open my test.avs with MPC-HC x64. However, I am getting the following error message: "There is no function named DGSource". I am using the example script you posted as a reference:

LoadPlugin("d:\dovi\DoViBaker_x64.dll")

bl=DGSource("d:\dovi\bl.hevc") el=DGSource("d:\dovi\el.hevc") DoViBaker(bl,el,rpu="RPU.bin")

DoViBaker(bl="d:\dovi\BL.hevc",el="d:\dovi\El.hevc",rpu="d:\dovi\RPU.bin") z_ConvertFormat(pixel_type="YUV420P16",colorspace_op="rgb:std-b67:2020:full=>2020ncl:std-b67:2020:limited",dither_type="none",resample_filter="spline36",resample_filter_uv="spline36")

ScriptClip(""" mcll=propGetInt("_dovi_max_content_light_level") mpq=propGetInt("_dovi_max_pq") subtitle("maxpq = " + string(mpq) + "; maxcll = " + string(mcll)) """)

Any idea of what I may be doing wrong?

danbezerra commented 2 years ago

OK, learned that DGSource seems to come from another plugin (DVDecodeNV.dll). Perhaps need to convert the HEVC into dgi files as well?

Anyway, when I try to load DGDecodeNV.dll as part of the AVS script, I get a different error: "Cannot load file. Platform returned code 126: The specified module could not be found."

danbezerra commented 2 years ago

Ok, I kept researching this area and got a script to work with MPC-HC player. I'm using FFVideoSource instead of DGSource:

bl=FFVideoSource("d:\dovi\BL.hevc") el=FFVideoSource("d:\dovi\EL.hevc") DoViBaker(bl, el, "RPU.bin")

When I open the AVS plugin on MPC-HC, I can see the results of the FEL layer applied to the BL. Fantastic. Now I need your help as I have a knowledge gap here:

  1. I'm using FFMPEG do re-encode the merged video with a simple command line: fmpeg -i "example.avs" -x265-params "colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084:hdr10=1:max-cll=0,0:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)" "out.hevc"

    Anything else I need/should add here? I am still trying to find the right CFR.

  2. you mention different LUT cube files. Can you make them available or send me to a location where I can download them?

Thanks!

erazortt commented 2 years ago

Hey, ok you did very well until now. Concerning DGSource, this should actually work with a current version: https://www.rationalqm.us/dgdecnv/binaries/ And yes, the HDR stuff is mainly 64 bits.

for the x265-params:

For the final encoding, I would very strongly advise to add an explicit conversion to YUV as the last command in your script: z_ConvertFormat(pixel_type="YUV420P10",colorspace_op="rgb:st2084:2020:full=>2020ncl:st2084:2020:limited",dither_type="error_diffusion",resample_filter="spline36",resample_filter_uv="spline36",chromaloc_op="center=>top_left")

All this is needed in case you want to create a static HDR10 stream from the DV. There are no cube files which could be used for this conversion. In case you want to convert to HLG instead, then the usage of cube files is necessary, since these provide the actual conversion. Are you interested in a HLG conversion, or is your scope to convert just to static HDR10?

danbezerra commented 2 years ago

Thanks! I added all flags you suggested and also the Z_convertFormat step. The result was exactly what I expected: A compliant HDR10 file! I compared the parameters on MediaInfo and all looks good.

You are correct - my goal is to have a static HDR10 stream with the FEL improvements added on. Now I can also play with DoVi and see if I can re-inject the RPU to the new HDR10 stream as well, so I could choose to play it with a device that can handle the dynamic metadata but not the original FEL layer. Or just rely on MadVR to handle the dynamic tone mapping on the fly.

Good idea on downconverting it to 1080p for the sake of maxCLL analysis!

What compression factor (CRF) do you actually use on your backups? I'm playing with 18 and may go down to 14 just to see the difference.

Also, any disadvantages with using FFVideoSource instead of DGSource (qualitywise)? I'm using an AMD desktop for my initial tests, and it seems that DGSource requires a NVidia GPU (which would explain why I can't make it work)

Thanks!

erazortt commented 2 years ago

You are correct - my goal is to have a static HDR10 stream with the FEL improvements added on.

Ok, but I want to make clear that most of the time the EL streams are used to increase the dynamic contrast above 1000 nits. Adding the FEL and then watching with a TV of only 1000 nits will be counterproductive, since in this case the BL itself would have had the better contrast. Creating a static HDR10 is a nice way of introducing yourself into this whole DV, HDR10 and PQ10 subject, but this not really the usecase of this plugin.

Now I can also play with DoVi and see if I can re-inject the RPU to the new HDR10 stream as well, so I could choose to play it with a device that can handle the dynamic metadata but not the original FEL layer.

No, you cannot. Re-injecting the RPU is not possible since this would do the same operations again on a DV compatible TV, resulting in a double processing.

danbezerra commented 2 years ago

I'm targeting a few specific FEL titles where the BL was poorly mastered: Saving Private Ryan, Invasion of body Snatchers, Total Recall, Annihilation and a few others. On all those titles, the FEL layer fixes chroma and other issues present in the BL, and since I can't play the FEL layer with my current setup, DoViBaker came as a nice tool to fix that.

My understanding of the DoViBaker process is that the output BL file is still a static HDR10 file, with no dynamic tone mapping applied to it (even because DTM needs to know the max nits of the display to proper tone map the output). I see your point of double processing if my TV can consume the FEL data directly. But in my case, it can't. It can only consume the BL and the RPU. So in this specific case, I still believe that by creating a DV file with the updated BL + RPU would be correct. Basically, the original set was a BL + FEL + RPU, with the RPU working with the assumption that the FEL layer was properly consumed. Now, it will become a BL + RPU (or BL + MEL +RPU), and since the BL was updated with the FEL improvements, the RPU file would still be "valid".

Makes sense? And thanks for all the guidance!

danbezerra commented 2 years ago

where the BL was poorly mastered:

Or it is just a side effect of FEL. Please paste some screenshots, better in PQ AVIF.

Very good point. Most of the time the problem is a consequence of only applying the RPU while ignoring the FEL layer on players that can't handle FEL yet. But there are a few titles where the problem is visible on plain HDR10 BL as well:

rome1983 commented 1 year ago

Sorry, I couldn't find another way to reach out and ask these questions:

1. Does this project allow the creation of a RPU.bin file with the FEL enhancements, allo

Sorry, I couldn't find another way to reach out and ask these questions:

1. Does this project allow the creation of a RPU.bin file with the FEL enhancements, allowing devices that today can't process the FEL layer to take advantage of it?

2. Where do I find the cube files you mentioned in the readme file?

Thanks

Hi, How long did the process take?

Crosis47 commented 7 months ago

Sorry for resurrecting an old thread but I just wanted a bit of clarification to help my workflow and this thread was in the right context. Is DoViBaker needed for a movie that only has an MEL? I ask because I use HandBrake for it's simple GUI and queuing capability when possible and it is unable to bake EL into a DVp8 file but it does use the BL and RPU data. As I understand it, the MEL has no enhancements to bake into the BL so my thought was that it was not necessary to bake it in. However, my understanding of FEL / MEL is topical at best. Thanks for any info!

quietvoid commented 7 months ago

Is DoViBaker needed for a movie that only has an MEL?

No, it's only necessary for titles that have a FEL.