Skip to content

fix(disc): fold multi-clip Blu-ray titles onto a contiguous timeline (#105) - #110

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/bd-multiclip-timeline
Jul 7, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/bd-multiclip-timeline

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Problem (AE#105, round 3)

After R1 (decoy playlist) and R2 (MPLS duration / follow-selected-title) were confirmed by the reporter, the playhead position was still wrong on multi-clip titles: title 3 (0:00:42) read 1:10:14, title 4 (0:00:35) read 10:04, the ball pinned at the end, and title 3 again showed a blank frame.

Root cause

A multi-clip Blu-ray title concatenates m2ts clips that each carry their own STC, so the raw source PTS leaps at every clip boundary (the reporter's title 3 jumped ~91803s at its trailing clip: #65 ledger seg-10 drift=91803.676s). The engine uses a single constant videoShiftPts anchored on clip 0; the live timeline-rebase that absorbs such jumps (HLSSegmentProducer.swift:1444) is gated isLive, so VOD/disc inherits the jump. outputTfdt = source - shift then shows the raw source seconds, and post-boundary packets route past the plan into a blank frame. R2's duration fix corrected only the scrubber total and the plan, not the position.

Fix

The demuxer folds each clip onto one contiguous presentation timeline. MPLS already carries per-clip in_time and cumulative duration; from those the title selector computes a per-clip subtract offset (clip 0 = 0, so the plan/anchor/seeks in clip 0 stay untouched), disc recognition pairs each offset with the clip's byte span in the concat stream, and readPacket / indexedKeyframes attribute every packet and index entry to its clip by byte position (pkt.pos / entry.pos) and subtract that clip's offset. Active only for multi-clip BD titles; single-clip, main feature, DVD, and non-disc sources are a no-op.

Chose demuxer normalization over enabling the VOD producer-rebase: it fixes the concatenation seam itself, so the plan, producer, still extractor, and subtitle side-demuxer all see one clean timeline, and it leaves the regression-prone producer restart/tfdt code untouched.

Tests / builds

  • BDTitleSelectorTests.clipSubtractTicks (+4, incl. the reporter's observed 91803s drift), Issue105MultiClipTimelineTests (+4: byte-position attribution, contiguous-timeline assertion), MPLSParserTests per-clip retention (+1), BDDiscReaderTests single-clip no-op (+1).
  • Full disc suite green; strict-concurrency, tvOS-Sim, and iOS-Sim builds green.

Known residual (out of scope): a cold seek directly into a tiny trailing clip maps imperfectly (av_seek across the discontinuity); sequential playback is fully correct.

🤖 Generated with Claude Code

…105)

A multi-clip BD title concatenates m2ts clips that each carry their own STC, so
the raw source PTS leaps at every clip boundary (the reporter's title 3 jumped
~91803s at its trailing clip). A single constant videoShiftPts anchored on clip 0
cannot absorb that, so the output tfdt inherited the jump: the playhead read
1:10:14 instead of 0:41 and playback ran past the plan into a blank frame. The
earlier duration fix (db8eab8) corrected only the scrubber total and the plan,
not the position.

The demuxer now folds each clip onto one contiguous presentation timeline. MPLS
already carries per-clip in_time and cumulative duration; from those the title
selector computes a per-clip subtract offset (clip 0 = 0, so the plan/anchor/
seeks in clip 0 stay untouched), disc recognition pairs each offset with the
clip's byte span in the concat stream, and readPacket / indexedKeyframes
attribute every packet and index entry to its clip by byte position and subtract
that clip's offset. Active only for multi-clip BD titles; single-clip, main
feature, DVD, and non-disc sources are a no-op.

Tests: per-clip offset math (incl. the reporter's observed 91803s drift), byte
position to clip attribution, a contiguous-timeline assertion, MPLS per-clip
timing retention, and a single-clip no-op regression. Full disc suite green;
strict-concurrency, tvOS-Sim, and iOS-Sim builds green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HFZVoTDayyEfpqrY8ohNyg
@superuser404notfound
superuser404notfound merged commit 46d6c99 into main Jul 7, 2026
3 checks passed
@superuser404notfound
superuser404notfound deleted the fix/bd-multiclip-timeline branch July 7, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant