Bake the DoVi into your clip
This avisynth plugin reads the Base Layer, Enhancement Layer and RPU data from a profile 7 DolbyVision stream to create a clip with the DolbyVision data baked in.
- Get dovi_tool and libdovi and save the dovi.dll such that it is reachable for avisynth (like in C:\Windows\System32)
- https://github.com/quietvoid/dovi_tool/releases/tag/1.5.5
- https://github.com/quietvoid/dovi_tool/releases/tag/libdovi-1.6.7
- Extract the Base and Enhancement Layers separately from the initial profile 7 stream
- Extract the RPU data from the Enhancement Layer using dovi_tool
- Write a Avisynth script like the example below
example.avs:
bl=DGSource("blclip.dgi")
el=DGSource("elclip.dgi")
DoViBaker(bl,el,rpu="RPU.bin")
This plugin uses the metadata from the RPU file to compose the DolbyVision HDR picture out of the Base Layer (BL) and Enhancement Layer (EL). Display Management (DM) metadata will not be processed. It is however possible to use level 1 maximal pixel brightness data from DM by providing a collection of LUTs and limits of validity measured in nits of max-content-light-level. These will then be processed internally. (The LUT processing implentation is based on: https://github.com/sekrit-twc/timecube).
bl=DGSource("blclip.dgi")
el=DGSource("elclip.dgi")
DoViBaker(bl,el,rpu="RPU.bin",cubes="lut_1000.cube;lut_2000.cube;lut_3000.cube",mclls="1000;2000",cubes_basepath="C:\")
This will use the file lut_1000.cube for frames where the max-content-light-level is below or equal to 1000nits, the file lut_2000.cube for above 1000 but below or equal 2000 nits and lut_3000.cube for all frames above 2000nits. All cube files must be available in the path given to cubes_basepath, in this example it would be "C:\".
You can get the current tonemapping value of max-content-light-level by reading the frame property "_dovi_max_content_light_level":
ScriptClip("""
mcll=propGetInt("_dovi_max_content_light_level")
subtitle("maxcll = " + string(mcll))
""")
This application analyzes the RPU.bin file in order to show information relevant to deciding whether it is worth to use DoViBaker or if this can be skipped completly and the Base Layer can be used directly.
usage: DoViAnalyzer.exe <path_to_rpu.bin_file>
The output will show the following attributes:
- clip length
- overall max-content-light-level
- unusual color matrices defined by the RPU file
- mapping non-identity introduced by the RPU file
- enabled processing of the Enhancement Layer
The last three will indicate that the look of the clip will be different when DolbyVision is taken into account compared to just playing the Base Layer clip. This will mean that the processing using DoViBaker is necessary in order to get the DolbyVision look.