Repository navigation
fix(video): rebase the timeline across an archive chunk seam on a sequential origin (#368) - #371
Conversation
…uential origin (superuser404notfound#368) IPTV timeshift archives are chunked recordings whose every chunk restarts near PTS 0; libavformat's 33-bit wrap correction turns that backward seam into a +2^33 leap (device: dts delta 8226410192 ticks, 363524400 + 8226410192 = 2^33 exactly). The producer's timeline rebase was live-only, so on a sequential origin the leap reached the keyframe-gated cutter as item-axis time and walked its monotonic index to the plan tail: frozen playlist, a backpressure park waiting on a segment the playlist can never advertise, and a wedge recovery whose reposition a sequential origin refuses. The SW host already folds these seams for forward-only VOD (shouldFoldTimeline); this is the producer-path equivalent. Both stream rebases (video + audio) now run for sequential-origin VOD under the same thresholds. Cutter, ledger and append playlist are untouched: they operate on post-shift output time, so after the rebase the cutter keeps walking the same plan boundaries sequentially and EXTINF stays real. No EXT-X-DISCONTINUITY is added at the seam - the archive is content-continuous and the output timeline stays continuous; the discontinuity/force-cut flags stay live-only. Co-Authored-By: Claude Fable 5 <[email protected]>
…user404notfound#368) rebasedVideoShift is extracted as a pure static so the chunk-seam wrap can be pinned against the field values: the seam packet lands exactly one fallback frame past the last output dts, for the 2^33 wrap, a backward chunk restart, and the live-scale jump (extraction changed nothing for live). The cutter test pins the superuser404notfound#368 contract from the other side: rebased continuous dts advances one boundary per cut, while a raw wrap-scale leap saturates at the tail clamp in a single call. Co-Authored-By: Claude Fable 5 <[email protected]>
0e3dd02
into
superuser404notfound:main
|
Merged, thanks. The shape is right: the cutter, the ledger and the append playlist all work post-shift, so the rebase is the one place that needed to know about the seam, and reusing the live thresholds keeps one definition of "discontinuity" in the file. Verified here that One gap the rebase opens, fixed in a follow-up on main (20adae8, merge a17a8b4). The published clock folds A sequential archive has no source axis to anchor a display origin on: every chunk restarts near PTS 0 and the wrap correction turns each seam into a fresh fiction, so no single source PTS maps to display-0 for the session. Its item axis does, it starts at 0 because the producer is pinned to byte 0, and it is exactly what Nothing structural depended on it, which is why the traces do not show it: the #65 wedge detector reads the rendered playlist position, not the engine clock. It is worth a look during the device retest though, since a host progress bar and any resume position ride on it. |
Fixes #368.
What happens today
On a sequential origin (
LoadOptions.sequentialOrigin, IPTV timeshift archives), a chunk seam's PTS reset — wrap-corrected by libavformat into a +2^33 leap — reachesVODSegmentCutteras item-axis time and walks its monotonic index to the plan tail in one call. From there the session is structurally dead: the append playlist freezes (folded indices publish duration 0 and get no URI), the backpressure park waits for a fetch ofhead − 10that the playlist can never advertise, AVPlayer drains and stalls, and the #65 wedge recovery's reposition is exactly what a sequential origin categorically refuses. Field trace: 4 minutes of clean playback, stall, and a retry session that died the same way ~2 s in (the arithmetic fingerprint:363524400 + 8226410192 = 2^33exactly, surfaced by movenc asApplication provided duration: 8226410192 in stream 0 is invalid).The fix
Run the existing live timeline rebase (video and audio, unchanged thresholds and pairing machinery) for sequential-origin VOD as well:
rebasesTimelineOnDiscontinuity = isLive || foldsSequentialTimeline, with the engine passingsequentialOriginPinsProducerToZero. The cutter, ledger, and append playlist need no change — they operate on post-shift output time, so after the rebase the cutter keeps walking the same plan boundaries sequentially and EXTINF stays real.Deliberate choices, spelled out in comments:
sequentialOriginis already the client's declaration "this is a forward-only chunked recording"; timeline continuity across its chunk seams is a correctness property of that declaration.SoftwarePlaybackHost.shouldFoldTimelinealready folds these seams unconditionally forisLive || !sourceSeekable(its comment cites the same failure at +92726 s), so gating the producer path behind a second flag would make the two hosts behave differently for identical options.EXT-X-DISCONTINUITYat the seam. The archive is content-continuous and the output timeline stays continuous after the rebase; the discontinuity/force-cut flags stay live-only (they feed only the live segment bookkeeping).onLiveTimelineRebasefires for sequential seams too, on purpose: the A53 caption tap and subtitle mapping need the playlist axis moved the same way, andhandleLiveTimelineRebase's deferred-shift contract is exactly right for it.isSourceReplaystays untouched in the shared path: it requires a recent unplanned reconnect, which a sequential origin (single connection, no reconnect) can never have.Tests
TimelineRebaseMathTests(new): the rebase math extracted as a pure static and pinned against the device trace — the 2^33 wrap continues exactly one fallback frame past the last output, a backward chunk restart (the SW-host trace) keeps output moving forward, a live-scale jump proves the extraction changed nothing for live, and the zero-fallback floor.VODSegmentCutterTests: the Sequential-origin VOD: a 33-bit PTS wrap at an archive chunk seam is never rebased — cutter folds to the plan tail, playlist freezes, session dies on a refused re-anchor #368 contract from the cutter's side — rebased continuous dts advances one boundary per cut, while a raw wrap-scale leap saturates at the tail clamp in a single call.Test plan
swift test(full suite, counts above).Merges cleanly alongside the #369 and #370 PRs; the three-way combination is integration-tested locally (full suite green on the merged tree).