Skip to content

VOD loopback: the session clock keeps the source PTS origin until the first re-anchor, so a non-zero-origin source reports a position outside its own duration #270

Closed

Description

@superuser404notfound

What happens

On the VOD loopback path, engine.currentTime is reported on the SOURCE PTS axis from the first frame until something re-anchors the shift. duration is correct throughout, so the reported position can sit outside the item's own duration.

Same 600 s HEVC + AAC MPEG-TS three times, only the muxed PTS origin differs. Local file, no HLS, plain loopback VOD session:

PTS origin first playing tick first seek
1.4 s (ffmpeg default) cur=2.00 dur=60.0 fine
60 s cur=62.04 dur=600.0 lands, and the clock is correct from the re-anchor on
1001 s cur=1002.04 dur=600.0 seek#1 programmatic landed rendered=1001.34 target=480.00, playback resumed near the start

The shift is published at session start and looks right:

[AetherEngine] VOD shift published: 61.341s (prev 0.000s, delta 61.341s, changed=YES) seamAt=0.000s seams=1 foldShift=61.341s presentationOrigin=0.000s rawClock=0.00s avBufAhead=0.00s
  t=01 state=playing phase=playing cur=62.04 src=62.04 buf=109.34 dur=600.0

and the clock only becomes correct once a later seam republishes it:

[AetherEngine] VOD shift published: 63.301s (prev 61.341s, delta 1.960s, changed=YES) seamAt=232.000s seams=2 foldShift=63.301s presentationOrigin=0.000s rawClock=238.66s
  SEEKLANDED target=300.00 in 86ms (clock=300.00)
  t=13 state=playing phase=playing cur=302.80 src=302.80 buf=351.30 dur=600.0

Why it matters

A host scrubber opens at 1:02 on a ten-minute item for a 60 s origin, and a resume position written from that clock is wrong by the same amount. At broadcast-scale origins it stops being cosmetic: the 1001 s run reported a landing at 480 s while playback actually resumed at the beginning of the file. Broadcast-derived VOD (anything remuxed from a transport stream rather than re-timestamped) routinely carries origins in the hundreds or thousands of seconds.

Steps to reproduce

ffmpeg -f lavfi -i testsrc2=size=960x540:rate=25 \
       -f lavfi -i sine=frequency=440:sample_rate=48000 -t 600 \
       -c:v libx265 -preset ultrafast -pix_fmt yuv420p -c:a aac -b:a 96k \
       -output_ts_offset 60 -f mpegts origin60.ts

swift run aetherctl play --seconds 16 --seek-every 6 --seek-pattern 300 origin60.ts

The first playing tick reports ~62 s. Raising -output_ts_offset scales the error one to one.

Expected behavior

The session clock is on the item axis from the first frame: a 600 s source reports 0 to 600 regardless of the PTS origin its container happens to carry, and a seek target on that axis lands where it was asked to.

Notes

Found while verifying #268, where it is easy to hit because HLS VOD carved out of a broadcast stream keeps its origin. It is not an ingest problem: the runs above use a plain local file with no HLS in the path. #268's own axis mapping (the reader addresses playlist time while the engine seeks on absolute source PTS) is a separate defect and is already fixed on main in d8cc273.

Measured on macOS 26.5 through aetherctl, main at d8cc2734 (6.3.0 + the #268 merge).

Activity

  1. added
    bug
    on Jul 31, 2026
  2. superuser404notfound commented on Jul 31, 2026

    @superuser404notfound
    OwnerAuthor

    Fixed in b6d54fe, released in 6.4.0.

    The origin now comes from the container's own start time (HLSVideoEngine.sourceStartSeconds), installed when the session starts, and later shift publications no longer move it for a non-disc VOD source. The producer's shift is deliberately not the anchor: it also carries the producer's initial drift, which reads -0.08 s on a B-frame MP4 whose first PTS is 0, so anchoring on it would have shifted the clock of every source that was already correct.

    Verified on the three fixtures from the report: 60 s and 1001 s origins now publish 0-based positions inside their duration and seeks land where they were asked to (presentationOrigin=61.400 / 1001.341, first tick cur=0.74 / cur=0.70, SEEKLANDED target=300.00 clock=300.00), while the 0-based control stays byte-identical to before (presentationOrigin=0.000, cur == src). Two seek-landing events that published on the source axis while their own target was on the display axis are folded the same way.

    Closing on the measurement. The loopback path is shared across platforms, so there is nothing device-specific left in this one; the fixture recipes are in Scripts/fetch-fixtures.sh if it needs to be re-measured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions