fix(video): validate pass-through fixed GOP cadence - #380
Conversation
kstonekuan
left a comment
There was a problem hiding this comment.
Holding this rather than merging it, and the reason is about #376 rather than about your code. The work is sound: gate is clean on the merged result, 1451 passed / 6 skipped, and the cadence derivation from gop_seconds and each channel's measured frame rate is the right way to compute the grid.
#376 is deliberately open on what to do, not just how. It names three options: refuse off-grid pass-through, measure and stamp the real interval, or report it as a doctor finding and leave refusal to callers. This PR implements the first and the third. Merging it would settle that choice by landing it, and the first option is the one with the largest blast radius, so it is the one I asked not to be decided by default.
Timing was against you here. The issue's author posted a measurement 36 minutes after you opened this, and it speaks directly to the refusal half. Scanning nominal-io/xplane-mcap (the 24,689-message corpus src/hflow/video.py:513 records this repo's lossless-suffix guarantee as validated on):
video messages scanned: 24689
messages WITHOUT an AUD: 24689
keyframe-bearing (IDR): 103 (agrees with the corpus's own video/keyframes channel)
keyframe spacing: nominal 250, holds for 93 of 102 intervals
off-grid intervals: 9, tightest at 39 messages
That source needs AUD repair to conform, repair cannot move keyframes, and so it is a conforming pass-through stream with an irregular grid. Your _validate_passthrough_video_payload change would refuse it. Refusing a recording this repository used to validate a shipped code path is a real cost, and it is not one anybody had measured when you started.
None of that is wasted. Whichever direction #376 lands on, something has to measure cadence from the access units, and your derivation plus the video-keyframe-cadence finding are the parts most likely to survive intact: a doctor finding is wanted under all three options. The piece that is genuinely contingent is the SourceNotConforming raise in the transform.
So: leaving this open rather than closing it, and no changes to push yet. When #376 names a direction I will say so here, and if it is anything other than "refuse", the reshape is smaller than rewriting.
One thing worth doing regardless, if you want to keep moving on it: _validate_passthrough_video_payload returning bool for the keyframe flag makes a validation function carry a second job in its return type. A separate accessor, or collecting the flag where the access unit is already in hand, keeps the validator's contract "raises or does not". That is a comment on the code and it holds whichever way the design goes.
|
#376 now has a direction, so here is where this stands. The refusal comes out. The Your doctor half stays. What is new work: the provenance record stops copying the configured interval on the pass-through path and reports the stream instead. The rule is that it reports the measurement, or reports that there is not one; a stream with spacing 7, 1, 82, 1 has no single interval and the record must not invent one. The encoding is your call, with a note in the PR saying which and why. The re-encode path does not change. Two things to plan for. If you would rather not carry the provenance half, say so and land the doctor finding and the cadence derivation on their own. That is a clean, useful PR by itself and the record change can follow separately. Either way this is not starting over. Also still worth doing whichever shape you pick: |
Summary
gop_secondsand each channel's measured frame rate before provenance is written.video-keyframe-cadencedoctor error while preserving existing malformed-payload and stream-start diagnostics.Fixes #376
Why
Pass-through episodes previously stamped
gop_secondsas the interval actually used without verifying that their H.264 keyframes followed that cadence. Refusing off-grid pass-through streams and checking existing files inhflow doctormakes that provenance assertion verifiable without changing the provenance schema or re-encode behavior.Validation
Focused and full test suites passed, and lint, formatting, type checking, documentation links, and diff whitespace checks are clean.
Checklist
uv run ruff check --fix,uv run ruff format, anduv run ty check.