Repository navigation
feat(spec)!: bind clip timing with media.timing - #73
Merged
Merged
Conversation
A clip's timing was bound by nothing: content_hash covers NAL units and
audio frame bytes, media.presentation how a player is told to show them,
and a re-mux that kept every sample could freeze a frame (stts), reorder
frames in a GOP (ctts), rescale both tracks in sync (mdhd), trim inside a
located segment (elst) or declare another audio sample rate (esds) and
still read verified clip.
Implements reviews/design-clip-timing.md, accepted 4 October 2026:
- §5 Timing: timing(n), a fixed-width record of each segment's video
DTS deltas, composition offsets, end (last DTS + duration) and the
audio frames §5 assigns to it, in each track's own mdhd timescale.
segments[].timing = SHA-256(timing(n)); media.timing = { video_timescale,
audio_timescale (absent without audio), root } is a required core field.
The 96-byte segment message is unchanged: no segment is re-signed.
- Verifier: root recomputed from complete entries (mismatch: tampered);
on a clip each located segment's record is read back and converted
exactly into the signed timescales; a differing record, an entry set the
root cannot authenticate, or a media edit trimming a located segment is
frames not compared with the new label "timing differs"; on an original
it is the writer's false claim, authentic capped amber.
- The audio sample entry's esds joins media.presentation.config.
- tools/src/timing.ts is the reference record, written to be ported.
Corpus 7.0.0 (187 vectors): every rebuildable video vector re-signed or
re-minted with the field, no existing verdict moved; device captures 36,
37, 48, 85 keep their bytes; 175-187 are new.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes clip timing binding normative (design
reviews/design-clip-timing.md, accepted 4 October 2026). Before: a re-mux keeping every sample could freeze a frame (stts), reorder frames in a GOP (ctts), rescale both tracks (mdhd), trim a located segment (elst) or change the audio sample rate (esds), and the clip still read verified clip.timing(n);segments[].timing = SHA-256(timing(n)); core fieldmedia.timingrequired whereversegmentsis (absent → no proof found). The segment message does not change, so no segment is re-signed.esdsjoinsXinconfig.tools/src/timing.ts: reference record, hash, root, conversion and edit rule, written to be ported.container.tsreadsctts, the media edit andesds.remux.tscan rescale, retime and writectts.Record and core field
stts.ctts(v0 unsigned, v1 signed), 0 without one.sttsduration. Never taken frommdhd.sttsduration.mdhdtimescale.media.timing = { video_timescale: uint32≥1, audio_timescale?: uint32≥1 (absent, never null/0, without a soun track), root: b64url SHA-256(T(0)‖…‖T(count−1)) }.segments[n].timingis base64url of 32 bytes and is required on every entry.Verifier algorithm
media.timingmissing or malformed, or any entry withouttiming→ no proof found.media.hash≠, GOPs located, presentation OK):timing(n)from the file and convert each value witht × ts_signed / ts_received. A non-integer result, missing audio timescale or overflow → differs. Hash the converted record and compare it with the entry.m > sor(d+1)·T ≤ (e−m)·M. The span is min/max of dts+cts(+dur) for video, and first adts to last adts+adur for audio.timing differs,segments.verified=[].media.hashmatches): build the records of all segments from the file and convert them. A root mismatch → authentic +timing differs(amber cap). The edit rule is not applied.Sealer requirements
media.timingand every entry'stiming, and add the audioesdstoconfig. Sign the core after the read-back. Segment messages are untouched.segments[]entry (vector 186).Vectors
debughas every recordmedia.timingtimingnot in rootstts)ctts)mdhd×2, durations keptesds48→44.1 kHztimingDecisions beyond the design
audio_timescaleis absent on silent files.timing→ no proof found (187).Recorded as open in §11:
esdsinside awavebox (no vector)Gates (Node 22.23.2)
These were run locally;
npm ciwas skipped because the lockfile is unchanged.typechecktest(280 tests)validatemanifest:checkconformance:check(187/187)generate:edge-casesgeneratetwice (byte-stable)C2PA vectors were re-minted with c2pa-node 0.9.8 and c2patool 0.27.16.
🤖 Generated with Claude Code