Repository navigation
fix(disc): fold multi-clip Blu-ray titles onto a contiguous timeline (#105) - #110
Merged
Merged
Conversation
…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
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.
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) read10: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 constantvideoShiftPtsanchored on clip 0; the live timeline-rebase that absorbs such jumps (HLSSegmentProducer.swift:1444) is gatedisLive, so VOD/disc inherits the jump.outputTfdt = source - shiftthen 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_timeand 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, andreadPacket/indexedKeyframesattribute 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),MPLSParserTestsper-clip retention (+1),BDDiscReaderTestssingle-clip no-op (+1).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