fix(vaults): lengthen the whole-file key check and steady its HEVC test

Wrong-key HEVC noise can decode clean for seconds in small frames, so the tail check now decodes 8 s. The test clips are 640x360 with a fixed IV.
This commit is contained in:
imSp4rky
2026-10-13 17:32:29 -06:00
parent b4e686df86
commit 6b04d7b137
4 changed files with 38 additions and 24 deletions
+2 -2
View File
@@ -240,8 +240,8 @@ def pick_windows(spans: list[tuple[float, float]], longest: float = 4.0) -> list
A window starts at a fragment and runs on through the next fragments of the same KID, up
to ``longest`` seconds, but never into a fragment of another KID or a clear one. A short
window can decode noise without an error: the decoder often needs several frames to find it.
A wrong key fails on the first inter frame in every measured case, so ``longest`` buys
decoder frames, not certainty; every second of it is decoded in full for a right key.
``longest`` buys decoder frames, not certainty; every second of it is decoded in full for
a right key.
The last window ends where the KID's last run of fragments ends.
"""
spans = sorted(span for span in spans if span[1] > span[0]) # a duplicated tfdt gives an empty span
+9 -5
View File
@@ -56,6 +56,7 @@ FFMPEG_MISSING_REFERENCE = (
"could not find ref with poc",
)
FFMPEG_CHECK_TIMEOUT = 120
FFMPEG_CHECK_TAIL = 8 # seconds
def ffmpeg_decodes(path: Path, start: Optional[float] = None, seconds: float = 3, video: Optional[bool] = None) -> bool:
@@ -66,13 +67,15 @@ def ffmpeg_decodes(path: Path, start: Optional[float] = None, seconds: float = 3
With ``start``, the check decodes ``seconds`` from that time. An FFmpeg copy cuts the
window first, so no sample after the window gets to the decoder. Without ``start``, the
check decodes the first seconds and the last 4 seconds, because a title can open with
check decodes the first seconds and the last seconds, because a title can open with
a clear or separately keyed lead.
Every frame is decoded, because an HEVC keyframe decrypted with a wrong key can decode
without an error. When a window starts inside a GOP and the only error is a missing
reference frame, the check decodes the keyframes of that window again and uses that
verdict. ``video=False`` skips that second pass.
without an error. A pass is not proof: HEVC noise can decode clean for seconds, most
often in small frames, so a longer window finds more wrong keys. When a window starts
inside a GOP and the only error is a missing reference frame, the check decodes the
keyframes of that window again and uses that verdict. ``video=False`` skips that second
pass.
A file this FFmpeg build cannot judge counts as a pass, never as a wrong key, and so
does a check that does not finish in time.
@@ -130,9 +133,10 @@ def ffmpeg_decodes(path: Path, start: Optional[float] = None, seconds: float = 3
return decode(window, keyframes=True)
return False
tail = ["-sseof", f"-{FFMPEG_CHECK_TAIL}", "-t", str(FFMPEG_CHECK_TAIL)]
if start is not None:
return decode(["-ss", f"{start:.6f}", "-t", f"{max(seconds - 0.5, seconds / 2):.6f}"], keyframes=False)
return decode(["-t", str(seconds)], keyframes=False) and decode(["-sseof", "-4", "-t", "4"], keyframes=False)
return decode(["-t", str(seconds)], keyframes=False) and decode(tail, keyframes=False)
def ffprobe(uri: Union[bytes, Path]) -> dict: