Skip to content

Direct-play embedded subtitles: forward cue exposure bounded by the producer park breaks host advance-offsets (text and bitmap) #151

Closed

Description

@rrgomes

On the loopback-HLS path, a host that renders $subtitleCues in its own overlay and applies a negative (advance) subtitle sync offset queries cues several seconds ahead of the playhead — for both text (.text/.richText) and bitmap (.image) tracks.

subtitleDrainLeadSeconds is 60, but SubtitlePacketStore notes forward exposure is bounded by the segment producer's forward park (#102), so in practice only ~2-3 s of cues exist ahead of the playhead on a direct-play stream. A delay offset works (300 s retention behind the playhead), but an advance beyond the park shows nothing, or the cue flashes in late and is cut short as the window catches up. SRT and PGS alike, since both flow through the same side-demuxer drain.

Preferred resolution: let the subtitle side-demuxer read/produce further ahead — toward the 60 s drain lead — independent of the video producer's forward park, so both text and bitmap cues are available for a host-applied advance offset.

Alternative, text only: confirm whether prepareNativeSubtitles + eagerNativeSubtitleReaders populate a finished NativeSubtitleCueStore for embedded text tracks that a host could pull whole via $subtitleCues (analogous to the #88 external-track backfill). That would fix text client-side but not bitmap (which prepareNativeSubtitles excludes), so the forward-production approach is the one that covers both.

Context: we render engine subtitles in our own overlay with a user-tunable sync offset (mkvmerge convention). Delay is solid; advance is where users hit this. Repro: any direct-play MKV with embedded SRT or PGS, advance the offset a few seconds.

Activity

  1. added a commit that references this issue on Jul 19, 2026
  2. superuser404notfound commented on Jul 19, 2026

    @superuser404notfound
    Owner

    Fixed in 5.9.7 via #156, using the forward-production approach you preferred, so it covers text and bitmap alike.

    What ships:

    • A VOD-only subtitle forward prefetcher: a subtitle-only side reader that fills the session packet store up to playhead + 60 s (the full subtitleDrainLeadSeconds) independent of the producer's forward park. The drainer already decoded to +60 s once packets existed, so $subtitleCues now actually holds that window and an advance offset up to roughly 60 s has cues to land on. Delay offsets are unchanged (300 s trailing retention).
    • It routes every embedded subtitle stream (all other streams discarded on the side demuxer), parks on the subtitle PTS axis, and re-anchors on seeks via the drain tick's jump detection. While a producer restart is in flight the open defers, so it never competes with a restart for a starved link (the Loopback-HLS: a single backward seek on heavy 4K can wedge the segment producer (video stalls, audio continues -> A/V desync) #93 rule).
    • Split-PES PGS display sets (MPEG-TS) now assemble under a per-writer key in the store, so the pump and the prefetcher can feed the same stream concurrently without corrupting each other's in-flight set.
    • Live sessions skip it (content past the edge does not exist), and it is best-effort: if the side demuxer cannot open or wedges, behavior is exactly the previous tap-fed path.

    On your alternative: embedded text tracks do fill native cue stores via the pump tap, but that coverage is bounded by the same producer park, and prepareNativeSubtitles indeed excludes bitmap, so the forward-production route was the right call.

    When the prefetcher engages you should see #151 forward prefetch started: streams=[...] startAt=...s lead=60.0s in the log, and cue queries a few seconds ahead of the playhead should return populated results for both SRT and PGS on a direct-play MKV. Please retest with an advance offset on your side and reopen if anything still comes up short.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions