quietvoid / dovi_tool

dovi_tool is a CLI tool combining multiple utilities for working with Dolby Vision.
MIT License
623 stars 59 forks source link

Error parsing frame & Error number of valid RPUs different from total #87

Closed manuelrn closed 2 years ago

manuelrn commented 2 years ago

Hi!

With the latest version (1.4.1), I get this error (with 'The Power of the Dog' 4K DV from Netflix, if you need I can share the RPU):

Parsing RPU file...
Error parsing frame 183402: CM v2.9: dm_alignment_zero_bit != 0
Error: Number of valid RPUs different from total: expected 185341 got 183402

If I extract the RPU intact, I can use the info command without getting an error. But if I convert it with mode 3 (this process is done without errors), the info command gives me that error. And if I try to use the inject-rpu command with this RPU converted with mode 3, the same error also occurs.

It makes me think that the problem must be after the film is finished, specifically in the dubbing credits. Maybe during that part DV metadata is incomplete or the metadata there is fake, or something like that, I don't know.

I think about it for this reason: When converting the RPU with mode 3, the process indicates that the RPU contains 185341 frames:

EditConfig {
    mode: 3,
    convert_to_cmv4: false,
    remove_mapping: false,
    active_area: None,
    remove: None,
    duplicate: None,
    min_pq: None,
    max_pq: None,
    level6: None,
    level11: None,
}
Parsing RPU file...
Converting with mode 3...
Final metadata length: 185341
Writing RPU file...

But if I try to see the information of that last frame with the info command, the process indicates that there are only 183402 valid frames:

Parsing RPU file...
Error parsing frame 183402: CM v2.9: dm_alignment_zero_bit != 0
Error: Number of valid RPUs different from total: expected 185341 got 183402



I have tried to see the information of those frames with the info command (from RPU intact, as the info command fails with RPU converted with mode 3), and I have observed that up to frame 183401 (included) contains the cmv29_metadata block, but from frame 183402 (included) to the end the cmv29_metadata block does not exist.

So I thought to remove those last frames that don't contain the cmv29_metadata block, I have tried to edit the RPU with this json:

{
    "mode": 3,
    "remove": [
        "183402-185340"
    ]
}

And it seems that now everything is correct. In this RPU converted with mode 3 I can now use the info command without errors.

Although I have already managed to solve it this way, I open this Issue to see if a simpler way to solve these types of cases could be implemented. For example, I have thought that the inject-rpu command might be able to check if all the frames contained in the HEVC file are valid in the RPU file, instead of simply giving an error. This way you avoid editing the RPU (just in case none of the HEVC frames is an invalid frame in the RPU).

Thanks and regards!

quietvoid commented 2 years ago

So in the refactor, I made it ignore DM metadata if there were no blocks. However it seems DM metadata v1 is expected to always be present, regardless of the number of blocks.

manuelrn commented 2 years ago

So in the refactor, I made it ignore DM metadata if there were no blocks. However it seems DM metadata v1 is expected to always be present, regardless of the number of blocks.

So if I understood correctly, in those cases the cmv29_metadata block will now be written empty (simply so that it always exists)?

Thanks again!

quietvoid commented 2 years ago

Yes, as it should.

manuelrn commented 2 years ago

Okay, thanks again.