Repository navigation
Description
Summary
On the nativeRemoteHLS bypass, clock.sourceTime is documented as "Source PTS of the currently displayed frame". What it actually tracks is AVPlayer's item (playlist) time. On a Jellyfin HLS transcode, after a seek, item time runs ahead of the displayed frame by between 1.1s and 8.3s. The amount changes with every seek. A host driving a subtitle renderer from sourceTime (libass, in our case) draws every line early.
The WebVTT renditions injected by #316 are not affected. AVPlayer times those against the media timestamps, so they stay in sync.
AetherEngine 7.15.0, Jellyfin 10.11.11, fMP4 HLS transcode (H.264/HEVC), iOS 26.6 device.
Mechanism (measured)
- On a seek, Jellyfin restarts the transcode with
-ss <slot start> -noaccurate_seek -copyts. ffmpeg therefore starts at the source keyframe at or before the slot. The first segment'stfdtcarries the real (earlier) PTS, while the playlist places that segment at its slot start. Our transcoding URL givesEXTINF3.003 segments. - AVPlayer anchors its item timeline to the first segment it loads after the seek:
item = pts + (slot_first − tfdt_first). - It keeps that anchor when Jellyfin restarts the job again underneath it. Requesting the init segment always restarts the job at 0, and later segments can carry a different slot−keyframe gap.
Measured with a bare AVPlayer on macOS against the real transcoding URL, comparing presented frames with a reference decode:
| First segment loaded after seek | slot − keyframe | Measured item − frame offset |
|---|---|---|
| seg 494: slot 1483.482, keyframe 1482.272 | 1.210 | 1.209 |
| slot 1786.785, keyframe 1783.699 | 3.086 | 3.086 |
In the first case, a later job restart at seg 500 had slot − tfdt = 2.252. AVPlayer ignored it and kept 1.209. So probing the tfdt of the currently playing segment is not a reliable way to recover the offset.
On device, across repeated scrubs of one film, the offset varied between 1.1s and 8.3s. sourceTime − AVPlayer item time read ≈ 0.000 throughout, so sourceTime carries the offset unchanged.
Repro
- Load a Jellyfin HLS transcode URL with
nativeRemoteHLS: true. - Seek to a mid-film position that isn't keyframe-aligned (almost any).
- Compare
clock.sourceTimewith the PTS of the frame on screen, or with when an injected nativeRemoteHLS: external subtitles can never become renditions (load-time dropped, post-load overlay-only) #316 WebVTT cue appears.sourceTimeleads by the first post-seek segment's slot − keyframe gap.
Expected
Either sourceTime reflects the displayed frame's PTS on this route, or its docs note that on nativeRemoteHLS it is item time, which can lead the picture after a seek on origins that restart at keyframes. The exposed offset would be enough for hosts.
Host workaround, in case it helps
The host keeps the injected WebVTT rendition selected. An AVPlayerItemLegibleOutput with suppressesPlayerRendering = true reports each cue with the item time AVPlayer presents it at. Matching the cue text to the script event then gives offset = itemTime − event.start. That self-corrects on every line.
One trap worth knowing: if the output starts suppressing while AVPlayer is already drawing a line, that line stays frozen on screen for good, and a deselect afterwards doesn't clear it. Deselecting the rendition, letting a frame or two pass, then attaching the output and reselecting avoids it.
If the engine could publish the item-to-media offset it already sees (e.g. from the first post-seek segment's tfdt, or from its own legible pipeline), hosts wouldn't need this.
Activity
superuser404notfound commentedon Sep 24, 2026
Thanks for the thorough report. The table and the frozen-line trap saved a lot of time.
Confirmed in the code: on the
nativeRemoteHLSbypasssourceTimewas wired straight to AVPlayer's rendered item time, so the documented contract did not hold on that route.The fix is in #617, taking the route suggested at the end of the report: the engine measures the offset on its own #316 renditions.
suppressesPlayerRendering = false. It changes nothing about what AVPlayer draws, and it cannot trigger the frozen-line trap, because it never suppresses.offset = itemTime - cue.start. The delivery at a seek landing is skipped, because a line active there carries the landing time rather than its own start. Lines that end teach nothing.clock.sourceTimethen publishes item time minus that offset.currentTime,seek(to:)and the scrubber stay on item time, so seeking round-trips unchanged. The log line to look for isAE#616: item time leads the presented frame by ....Limit, also written into the docs: it measures only while one of the injected renditions is selected and presenting. So the setup from the report (rendition selected, a host output with
suppressesPlayerRendering = truein front of it) is exactly the case it covers, and the host-sideitemTime - event.startmatching should no longer be needed. Without an injected renditionsourceTimestays item time.Verified locally with a fMP4 HLS fixture whose playlist puts every segment 1.5 s after its
tfdt.sourceTimeled the decoded picture by 1.46 s before the first line and sat within one frame after it, including across a seek. One difference from your measurements: on that local origin, which never restarts anything, AVPlayer kept its first anchor across a seek rather than re-anchoring. So the per-seek variation you saw needs Jellyfin's restart pattern, which I cannot reproduce here. A run of the branch against your Jellyfin transcode (repeated scrubs, comparingsourceTimewith the frame on screen) would be the real test. I'll leave the issue open until then.superuser404notfound commentedon Sep 24, 2026
Released in 7.15.2 (
19a222fe, merged in #617). On thenativeRemoteHLSbypass,sourceTimenow follows the presented frame, measured off the injected WebVTT renditions.currentTimeandseek(to:)stay on item time. With no injected rendition selected,sourceTimestays item time, as the API docs now say. A retest on the transcode from the report would confirm the lead is gone. I will leave the issue open until then.imbenjamin commentedon Sep 24, 2026
Verified on 7.15.2 against the same setup as the report: Jellyfin 10.11.11 fMP4 HLS transcode of Deadpool (2016),
nativeRemoteHLS, iPhone 16 Pro on iOS 26.6. The injected WebVTT rendition was selected, with a hostAVPlayerItemLegibleOutput(suppressesPlayerRendering = true) in front of it. For this run the host calibration was switched off, so libass was driven byclock.sourceTimealone. Seven scrubs, forward and back.For each line AVPlayer presented, we logged
sourceTimeminus that event'sStartin the script:sourceTime − Starton the lines after itThe lead varied between 0.8 s and 3.9 s from scrub to scrub, which is the Jellyfin re-anchoring pattern from the report, and
sourceTimeremoved it every time. After the first measured line,sourceTimesat 7–90 ms behind the event start. That is within one tick of the 100 ms observer we sample it from. Styled subtitles looked in sync on screen throughout. From our side this fixes the issue, and we'll drop our host-sideitemTime − event.startmatching when we bump.One observation, not a blocker: between a seek landing and the first line the engine measures,
sourceTimestill carries the previous seek's offset. In the log, the one or two lines right after a landing read −1.50 s, −1.77 s (previous lead 2.9 s, new 1.15 s) and −1.79 s (previous 3.8 s, new 2.1 s), and then fell into line. So for those first seconds a host renders late when the new lead is smaller, and early when it is larger. That matches the limit you described. We'll keep a short hold after a seek on our side. If the engine could say whether the offset has been measured since the last time jump (a flag, or an optional offset that resets ontimeJumped), hosts could gate on that instead of re-detecting seeks themselves. That would be nice to have, not something this issue needs.Thanks for the quick turnaround. Fine to close from our end.
superuser404notfound commentedon Sep 24, 2026
Thanks for the careful retest, and for sampling it per line across seven scrubs. Good to see the lead removed on every landing.
The flag you suggested is in #624, merged to main and part of the next release:
clock.sourceTimeFollowsPicture(plus the one-shot mirrorsourceTimeFollowsPictureon the engine).nativeRemoteHLSit is alwaystrue.falseat load and at everyAVPlayerItem.timeJumpedNotification, andtrueonce a presented line of an injected rendition has re-measured the lead. Without an injected rendition selected it staysfalse, sincesourceTimeis plain item time there.falsewindowsourceTimestill applies the previous lead, as before. The flag only says it is a guess, so the −1.5 to −1.8 s lines from your log fall exactly inside it and can be held on that instead of on your own seek detection.Closing this one as confirmed. If anything about the flag doesn't fit how libass is driven on your side, a new issue is welcome.
superuser404notfound commentedon Sep 24, 2026
Released in 7.16.0 (
eb172571):clock.sourceTimeFollowsPictureand thesourceTimeFollowsPicturemirror from #624 are in it.feat(clock): sourceTimeFollowsPicture says when the remote-HLS lead i…