quietvoid/hdr10plus_tool

issue with number of frame

Closed this issue · 8 comments

First of all, thanks a lot for your tools !!

i try to apply a HDR+ metadata from a movie to the same movie but with different compression level.

when extracting metadata HDR10+ from a movie, i obtain a metadata.json
after that try to inject this metadata.json to the same movie with same number of frame but hdr10plus_tool says :
"Generated metadata for 5735 frames"
but the movie contains 173802 frames

so when try to inject to the same movie but with lower compression but same number of frame (and constant) hdr10plus_tool says :
"Warning: mismatched lengths. video 173802, RPU 5735
Metadata will be duplicated at the end to match video length"

i have the same issue with all movie i tested (using json to inject, or converting to RPU before)
is there something to do specifically in this objective ?

my script to test it:

set ffmpeg=ffmpeg.exe
set videoWithHDR=myMovieSourceWithHDR10Plus.mkv
set videoToAddHDR=myMovieTargetWithoutHDR10Plus.mkv
set hdr10plusTool=hdr10plus_tool.exe
set doviTool=dovi_tool.exe
set rpu=%videoWithHDR%.rpu.bin
set json=%videoWithHDR%.metadata.json
set videoOut=%videoToAddHDR%.withHDR.hevc
set videoInHEVC=%videoWithHDR%.hevc

if not exist "%json%" %ffmpeg% -loglevel panic -hide_banner -i "%videoWithHDR%" -map 0:v:0 -c copy -vbsf hevc_mp4toannexb -f hevc - | %hdr10plusTool% extract - -o "%json%"

Reading parsed dynamic metadata... Done.
Reordering metadata... Done.
Generating and writing metadata to JSON file... Done.

if not exist "%rpu%" %doviTool% generate -j default_cmv40.json --hdr10plus-json "%json%" -o "%rpu%"

Parsing HDR10+ JSON file...
Generating metadata...
Generated metadata for 5735 frames
Done.

if not exist "%videoToAddHDR%.hevc" %ffmpeg% -loglevel panic -hide_banner -i "%videoToAddHDR%" -map 0:v:0 -c copy -vbsf hevc_mp4toannexb -f hevc "%videoToAddHDR%.hevc"
if not exist "%videoOut%" %doviTool% inject-rpu -i "%videoToAddHDR%.hevc" --rpu-in "%rpu%" -o "%videoOut%"

Parsing RPU file...
Processing input video for frame order info...

Warning: mismatched lengths. video 173802, RPU 5735
Metadata will be duplicated at the end to match video length

Computing frame indices..
Rewriting file with interleaved RPU NALs..

Clearly the video you're extracting the metadata from doesn't have metadata for every frame.
hdr10plus_tool does not duplicate metadata, it expects every frame to have metadata.

You have not mentioned what the source of the metadata is. To me it sounds like a reencoded file, so it's unsupported.

Ho ok ! you're right, it's a reencoded video !
So i understand.
thanks !

hi @quietvoid sorry to bump it up do you plan to implement duplicating function ?
since now it will duplicate only last frame metadata for the rest of the video, i'm guessing it will cause the whole thing be invalid as the frame metadata is probably per scene not per frame - which to my brain means the begining video will have invalid metadata for not the destined frames, and then at somepoint the metadata will be used for the rest of the movie

so i think it would be good to either duplicate frame until next one is present or totally fail the conversion or at least have a switch that would not allow for such conversion of not valid source, because i think that duplicating at end is pointless

I ask becasue all of Amazon releases are reencoded and even though i have subscription i have only DV capable display

No, I don't.
Pull requests welcome.

unfortunately i suck at rust and you do not accept donations :/
I'm guessing its better to watch in plain HDR rather than such messed up metadata right ?

You said Amazon releases are problematic, but that's not true.
They all have metadata for every frame.

Find better releases.

yeah bad luck i had 5 releases first 2 were broken next are good, will have to come up with some detector to stop conversion if encounter such metadata discrepancy thanks

x265 encoded files with --dhdr10-opt are now supported.