Log in

View Full Version : [DDVT Tool] Dolby Vision RPU Demuxing / Injecting / Editing.


Pages : 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

von Suppé
16th August 2022, 13:39
One thing you could do is extract the RPU using the DEMUXER, apply the delay when using the INJECTOR to get it in sync with the movie (no custom.json for now, borders are set in the next step), extract the new RPU using the DEMUXER, this time using INJECTOR with 0 delay along with custom.json.

I also considered this way but I did not like the idea of having to extract RPU again after first injection. Too laborious. And I already wanted to know how to manually add delay with dovitool.exe. So I read and did some tryouts.
I got the "duplicate" function working, which wasn't so difficult actually. Set a sourceframe, where and how many duplicated frames you want and Bob's your uncle. It sure beats the hell out of manually editing a kazillion frameranges in json :)
BTW next to the delay function, I'm guessing QfG injector would also apply either "duplicate" or "remove" somewhere for the last frames, in order to match the total amount of actual frames in target-video.

Anyways, so I delayed the RPU first, and the resulting RPU I edited with the L5 edits json file.
Some quick & dirty frame-infos showed L5 edits in the correct place this time. Injecting and remuxing now, hoping on good end-result.

note that dovi_tool is 0-based, i.e. the first frame is numbered 0.

Yes, I know. For framenumber stuff and viewing I use VirtualDub, which also starts framecount at zero.

GodzilaAvenger
16th August 2022, 16:09
Normally you can just look at if `scene_refresh_flag` is equal to 1, indicating a scene cut.
There's another script from someone at MakeMKV that can extract the scene cuts, as well.

Thanks, I didn't know that. I'll look up the script.

I also considered this way but I did not like the idea of having to extract RPU again after first injection. Too laborious. And I already wanted to know how to manually add delay with dovitool.exe. So I read and did some tryouts.
I got the "duplicate" function working, which wasn't so difficult actually. Set a sourceframe, where and how many duplicated frames you want and Bob's your uncle. It sure beats the hell out of manually editing a kazillion frameranges in json :)


Glad to see you got it working. Demuxing and remuxing does take a lot of time, especially if you're using HDDs!

Fortune
16th August 2022, 18:39
Use DDVT_DEMUXER to extract the RPU.bin file, then go to the tools folder and use dovi_tool export, i.e.

cd tools
./dovi_tool export [args]

(populate [args] with the proper arguments). This will convert RPU.bin into a .json file which you can view in a text editor.

On a side note, DDVT_FRAMEINFO seems to extract RPU.bin from the .mkv file each time it is called, which can be time-consuming. Instead you can use DDVT_DEMUXER to extract the RPU.bin file once and then use dovi_tool info to get information about a specific frame.

Thanks Godzilla.
I have extracted the RPU.bin but I dont have dovi_tool_export application.
Sorry I dont really understand can you expand on your explation please if possible.

Would be real nice if possible we can add a script for novices like me lol

GodzilaAvenger
16th August 2022, 18:58
export is a functionality of dovi_tool, which comes with DDVT.

Open the DDVT folder, then go to tools. You'll see dovi_tool.exe there. Open a terminal in that folder and use
.\dovi_tool.exe export -i \path\to\RPU.bin -o \path\to\RPU_export.json

You can also use
.\dovi_tool.exe export --help
for more info.

NeverExists
17th August 2022, 00:25
Hi, Quick Question. What do I do if the Web-Dl and the RPU are 8 frames ahead of the Bluray release File? I know there is the rpu delay, but I don't want to delay the RPU. Is there a way to make it work?

GodzilaAvenger
17th August 2022, 03:02
The film and the RPU have to be in sync so the correct lighting is applied to each scene (which is pretty much the whole point of DV), otherwise you get weird flashes and lighting changes. So, I think your options are to either delay the RPU or cut some frames from the beginning of the film. Why don't you want to delay the RPU?

GodzilaAvenger
17th August 2022, 03:13
Normally you can just look at if `scene_refresh_flag` is equal to 1, indicating a scene cut.
There's another script from someone at MakeMKV that can extract the scene cuts, as well.

