Dolby Vision now possible through MP4 Mux.

Please post here for issues related to UHD discs
RESET_9999
Posts: 1972
Joined: Mon Aug 05, 2019 7:12 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by RESET_9999 »

P7 is always dual layers.

Single track Dual layer means that the BL + EL are interleaved which is what MakeMKV does
Dual track Dual layer is the Bluray original format.
sofakng
Posts: 74
Joined: Fri Mar 19, 2010 12:51 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by sofakng »

Got. Thanks for the explanation!
LV8HD
Posts: 24
Joined: Tue Jan 11, 2022 3:48 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by LV8HD »

skull88 wrote:
Sun Jun 23, 2024 10:42 pm
LV8HD wrote:
Sun Jun 23, 2024 5:11 pm
Hi everyone, some time ago I asked if anybody here knew how to change maxcll and maxfall values within the hevc stream itslef without the need to re-encode it. Well ,I've finally figured it out.
Thus, a question comes to my mind: how important are these values in the actual playblack? I've seen many movies having those values wrong and sometimes not having them at all.
They don't matter for DV playback for sure, and possibly not in some contexts even for HDR fallback, as Paramount for example continues to not add MDL metadata for their UHD BDs. Curious what the method you figured out is, regardless, please share if you're willing to. Thank you kindly. Cheers. :)
The process is fairly simple and intuitive, you only have to get used to working with hex code editors in order to identify the proper segments to change.
Here's an example:

Let's say I want to change MDL and MaxCLL and MaxFALL values of this hevc stream:

Code: Select all

Video
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5@Main
HDR format                               : SMPTE ST 2094 App 4, Version 1, HDR10+ Profile B compatible
Width                                    : 3 840 pixels
Height                                   : 1 600 pixels
Display aspect ratio                     : 2.40:1
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant
Mastering display color primaries        : Display P3
Mastering display luminance              : min: 0.0001 cd/m2, max: 1000 cd/m2
Maximum Content Light Level              : 763 cd/m2
Maximum Frame-Average Light Level        : 218 cd/m2
The new values are going to be:
MDL: 4000
MaxCLL: 1653
MaxFALL: 614

1) Open up your file with https://github.com/virinext/hevcesbrowser
MDL, MaxCLL and MaxFALL values are stored as SEI NALs within the hevc stream and that's what we are looking for.
For every SEI keep in mind its position and lenght, we will need those values later in the editor.

MaxCLL and MaxFALL:
Image

MDL:
Image



2) Now that we have identified MDL, MaxCLL and MaxFALL positions we can open up the stream with a Hex Editor. I'll be using https://freehexeditorneo.com/ but it's just a matter of personal preference.

We will first change the MDL: go to Select -> Select Range. Swap from Hexadecimal to decimal. Now, 122 is the offset and 33 is its size.

Image

These lines of code contain the MDL values somewhere. To actually understand where and what to change whe first have to convert the decimal value for the max_display_mastering_luminance to hexadecimal using a converter https://www.rapidtables.com/convert/num ... o-hex.html. 10000000 is the decimal value and 00989680 is the hexadecimal value we have to identify and swap.

Image

The Hexadecimal value for 40000000 is 02625A00: this is what we have to swap 00989680 for.

Image


Changing MaxCLL and MaxFALL works the same.

When you're finished just save as .hevc and you're done.

New file:

Code: Select all

Video
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5@Main
HDR format                               : SMPTE ST 2094 App 4, Version 1, HDR10+ Profile B compatible
Width                                    : 3 840 pixels
Height                                   : 1 600 pixels
Display aspect ratio                     : 2.40:1
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant
Mastering display color primaries        : Display P3
Mastering display luminance              : min: 0.0001 cd/m2, max: 4000 cd/m2
Maximum Content Light Level              : 1653 cd/m2
Maximum Frame-Average Light Level        : 614 cd/m2
EDIT:

When muxed to MKV mediainfo shows this error:

Code: Select all

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5@Main
HDR format                               : Dolby Vision, Version 1.0, Profile 8.1, dvhe.08.06, BL+RPU, no metadata compression, HDR10 compatible / SMPTE ST 2094 App 4, Version HDR10+ Profile B, HDR10+ Profile B compatible
Codec ID                                 : V_MPEGH/ISO/HEVC
Duration                                 : 5 min 0 s
Bit rate                                 : 13.7 Mb/s
Width                                    : 3 840 pixels
Height                                   : 1 600 pixels
Display aspect ratio                     : 2.40:1
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.093
Stream size                              : 489 MiB (100%)
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant
Mastering display color primaries        : R: x=0.129280 y=0.005360, G: x=0.000060 y=0.358420, B: x=0.081920 y=0.000000, White point: x=0.010220 y=1.305640
Mastering display luminance              : min: 0.0000 cd/m2, max: 53687 cd/m2
Maximum Content Light Level              : 1653 cd/m2
Maximum Frame-Average Light Level        : 614 cd/m2
SEI_rbsp_stop_one_bit                    : Missing
Conformance errors                       : 1
 HEVC                                    : Yes
  General compliance                     : Bitstream parsing ran out of data to read before the end of the syntax was reached, most probably the bitstream is malformed (frame 0, time 00:00:00.000, offset 0x1D86)
I don't know what went wrong. i guess it only works for MaxCLL and MaxFALL values
skull88
Posts: 46
Joined: Mon Mar 27, 2023 3:08 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by skull88 »

Wow, so it does involve hex editing, that's what I was curious about, or if someone developed some tool open source or something. I really appreciate the detailed explanation sir. Thanks LV8HD. <3
Rororororo
Posts: 12
Joined: Tue May 12, 2020 1:23 am

Re: Dolby Vision now possible through MP4 Mux.

Post by Rororororo »

@RESET_9999

Where'd you get CMv4.0 bloc for Batman 2022?
I've got P5 and P8 WEBs, both of which are 2.9 blocs with only two 4.0 shots and no L3L8L9 metadata
Last edited by Rororororo on Thu Jul 04, 2024 5:42 pm, edited 1 time in total.
ASUS BW-16D1HT 3.10
RESET_9999
Posts: 1972
Joined: Mon Aug 05, 2019 7:12 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by RESET_9999 »

MAX web-dl
Rororororo
Posts: 12
Joined: Tue May 12, 2020 1:23 am

Re: Dolby Vision now possible through MP4 Mux.

Post by Rororororo »

RESET_9999 wrote:
Tue Jul 02, 2024 10:47 am
MAX web-dl
I got MAX WEB-DL and it's just CMv2.9, could you tell me the release name?

Code: Select all

Summary:
  Frames: 253474
  Profile: 5
  DM version: 1 (CM v2.9)
  Scene/shot count: 2427
  RPU mastering display: 0.0001/1000 nits
  RPU content light level (L1): MaxCLL: 440.77 nits, MaxFALL: 50.13 nits
  L6 metadata: Mastering display: 0.0001/1000 nits. MaxCLL: 413 nits, MaxFALL: 65 nits
  L2 trims: 100 nits, 600 nits, 1000 nits
  L2 Trim Count (TargetID, count): (1, 2427) (27, 2427) (48, 2427)"
  L5 Left=0 Right=0 Top=275 Bottom=276
  HDR10 BL MDL: N.A.
  HDR10 BL MDP: N.A.
  Resolution: 3840 x 2160
  FrameRate: 23.976fps
  Duration: 10571.978seconds
ASUS BW-16D1HT 3.10
RESET_9999
Posts: 1972
Joined: Mon Aug 05, 2019 7:12 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by RESET_9999 »

Rororororo wrote:
Thu Jul 04, 2024 5:00 pm

I got MAX WEB-DL and it's just CMv2.9, could you tell me the release name?

L5 Left=0 Right=0 Top=275 Bottom=276
HDR10 BL MDL: N.A.
HDR10 BL MDP: N.A.
Resolution: 3840 x 2160
FrameRate: 23.976fps
This doesn't look like the MAX webdl.. MAX encodes are cropped.

There is no release group. It's on TL

The Batman 2022 2160p MAX WEB-DL DDPA 5 1 DV H 265
Rororororo
Posts: 12
Joined: Tue May 12, 2020 1:23 am

Re: Dolby Vision now possible through MP4 Mux.

Post by Rororororo »

RESET_9999 wrote:
Thu Jul 04, 2024 5:09 pm
Rororororo wrote:
Thu Jul 04, 2024 5:00 pm

I got MAX WEB-DL and it's just CMv2.9, could you tell me the release name?

L5 Left=0 Right=0 Top=275 Bottom=276
HDR10 BL MDL: N.A.
HDR10 BL MDP: N.A.
Resolution: 3840 x 2160
FrameRate: 23.976fps
This doesn't look like the MAX webdl.. MAX encodes are cropped.

There is no release group. It's on TL

The Batman 2022 2160p MAX WEB-DL DDPA 5 1 DV H 265
Aight, got it now, thanks, I was confusing hmax with max.

Code: Select all

Summary:
  Frames: 576
  Profile: 8
  DM version: 2 (CM v4.0)
  Scene/shot count: 7
  RPU mastering display: 0.0001/1000 nits
  RPU content light level (L1): MaxCLL: 414.54 nits, MaxFALL: 10.05 nits
  L6 metadata: Mastering display: 0.0001/1000 nits. MaxCLL: 413 nits, MaxFALL: 65 nits
  L2 trims: 100 nits, 600 nits, 1000 nits
  L8 trims: 100 nits
  L5 Left offset: 0
  L5 Right offset: 0
  L5 Top offset: 1
  L5 Bottom offset: 1
  HDR10 BL MDL: min: 0.0001 cd/m2, max: 1000 cd/m2
  HDR10 BL MDP: Display P3
  Resolution: 3840 x 1610
  FrameRate: 23.976fps
ASUS BW-16D1HT 3.10
DylanValenti
Posts: 24
Joined: Sat Dec 19, 2020 9:42 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by DylanValenti »

How would I be able to re-inject a DV FEL (.h265 file) back into an hdr10 BL (.hevc file). Can I do this with the Do_Vi scripts?
RESET_9999
Posts: 1972
Joined: Mon Aug 05, 2019 7:12 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by RESET_9999 »

You can use the dovi_tool in cli:

dovi_tool_path mux --bl BL.hevc --el EL.hevc -o ST-DL.hevc

or if you don't want to mess with command lines, mux the layers to TS/M2TS with tsmuxer and then mux with mkvtoolnix.


EDIT: I just added support for raw hevc in workflow 4-2 in the latest beta.
DylanValenti
Posts: 24
Joined: Sat Dec 19, 2020 9:42 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by DylanValenti »

Thanks it works perfectly!

If I could get some opinions on something that would be great:

There is a film I’m interested in that has 2 separate releases. One with DV in MEL and a higher bitrate. The other is in DV FEL with a lower bitrate. Should I do the DV FEL with lower bitrate or the DV MEL with higher bitrate?
RESET_9999
Posts: 1972
Joined: Mon Aug 05, 2019 7:12 pm

Re: Dolby Vision now possible through MP4 Mux.

Post by RESET_9999 »

I'm not sure if that would work? are the two BL exactly the same? it must be 1:1 identical to work because the FEL is created by analyzing the BL encode and the master and any difference is recorded in the EL.

Code: Select all

-h [ --help ] Show this help.
--toolset-dir arg (=D:\DoVi_Scripts\tools\DEE)
Toolset installation directory.
-l [ --license ] arg (=D:\DoVi_Scripts\tools\DEE\license.lic)
Toolset license file.
--print-all arg (=0) Enable log printing. Values: 0|1.
--progress arg (=0) Show progress in percentage. Values: 0|1.
--overwrite arg (=0) Allow overwriting existing files. Values: 0|1.
--temp-dir arg (=D:\DoVi_Scripts\tools\DEE)
Directory to store temporary files.
--keep-temp arg (=0) Keep temporary files after execution. Values: 0|1.
--ffmpeg arg (=ffmpeg) FFmpeg executable.
--dvesverifier arg Dolby Vision ES Verifier executable. If not specified, the script will skip the verification step.
--input-format arg Input format followed by format-specific options. Use "--morehelp input-format" for more details.
Values: jpeg2000_list|jpeg2000_mxf|prores_list|prores_mov|tiff_list.
-i [ --input ] arg Input file with mezzanine video. Input directory for list-based inputs.
-m [ --input-metadata ] arg Optional input metadata file. If not specified, the application attempts to extract metadata from
the input.
-b [ --output-bl ] arg Base-layer output file in HEVC format.
-e [ --output-el ] arg Enhancement-layer output file in HEVC format.
--metadata-offset arg (=0) Offset added to each frame index, when accessing frame metadata from the source.
--start arg (=0s) Start position in 'xs' format, where 'x' represents seconds or 'xf' format, where 'x' is a frame
number.
--duration arg (=-1) Duration in 'xs' format, where 'x' represents seconds or 'xf' format, where 'x' is a frame number.
'-1' means "end of file".
--end arg (=-1) End position in 'xs' format, where 'x' represents seconds or 'xf' format, where 'x' is a frame
number. '-1' means "end of file".
--encoder arg HEVC encoder. Values: x265|beamr|impact.
--preset arg Encoder preset. If not specified, selected encoder's default preset is used. Use "--morehelp preset"
for more details.
--data-stream arg (=0) Use data streaming instead of temporary files, wherever possible. Values: 0|1.
--yuv-buffer-size arg (=-1) YUV buffer size in bytes. '-1' means "assign automatically". Relevant only if 'data-stream' is
enabled.
-p [ --encoder-pass-num ] arg (=2) Number of encoder passes. Values: 1|2.
--use-case arg Desired use-case. A combination of content mapping type and enhancement-layer type (fel - full
enhancement-layer, mel - minimal enhancement-layer). Values: no_mapping_with_mel|no_mapping_with_fel
|map_to_1000_nits_with_fel|map_to_1000_nits_with_mel|map_to_600_nits_with_fel.
--morehelp arg Show more help about selected topic. Values: input-format|preset.

Code: Select all

-h [ --help ] Show this help.
-l [ --license ] arg (=D:\DoVi_Scripts\tools\DEE\license.lic)
License file.
--loglevel arg (=info) Logging level followed by log customization options. Use
"--morehelp loglevel" for more details. Values:
debug|error|info|quiet|warning.
--overwrite arg (=0) Allow overwriting existing files. Values: 0|1.
--progress arg (=0) Show progress in percentage. Values: 0|1.
--cc arg (=1) Enable concurrent processing. Use "--morehelp cc" for more
details. Values: 0|1.
--show-frames arg (=none) Show more details about processed video frames. Values:
all|counters|decoder|demuxer|none|resizer|transformer.
-m [ --input-metadata ] arg Optional input metadata file. If not specified, the
application attempts to extract metadata from the input.
-r [ --output-rpu ] arg Output RPU file.
-o [ --output ] arg Output YUV enhancement-layer file (10-bit 420 planar).
--el-type arg (=full) Enhancement-layer type. Values: full|minimal.
--L5 arg (=auto) Dolby Vision level 5 metadata. Use "--morehelp L5" for more
details.
--max-scene-frames arg (=255) Maximum number of frames processed as a single scene
[1:255]. Use "--morehelp max-scene-frames" for more
details.
--duration arg (=-1) Duration (in frames). Value '-1' means "up to the last
frame".
--input-format arg Input format followed by format-specific options. Use
"--morehelp input-format" for more details. Values:
jpeg2000_list|jpeg2000_mxf|prores_list|prores_mov|raw|tiff_
list.
-i [ --input ] arg Input file or input directory, in case of list-based input.
--decoder arg Decoder plugin and decoder options to be used. If not
specified, the application attempts to select plugin
automatically. Use "--morehelp decoder" for more details.
--resize-options arg Resize options. Syntax: "option1=value1:option2=value2".
Use "--morehelp resize-options" for more details.
--it arg Name of image transformer plugin to be used followed by
configuration parameters. Use "--morehelp it" for more
details.
--metadata-offset arg (=0) Offset added to each frame index, when accessing frame
metadata from the source.
--start arg (=0) Start frame.
--input-bl-format arg Base-layer's input format followed by format-specific
options. Use "--morehelp input-bl-format" for more details.
Values: raw.
--input-bl arg Input base-layer file.
--morehelp arg Show more help about selected topic. Values:
cc|input-bl-format|input-format|max-scene-frames|plugins|re
size-options|L5|decoder|it|loglevel.
--temp-dir arg (=C:\Users\david) Directory to store temporary files.
--keep-temp arg (=0) Keep temporary files after execution. Values: 0|1.
--plugin-dir arg (=D:\DoVi_Scripts\tools\DEE)
Directory containing compatible plugins.
Post Reply