quietvoid / dovi_tool

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

Incorrect number of frames in RPU when extracting. #170

Closed Gronis closed 1 year ago

Gronis commented 2 years ago

I'm trying to extract dovi data from "source hevc" stream into "target hevc". The problem is that when extracting the RPU from "source hevc", the frame count of the RPU is incorrect. This hevc stream has 309848 frames, but the dovi RPU (when inspected with dovi_tool info) has only 71406 frames. When injecting the RPU into the "target hevc" stream, the last dovi frame (71406) repeats itself so that an RPU extracted from this stream has 309848 frames, with frames 71406-309848 contains the same dovi data repeated over and over.

I guess that the source hevc stream does not have dovi data on every frame and the information of where each frame should be is lost in the process.

How do I export/inject so that the dovi information is injected on the right frames?

quietvoid commented 2 years ago

It's not supported. Every frame is expected to carry metadata. There might be a bug otherwise, but it's not possible to know without analyzing the video file.

The more likely situation is that the file has invalid metadata to begin with.

Gronis commented 1 year ago

Hmm, ok.

I'll take a more close look into the codebase to try to debug what is going on. Hopefully the metadata is not invalid.

quietvoid commented 1 year ago

You could provide more info on this "source.hevc" file. How was it created? Where is it from? What title?

Gronis commented 1 year ago

It's a 4K version of watchmen with dolby vision from MakeMKV. This is the output of mediainfo. The hevc stream is extracted using ffmpeg like your examples.

General
Complete name                            : Movies/Watchmen.2009.2160p.DV.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 75.1 GiB
Duration                                 : 3 h 35 min
Overall bit rate mode                    : Variable
Overall bit rate                         : 49.9 Mb/s
Encoded date                             : UTC 2022-07-06 19:22:14
Writing application                      : MakeMKV v1.15.3 win(x64-release)
Writing library                          : libmakemkv v1.15.3 (1.3.10/1.5.2) win(x64-release)

Video
ID                                       : 1
ID in the original source medium         : 4113 (0x1011)
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5.1@High
HDR format                               : Dolby Vision, Version 1.0, dvhe.07.06, BL+EL+RPU, Blu-ray compatible / SMPTE ST 2086, HDR10 compatible
Codec ID                                 : V_MPEGH/ISO/HEVC
Duration                                 : 3 h 35 min
Bit rate                                 : 45.1 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0 (Type 2)
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.227
Stream size                              : 67.8 GiB (90%)
Language                                 : English
Default                                  : No
Forced                                   : No
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
Original source medium                   : Blu-ray
quietvoid commented 1 year ago

It's definitely missing data. You might have hit https://forum.makemkv.com/forum/viewtopic.php?f=12&t=23962 The video bitrate should average 48.9 Mb/s.

So the file is invalid. You should try remuxing with a more recent MakeMKV version. Or if the UHD BD folder you used isn't the original, then it's the bug.

Nothing to fix in dovi_tool.

Gronis commented 1 year ago

Thanks for the help!