For anyone interested, I believe this (https://forum.makemkv.com/forum/viewtopic.php?p=123221#p123221) is the script quietvoid was referring to for getting all the scene cuts.

von Suppé
17th August 2022, 10:14
This may come in handy, gonna play around with it. Thanks for the link, GA.

Latest remux of Interstellar plays flawlessly. Being at it, atm I'm figuring out the "remove" function of dovitool.exe.

von Suppé
17th August 2022, 12:20
Dovi_tool's "demux" section at the online readme.me says RPU can be removed from hevc.
So I demuxed a "BL+RPU" hevc stream and the output gives me a BL and EL. The demuxed BL indeed holds no RPU data.

The size of the demuxed EL would suggest it holds the RPU. However, dropping the EL on DDVT_DEMUXER or DDVT_REMOVER both times shows no DV data.

First, I wonder if an extra option needs to be added after demux to properly remove RPU with dovitool.exe. The demux --help didn't provide with relevant info.

Secondly, what's up with this demuxed EL? Is there any use to it?

NeverExists
17th August 2022, 13:29
The film and the RPU have to be in sync so the correct lighting is applied to each scene (which is pretty much the whole point of DV), otherwise you get weird flashes and lighting changes. So, I think your options are to either delay the RPU or cut some frames from the beginning of the film. Why don't you want to delay the RPU?
Cause the RPU is from the film that is longer than the Bluray release. I want to make a hybrid. using the Bluray file's video. So how would delaying the rpu help if it's already too long?

-QfG-
17th August 2022, 16:38
New update coming soon. NEW* TMP Folder and Output Folder can be set. Also i creating a readme file for all functions.

von Suppé
17th August 2022, 17:38
Nice one, -QfG-. Looking forward to it.

Cause the RPU is from the film that is longer than the Bluray release.

With longer, you mean that the two versions are entirely different? Like one is a "theater release" and the other an "extended cut" or something? If so, you can't use the RPU. It's for totally different scenes and timings.


Chances are you have two versions that carry the exact same movie, but one has some extra frames at the end. Like in the same way one already has a few frames added at the beginning. Then you can use the RPU. The injector will see to it that the amount of frames will match at the end.
But you do have to set the delay to sync RPU to target video. If you don't, like GodzilaAvenger said, you'll experience flickering/flashes during the entire video.

Maybe you need to check first if the two versions of the movies are the same before proceeding.

-QfG-
17th August 2022, 18:11
-v0.48
*Updated mkvtoolnix to v 69.0.0.0.
*Add function to set TEMP and OUTPUT folder.
*Multi instances support (only for different releases!)

Many deep changes in the scripts for adding Folder Support. I hope all works bugfree.

NeverExists
17th August 2022, 19:53
Nice one, -QfG-. Looking forward to it.



With longer, you mean that the two versions are entirely different? Like one is a "theater release" and the other an "extended cut" or something? If so, you can't use the RPU. It's for totally different scenes and timings.


Chances are you have two versions that carry the exact same movie, but one has some extra frames at the end. Like in the same way one already has a few frames added at the beginning. Then you can use the RPU. The injector will see to it that the amount of frames will match at the end.
But you do have to set the delay to sync RPU to target video. If you don't, like GodzilaAvenger said, you'll experience flickering/flashes during the entire video.

Maybe you need to check first if the two versions of the movies are the same before proceeding.

I mean The Web download and RPU are 8 frames ahead of the Bluray from the beginning, not the end. That's why I don't understand why I would use a delay for the rpu when it's already ahead of the bluray release by 8 frames.

-QfG-
17th August 2022, 20:31
-v0.48a
*Updated FRAMEINFO Function. If you set Frames to ALL, all frames of
a RPU will be exported. Also a file with all scenecuts will be created.
Automatically formated in readable format.
*Minor Bugfixes.

I mean The Web download and RPU are 8 frames ahead of the Bluray from the beginning, not the end. That's why I don't understand why I would use a delay for the rpu when it's already ahead of the bluray release by 8 frames.

Example:

BluRay Frame 100 identical to RPU Frame 120 -> set Delay "-20"
BluRay Frame 120 identical to RPU Frame 100 -> set Delay "20"

GodzilaAvenger
17th August 2022, 20:36
I mean The Web download and RPU are 8 frames ahead of the Bluray from the beginning, not the end. That's why I don't understand why I would use a delay for the rpu when it's already ahead of the bluray release by 8 frames.

You can also set negative delay. If, for example, frame 8 of the RPU corresponds to frame 0 of BluRay, set a -8 delay, which tells DDVT to remove the first 8 frames of the RPU.

Edit: same as what -QfG- said!

von Suppé
17th August 2022, 22:04
@-QfG-

Thanks for implementing the "all scenecuts" output for DDVT_FRAMEINFO. Very nice.

When DDVT_FRAMEINFO has finished output for a single frame, can you make it return as to be ready to take another framenumber? Unless I'm missing something, now for every single frame the RPU needs to be dropped on the command.

Thanks

GodzilaAvenger
17th August 2022, 22:10
Dovi_tool's "demux" section at the online readme.me says RPU can be removed from hevc.
So I demuxed a "BL+RPU" hevc stream and the output gives me a BL and EL. The demuxed BL indeed holds no RPU data.

The size of the demuxed EL would suggest it holds the RPU. However, dropping the EL on DDVT_DEMUXER or DDVT_REMOVER both times shows no DV data.

First, I wonder if an extra option needs to be added after demux to properly remove RPU with dovitool.exe. The demux --help didn't provide with relevant info.

Secondly, what's up with this demuxed EL? Is there any use to it?

Have you tried the extract-rpu command of dovi_tool?

quietvoid can speak more to this, but my understanding is that for DV Profile 5 (which most streamers use) and Profile 8, the EL is essentially the RPU. For DV Profile 7 (which is used for UHD BluRays), the EL can be either the RPU alone (Minimum Enhancement Layer or MEL) or RPU plus a second 1080p track (Full Enhancement Layer or FEL). On compatible players, a second HEVC decoder is launched to decode the FEL, which when put together with the decoded BL should get very close to the 12-bit DV master of the movie.

The first post of this (https://forum.blu-ray.com/showthread.php?t=276448) topic has some good information, just make sure to click on the 'Show spoiler' links.

quietvoid
17th August 2022, 22:16
The EL file obtained from demuxing a non profile 7 single layer file cannot be reused, as it only contains the RPU with extra bytes.

GodzilaAvenger
18th August 2022, 03:03
-v0.48
*Updated mkvtoolnix to v 69.0.0.0.
*Add function to set TEMP and OUTPUT folder.
*Multi instances support (only for different releases!)

Many deep changes in the scripts for adding Folder Support. I hope all works bugfree.

It seems that in the new version, file paths that have a space in them don't work. When using such a file (e.g. D:\Path to\file location\file) DDVT creates empty folders in its directory (in this example it creates empty folders named "Path", "to", "file" "location", etc.). In previous versions a similar issue would occur if a parenthesis was in the file path.

Also, specifying ALL in FRAMEINFO returns empty .json files (both frame info .json and scene cut .json files are returned empty). The issue seems to be coming from jq, because when I replaced the jq.exe in the tools folder with the jq-win64.exe file I downloaded the issue was resolved.

It would be great if when selecting ALL for FRAMEINFO, information about the video and RPU borders would be displayed as well, much like when inputting "C" on the DEMUXER, with the option to fix the borders.

Also, how do we set the output directory to be the same as the working directory, like it used to be?

NeverExists
18th August 2022, 04:33
You can also set negative delay. If, for example, frame 8 of the RPU corresponds to frame 0 of BluRay, set a -8 delay, which tells DDVT to remove the first 8 frames of the RPU.

Edit: same as what -QfG- said!

Thanks, Guys!

von Suppé
18th August 2022, 08:59
Have you tried the extract-rpu command of dovi_tool?

Yes, I extract RPU with the dovitool command many times. But this leaves the sourcestream untouched and outputs a copy of RPU. My post was about removing RPU from a stream, which is a different thing.

my understanding is that for DV Profile 5 (which most streamers use) and Profile 8, the EL is essentially the RPU.

Well, to be exact, Profiles 5 and 8 don't carry any enhancement layer. They hold RPU and a single layer video.

For DV Profile 7 (which is used for UHD BluRays), the EL can be either the RPU alone (Minimum Enhancement Layer or MEL) or RPU plus a second 1080p track (Full Enhancement Layer or FEL).

I am familiar with MEL and FEL and them carrying RPU on UHDBD. My post was about a single layer "BL+RPU" stream, so without any EL. Which demuxing surprised me because of EL being part of the output.

The EL file obtained from demuxing a non profile 7 single layer file cannot be reused, as it only contains the RPU with extra bytes.

Thanks for making that clear.

specifying ALL in FRAMEINFO returns empty .json files (both frame info .json and scene cut .json files are returned empty). The issue seems to be coming from jq, because when I replaced the jq.exe in the tools folder with the jq-win64.exe file I downloaded the issue was resolved.

Weird. It works here. Is it the Windows version? I'm on Windows 7 (I do have to replace mkvmerge and mkvextract with compatible versions)

GodzilaAvenger
18th August 2022, 09:35
Weird. It works here. Is it the Windows version? I'm on Windows 7 (I do have to replace mkvmerge and mkvextract with compatible versions)

I'm on Windows 11, so maybe?

Edit: seems to be a system architecture thing, the jq coming with DDVT seems to be the 32-bit version, the one I downloaded the 64-bit version. A solution may be to include both and use the appropriate one based on system architecture.

von Suppé
18th August 2022, 09:52
I'm on Windows 11, so maybe?

Edit: seems to be a system architecture thing, the jq coming with DDVT seems to be the 32-bit version, the one I downloaded the 64-bit version.
Well I'm running 64 bit Windows 7...

Is dropping "EL+RPU" on latest DDVT_DEMUXER working on your pc? I get error "No Dolby Vision Profile found".

alexflin
18th August 2022, 13:44
Hi,

I would like to create an iso image to burn into a bluray with the BL.hevc and EL.hevc but it doesn't work, any Idea? Should be because the mkv it has a profile 8?

https://i.ibb.co/c809j7f/image.png (https://ibb.co/C9gyfTC)

alexflin
18th August 2022, 13:46
Well I'm running 64 bit Windows 7...

Is dropping "EL+RPU" on latest DDVT_DEMUXER working on your pc? I get error "No Dolby Vision Profile found".

Try to rename the video without spaces. I had the same error and I fixed it by doing this.

von Suppé
18th August 2022, 15:23
Try to rename the video without spaces. I had the same error and I fixed it by doing this.
Thanks, but the filename is already EL.hevc. Version 47a works. Latest doesn't.

-QfG-
18th August 2022, 16:28
Working on a fix. Coming soon ...

GodzilaAvenger
18th August 2022, 18:02
Well I'm running 64 bit Windows 7...

Is dropping "EL+RPU" on latest DDVT_DEMUXER working on your pc? I get error "No Dolby Vision Profile found".

Thanks, but the filename is already EL.hevc. Version 47a works. Latest doesn't.

Weird...

It seems the whole file path should not have any spaces, not just the file name, so if any upstream folders have a space try changing those and see if that makes a difference.

Working on a fix. Coming soon ...

Thanks!

-QfG-
18th August 2022, 18:12
-v0.48b
*Updated mkvtoolnix to v 70.0.0.0.
*Fixed bugs with spaced names.
*Fixed FRAMEINFO function.

I hope everything works well.

EDIT Reuploaded, because one wrong script was inside.

GodzilaAvenger
19th August 2022, 00:24
I hope everything works well.

EDIT Reuploaded, because one wrong script was inside.

It all works now, thanks!

von Suppé
19th August 2022, 08:51
Thanks for the fix, -QfG-

Try to rename the video without spaces. I had the same error and I fixed it by doing this.
I didn't realise you meant the whole path without spaces. You were bang on.

NeverExists
20th August 2022, 00:43
Don't know if this is the right place to ask but I was wondering if anyone knew of a tool I could use to convert already owned 4k Dolby Vision Movies From my iTunes account to something I can use with this tool? I have some movies I've bought on my iTunes account that I would like to make a higher-quality hybrid with. Sorry if this is the wrong place

GodzilaAvenger
20th August 2022, 18:00
I'm a bit out of my depth here but I think you should look up M4V converters.

von Suppé
21st August 2022, 10:41
I don't have any experience with iTunes products, M4V container and its possible contents.
I read they can be copy-protected. So I wonder if you wouldn't in the first place need a decryper?

GodzilaAvenger
24th August 2022, 07:18
It seems the HDR10+ injector tool doesn't work, saying it cannot find the input file after extracting the video layer from the mkv. Probably some bug with the new temp and output folder structure.

von Suppé
24th August 2022, 09:07
Thanks for the headsup, GA. I have a similar issue for DDVT_REMOVER.

Having checked for both HDR10+ and RPU, I get same error:

<
== COPYING ====================================

Please wait. Copy Stream to Temp folder...
The system cannot find the path specified.
Error.
>

GodzilaAvenger
24th August 2022, 18:00
For the time being my workaround is to grab the temp.hevc file and work with that.

-QfG-
25th August 2022, 19:46
-v0.48c
*REMOVER - Fixed Bug with wrong temp directory.
*INJECTOR - Fixed Bug with HDR10+ Injection.
*INJECTOR - Support for DV Profile 5 Video Streams.
*Updated hdr10plus_tool to v1.3.2.
*Updated dovi_tool to v1.5.6.

von Suppé
26th August 2022, 08:31
Injector and remover work again. Tested with no temp folder set.

Thanks for fixing :-)

DiscoD
26th August 2022, 22:11
Long Time user of the tool but i just wanted to make sure i am using and understanding the crop feature correctly...
i have always extracted and injected my RPU untouched from the source because i never cropped them i just left the black bars included while encoding.
more recently i have started to crop the encodes but i think i may be a bit confused on the crop/borders function.

in the picture included i cropped the encode and its my understanding(this is where i may be wrong) that cropping the rpu is just changing the Active area L5,Well obviously when i crop the video the TV will still have black bars since the video resolution is 3840x1600...
So the active area of the RPU should still be cropped to 280px on top and bottom to match the active area of the actual video file...

but when i extracted my RPU i cropped it since i was cropping the video as well and DDVT says its correct but i believe i may be confused

https://i.ibb.co/5hp7PNQ/rightorwrong.png (https://ibb.co/5hp7PNQ)

Just want to make sure im understanding and using this correctly,
Thanks!

-QfG-
26th August 2022, 23:08
If you crop your video you have letterbars on the TV, right (if you not change the Aspect Ratio). But the letterbars you see on your tv are not active pixels, that are "dead pixel".
Your TV will playback the video in the resolution 3840x1600 and set this in the middle of the display.
For cropped encodes with no black borders included, you must set the active area to 0,0,0,0.

DiscoD
27th August 2022, 00:20
If you crop your video you have letterbars on the TV, right (if you not change the Aspect Ratio). But the letterbars you see on your tv are not active pixels, that are "dead pixel".
Your TV will playback the video in the resolution 3840x1600 and set this in the middle of the display.
For cropped encodes with no black borders included, you must set the active area to 0,0,0,0.

I understand now thank you,
since the black bars on a cropped encode are seen essentially as inactive pixels, the RPU must match the active pixels on screen..

Keep up the great work!!!

speedy
28th August 2022, 18:13
I'm trying to create DoVi files that are compatible with Apple TV which means I need to use either Profile 5 or 8.4.
I want to use Profile 8.4 though so I can retain backwards compatibility with non-DoVi HDR displays.
I tried to convert a Profile 7 MEL file to DoVi Profile 8.4 using DDVT Tool but Infuse on Apple TV didn't detect it as DoVi and just played it back as HDR10.
Does anyone know how I can reliably convert both Profile 7 and 8.1 DoVi files to Profile 8.4 for Apple TV compatibility?
Thank you!

DiscoD
28th August 2022, 19:36
I'm trying to create DoVi files that are compatible with Apple TV which means I need to use either Profile 5 or 8.4.
I want to use Profile 8.4 though so I can retain backwards compatibility with non-DoVi HDR displays.
I tried to convert a Profile 7 MEL file to DoVi Profile 8.4 using DDVT Tool but Infuse on Apple TV didn't detect it as DoVi and just played it back as HDR10.
Does anyone know how I can reliably convert both Profile 7 and 8.1 DoVi files to Profile 8.4 for Apple TV compatibility?
Thank you!

I'm not sure of the process surrounding 8.4 but here is a good list put together about playback device compatibility...
https://docs.google.com/spreadsheets/d/1jBIGF8XTVi9VmDBZ8a5hEyongYMCDlUiLHU9n1f_S74/edit#gid=427220017
maybe 8.4 is working for people more recently if but this list is updated pretty often.

-QfG-
28th August 2022, 21:18
The RPU is not Profile 8.1,8.2 or 8.4 the RPU is every times Profile 8. If you mux the RPU now in:

HDR Stream you have Profile 8.1
SDR Stream you have Profile 8.2
HLG Stream you have Profile 8.4

So you need an HLG Base layer and mux the Profile 8 RPU in it. I think this works.

Profile 5 is another thing, you have the IPT (IPTPQc2 (https://en.wikipedia.org/wiki/ICtCp#IPTPQc2)) colorspace not the BT.2020 there.
Therefore, no fallback to HDR with Profile 5, because no BT.2020 colorspace are used.

AgentXXL
28th August 2022, 22:49
Some releases have a RPU with l6 metadata over 10.000. The tool will not mux them, because 10.000 is the max value there. If you have this problem simply set L6 Metadata to the same values how the HDR stream have.

I've been having great success with the scripts - so far I've saved about 4TB of space making hybrid DV-HDR versions instead of having to keep a copy of each.

I do have an issue with a couple of releases - the Demuxer script and dovi_tool itself complain with this message:

`self.max_display_mastering_luminance <= MAX_PQ_LUMINANCE`

It then exits the script with a zero byte RPU.bin. I see the mention of matching L6 metadata but I can't get that far as I have no RPU.bin to use with Injector.

I've done some searching online but my Google-fu is failing me. Is there a workaround/fix for DV files that have this issue?

And once again: thank you QfG, quietvoid and many others for your efforts! Truly impressive to see what this helpful community offers.

GodzilaAvenger
28th August 2022, 23:10
Profile 5 is another thing, you have the IPT (IPTPQc2 (https://en.wikipedia.org/wiki/ICtCp#IPTPQc2)) colorspace not the BT.2020 there.
Therefore, no fallback to HDR with Profile 5, because no BT.2020 colorspace are used.

Interesting... I once injected a Profile 5 RPU into an HDR BL and the result showed up as "Dolby Vision / HDR10" in MediaInfo, and played back as HDR on my TVs internal player (which doesn't support DV). Does this mean it won't trigger DV on a compatible player?

-QfG-
29th August 2022, 01:50
Maybe DV will be triggered with a HDR BL and a P5 RPU, but i'm sure you have some display errors on screen. I can test this in the next time :)

I've done some searching online but my Google-fu is failing me. Is there a workaround/fix for DV files that have this issue?

Yes there is, but I never wanted to make this script public.
I called this L6 Demuxer and can extract these RPUs. I post the script here, just create a cmd, save the content there and use this script just like the others.

@echo off & setlocal
mode con cols=122 lines=57
TITLE DDVT L6DEMUXER [DonaldFaQ] v0.48b beta

set RAW_FILE=FALSE
SET MaxDML=1000
SET MinDML=1
SET MaxCLL=0
SET MaxFall=0
set "sfkpath=%~dp0tools\sfk.exe" rem Path to sfk.exe
set "FFMPEGpath=%~dp0tools\ffmpeg.exe" rem Path to ffmpeg.exe
set "MKVEXTRACTpath=%~dp0tools\mkvextract.exe" rem Path to mkvextract.exe
set "MKVMERGEpath=%~dp0tools\mkvmerge.exe" rem Path to mkvmerge.exe
set "MP4BOXpath=%~dp0tools\mp4box.exe" rem Path to mp4box.exe
set "MP4FPSMODpath=%~dp0tools\mp4fpsmod.exe" rem Path to mp4fpsmod.exe
set "MEDIAINFOpath=%~dp0tools\mediainfo.exe" rem Path to mediainfo.exe
set "DO_VI_TOOLpath=%~dp0tools\dovi_tool.exe" rem Path to dovi_tool.exe
set "HDR10P_TOOLpath=%~dp0tools\hdr10plus_tool.exe" rem Path to hdr10plus_tool.exe

rem --- Hardcoded settings. Cannot be changed ---
set "TMP_FOLDER=SAME AS SOURCE\%~n1_[TEMP]"
set "TARGET_FOLDER=SAME AS SOURCE\%~n1_[L6 DEMUXED]"
set HDR=No HDR Infos found
set DV=FALSE
set HDR10P=FALSE
set REMHDR10PString=
set EXTSTRING=
set RESOLUTION=n.a.
set HDR=n.a.
set CODEC_NAME=n.a.
set FRAMERATE=n.a.
set FRAMES=n.a.
set INPUTFILENAME=%~nx1
set RAW_FILE=FALSE
set WAIT="%sfkpath%" sleep
set GREEN="%sfkpath%" color green
set RED="%sfkpath%" color red
set YELLOW="%sfkpath%" color yellow
set WHITE="%sfkpath%" color white
set CYAN="%sfkpath%" color cyan
set MAGENTA="%sfkpath%" color magenta
set GREY="%sfkpath%" color grey
set ERRORCOUNT=0

::Check for INI and Load Settings
setlocal EnableDelayedExpansion
IF EXIST "%~dp0DDVT_OPTIONS.ini" (
FOR /F "delims=" %%A IN ('findstr /C:"TEMP Folder=" "%~dp0DDVT_OPTIONS.ini"') DO (
set "TMP_FOLDER=%%A"
set "TMP_FOLDER=!TMP_FOLDER:~12!\%~n1_[TEMP]"
)
FOR /F "delims=" %%A IN ('findstr /C:"TARGET Folder=" "%~dp0DDVT_OPTIONS.ini"') DO (
set "TARGET_FOLDER=%%A"
set "TARGET_FOLDER=!TARGET_FOLDER:~14!\%~n1_[L6 DEMUXED]"
)
)
setlocal DisableDelayedExpansion
if "%TMP_FOLDER%"=="SAME AS SOURCE\%~n1_[TEMP]" set "TMP_FOLDER=%~dpn1_[TEMP]"
if "%TARGET_FOLDER%"=="SAME AS SOURCE\%~n1_[L6 DEMUXED]" set "TARGET_FOLDER=%~dpn1_[L6 DEMUXED]"

%GREEN%
echo powered by quietvoids tools Copyright (c) 2021 DonaldFaQ
echo.
%WHITE%
echo ====================================
%GREEN%
echo Dolby Vision Tool L6 DEMUXER
%WHITE%
echo ====================================
echo.
%WHITE%
echo.
echo.
echo == CHECK INPUT FILE ====================================================================================================

if "%~1"=="" (
%yellow%
echo.
echo No Input File. Use DDVT_DEMUXER.cmd "YourFilename.hevc/h265/mkv/mp4"
goto EXIT
)

if /i "%~x1"==".hevc" set "RAW_FILE=TRUE" & goto CHECK
if /i "%~x1"==".h265" set "RAW_FILE=TRUE" & goto CHECK
if /i "%~x1"==".mkv" set "MKVExtract=TRUE" & goto CHECK
if /i "%~x1"==".mp4" set "MP4Extract=TRUE" & goto CHECK

%yellow%
echo.
echo File not Supported^! Only HEVC^/h265^/MP4^/MKV files supported.
goto EXIT

:CHECK
set "VIDEOSTREAM=%~1"
if not exist "%TMP_FOLDER%" MD "%TMP_FOLDER%">nul
if not exist "%TARGET_FOLDER%" MD "%TARGET_FOLDER%">nul
if "%RAW_FILE%"=="TRUE" "%MKVMERGEpath%" --priority higher --output ^"%TEMP%\Info.mkv^" --language 0:und --compression 0:none ^"^(^" ^"%~1^" ^"^)^" --split parts:00:00:00-00:00:01 -q
"%MEDIAINFOpath%" --output=Video;%%Width%%x%%Height%% %1>"%TEMP%\Info.txt"
set /p RESOLUTION=<"%TEMP%\Info.txt"
if "%RESOLUTION%"=="3840x21601920x1080" set "RESOLUTION=3840x2160 DL"
if "%RAW_FILE%"=="TRUE" (
pushd %tmp%
"%MEDIAINFOpath%" --output=Video;%%HDR_Format/String%% Info.mkv>"%TEMP%\Info.txt"
popd
) else (
"%MEDIAINFOpath%" --output=Video;%%HDR_Format/String%% %1>"%TEMP%\Info.txt"
)
set /p HDR=<"%TEMP%\Info.txt"
"%MEDIAINFOpath%" --output=Video;%%Format%%^-%%BitDepth%%Bit^-%%ColorSpace%%^-%%ChromaSubsampling%% %1>"%TEMP%\Info.txt"
set /p CODEC_NAME=<"%TEMP%\Info.txt"
if "%CODEC_NAME%"=="HEVC-10Bit-YUV-4:2:0HEVC-10Bit-YUV-4:2:0" set "CODEC_NAME=HEVC-10Bit-YUV-4:2:0"
"%MEDIAINFOpath%" --output=Video;%%FrameRate%% %1>"%TEMP%\Info.txt"
set /p FRAMERATE=<"%TEMP%\Info.txt"
if "%FRAMERATE%"=="23.97623.976" set "FRAMERATE=23.976"
if "%FRAMERATE%"=="24.00024.000" set "FRAMERATE=24.000"
"%MEDIAINFOpath%" --output=Video;%%FrameCount%% %1>"%TEMP%\Info.txt"
set /p FRAMES=<"%TEMP%\Info.txt"
if exist "%TEMP%\Info.txt" del "%TEMP%\Info.txt">nul
if exist "%TEMP%\Info.mkv" del "%TEMP%\Info.mkv">nul

:START
cls
%GREEN%
echo powered by quietvoids tools Copyright (c) 2021 DonaldFaQ
echo.
%WHITE%
echo ====================================
%GREEN%
echo Dolby Vision Tool L6 DEMUXER
%WHITE%
echo ====================================
echo.
echo.
echo == VIDEO INPUT =========================================================================================================
echo.
%CYAN%
echo Filename = [%INPUTFILENAME%]
echo Video Info = [Resolution = %RESOLUTION%] [Codec = %CODEC_NAME%] [Frames = %FRAMES%] [FPS = %FRAMERATE%]
echo HDR Info = [%HDR%]
echo.

if "%RAW_FILE%"=="FALSE" (
echo.
%WHITE%
echo == DEMUXING ============================================================================================================
echo.
%YELLOW%
echo ATTENTION^! You need many HDD Space for this operation.
echo.
%CYAN%
echo Please wait. Extracting the Video Layer ...
if "%MKVExtract%"=="TRUE" "%MKVEXTRACTpath%" "%~1" tracks 0:"%TMP_FOLDER%\TEMP.hevc"
if "%MP4Extract%"=="TRUE" "%MP4BOXpath%" -raw 1 -out "%TMP_FOLDER%\TEMP.hevc" "%~1"
set "VIDEOSTREAM=%TMP_FOLDER%\TEMP.hevc"
if "%ERRORLEVEL%"=="0" (
%GREEN%
echo Done.
echo.
) else (
%RED%
echo Error.
set "ERRORCOUNT=1"
echo.
)
)

%CYAN%
echo Please wait. Prefetching DV Metadata...
echo {>"%TEMP%\Extra.json"
echo "level6": {>>"%TEMP%\Extra.json"
echo "max_display_mastering_luminance": %MaxDML%,>>"%TEMP%\Extra.json"
echo "min_display_mastering_luminance": %MinDML%,>>"%TEMP%\Extra.json"
echo "max_content_light_level": %MaxCLL%,>>"%TEMP%\Extra.json"
echo "max_frame_average_light_level": %MaxFall% >>"%TEMP%\Extra.json"
echo }>>"%TEMP%\Extra.json"
echo }>>"%TEMP%\Extra.json"

"%DO_VI_TOOLpath%" --edit-config "%TEMP%\Extra.json" convert "%VIDEOSTREAM%" -o "%TMP_FOLDER%\TEMP_L6.hevc"
"%DO_VI_TOOLpath%" -m 2 extract-rpu "%TMP_FOLDER%\TEMP_L6.hevc" -o "%TARGET_FOLDER%\RPU.bin"

echo.
echo Please wait. Cleaning and Moving files ...
if exist "%TMP_FOLDER%" (
RD /S /Q "%TMP_FOLDER%">nul
if "%ERRORLEVEL%"=="0" (
%GREEN%
echo Deleting Temp Folder - Done.
) else (
%RED%
echo Deleting Temp Folder - Error.
set "ERRORCOUNT=1"
echo.
)
)

:EXIT
%WHITE%
echo.
echo == EXIT ================================================================================================================
echo.
TIMEOUT 30
exit

It is recommended to mux this RPU with L6 Function in INJECTOR.

GodzilaAvenger
29th August 2022, 02:54
Maybe DV will be triggered with a HDR BL and a P5 RPU, but i'm sure you have some display errors on screen. I can test this in the next time :)

You can use this file (https://drive.google.com/file/d/1Dop-5nwyXUHfCjPMtf5r-IbpHbTwVf11/view?usp=sharing) I've made for your test.