Repository navigation
Description
Summary
Protocol v3 subtitle sidecars are always served by the API node. The URLs published in
playback_plan.subtitle.inventory[].url (and font_bundle_url) are hardcoded to the API-relative
/stream/{session_id}/subtitles/{n}, so in a multi-node deployment every subtitle fetch lands on
the API server even when the media itself is being served by a proxy node.
The proxy already implements the routes (/stream/subtitles/{token}/{track} and
/stream/subtitles/{token}/{track}/fonts), but nothing ever points a client at them.
This is the remaining piece of the same class of problem as #619 (direct play and progressive
remux, fixed in #620) and the closed #326 (direct downloads).
Source
Observed during verification of #620 on a multi-node deployment: media was correctly served by a
proxy node while the .vtt sidecar was still fetched from the API host.
Steps to Reproduce
- Deploy an API node plus at least one proxy node.
- Play a title whose plan publishes a sidecar subtitle inventory, and enable a subtitle track.
- Observe the network trace: the media request goes to the proxy, while
…/subtitles/{n}.vtt?file_id=…goes to the API host.
Expected Behavior
Subtitle sidecars and ASS font bundles for a proxy-served session are fetched from the proxy node
serving that session, so subtitle egress follows the media.
Actual Behavior
playback.SubtitleStreamURLV3 (internal/playback/subtitle_inventory_v3.go:213) and
SubtitleFontBundleURLV3 (same file, line 226) emit API-relative paths unconditionally. They have
no proxy-node awareness, and are not reached by the transport-layer node planning added in #620.
The blocker: combined ordinals vs container track indices
This is not a URL rewrite. The two handlers do not resolve the same track from the same number,
so naively repointing the URLs would silently serve the wrong subtitle track rather than fail.
BuildSubtitleInventoryV3 (internal/playback/subtitle_inventory_v3.go:110-129) assigns each item
a combined ordinal as len(items) across three consecutive ranges:
file.ExternalSubtitles(sidecar files on disk)file.SubtitleTracks(embedded container tracks)- downloaded subtitles (DB rows, stored in S3)
The API handler (internal/api/handlers/stream.go:236+) resolves that combined ordinal back
through the same three ranges. The proxy handler (internal/proxy/server.go:430+) does not: it
passes the ordinal straight to ffmpeg as a container track index against claims.MediaPath.
On any file with at least one external subtitle, the ranges are offset — combined ordinal N names
a different track on each side. The failure is silent: the viewer gets a subtitle, just the wrong
one.
Capability comparison:
| Source | API handler | Proxy handler |
|---|---|---|
| Embedded container tracks | yes (ffmpeg) | yes (ffmpeg) |
| External sidecar files | yes — reads ExternalSubtitles[i].Path |
no knowledge |
| Downloaded subtitles | yes — SubtitleRepo + S3Client |
no DB, no S3 access |
| Ordinal meaning | combined (externals → embedded → downloaded) | raw container track index |
Design options
Not decided; needs a call before implementation.
- Carry the resolved identity in the stream token. Extend the subtitle token claims with the
source discriminator and the resolved per-source index (plus the external file path, or the
downloaded artifact locator) so the proxy never re-resolves an ordinal it cannot interpret.
Most complete; grows the token and needs care so a path claim does not leak node-local layout. - Route only what the proxy can serve. Point embedded-track URLs at the proxy and keep
external and downloaded ones on the API. Smaller change, but the inventory then mixes hosts,
and the ordinal offset problem still has to be solved for the embedded subset. - Relay through the proxy. Have the proxy forward subtitle requests to the API rather than
resolving locally. Simplest correctness story, but it puts the bytes back on the API node and
so defeats most of the point.
Option 1 matches how #620 handled direct play and remux (freeze what the executor needs into the
token, since the proxy has no database).
Scope
Owning project: Silo Server. Client-visible only in that plan URLs become absolute, which clients
already tolerate for HLS and — after #620 — for direct play and remux.
Notes on priority
Lower impact than #619: subtitle sidecars are small and fetched once per track (a representative
.vtt in the observed trace was ~58 KB) rather than being a continuous stream. This is about
completing the "no media egress on the API node" property, not about relieving significant load.
Acceptance Criteria
- For a proxy-served session, sidecar subtitle URLs and ASS font-bundle URLs resolve to the
proxy node serving that session. - A given combined ordinal resolves to the same track whether served by the API or a proxy —
specifically covering a file that has external subtitles ahead of embedded ones. - External and downloaded subtitle sources either work through the proxy or are deliberately
and explicitly kept on the API, with the choice documented in code. - Sessions with no eligible proxy keep the current API-local behavior.
- PGS/
.supwindowed requests (?windowed=1,?position=,?duration=) behave identically
on both paths. - Tests cover the ordinal-equivalence case above and the no-proxy fallback.
Activity
Rhainland commentedon Oct 23, 2026
Reproduced on
origin/mainat 19f59ef: a local API server plus one registered proxy node, and a synthetic MKV with two embedded SRT tracks (eng, ger) and an external French.fr.srt. A v2playback/startreturned a direct-play plan whose media URL points at the proxy (/stream/direct/<token>, 206). Every subtitle URL is API-relative (/api/v2/stream/{session}/subtitles/{0,1,2}.vtt), and the API log shows all three fetches landing on the API server.The proxy's own subtitle route accepts the session's stream token, so no token scope change is needed to reach it. But it numbers tracks differently, as the issue warns:
0:s:2matches no stream)Cause: the API route reads the number as a position in one list (external files, then embedded tracks, then downloaded subtitles), while the proxy passes it straight to ffmpeg as an embedded-track index. The proxy also cannot do the API's database and blob-store work: external timing corrections, the auto-sync job, downloaded subtitles, and the VTT
position/durationwindow.This needs a maintainer decision:
/stream/subtitles/<token>/<number minus external count>, while external and downloaded subtitles stay on the API. No token change, but one subtitle list then spans two hosts, the proxy route skips the API's embedded-track check, and VTT windowing differs between the two hosts. This is the smallest correct step if a mixed-host subtitle list is acceptable.No PR for now. Open PR #2571 touches the same files.
AI disclosure: reproduced by Claude Code (claude-opus-5-5) at the maintainer's direction.