Repository navigation
Description
Summary
Enabling a subtitle track mid-playback takes noticeably long to show cues (web player and Apple clients), while disabling is instant on the web. Investigation shows the delay is on-demand ffmpeg subtitle extraction with no caching, and the Jellyfin-compat endpoint used by the Apple clients is the slowest possible variant (whole-file pass, fully buffered before the first byte).
Subtitle toggling never restarts the transcode (subtitles are out-of-band and client-rendered on both stacks — this is good architecture), so the fix is purely about extraction latency.
Current behavior
Every subtitle enable spawns a fresh ffmpeg extraction. There is no extracted-subtitle cache anywhere.
Native API (GET /stream/{session}/subtitles/{track}, used by web):
- Text (SRT→VTT): windowed extraction with input-side
-ss+-t(default 600s window) streamed with per-chunk flush — first cue ~1s. This path is fine. - ASS/SSA and PGS: windowing is disabled (
windowable = !IsASS && !IsPGS,internal/playback/subtitle_stream.go:129-142) — ASS needs the[Script Info]header at offset 0, PGS.supis consumed whole by libpgs. Enabling these triggers a whole-file demux from byte 0, which takes many seconds on large files / network storage.
Jellyfin-compat API (GET /Videos/{item}/{mediaSource}/Subtitles/{index}/stream.{format}, used by Apple clients):
playback.ExtractSubtitle/ExtractSubtitleWithFormat(internal/playback/subtitles.go:58-132) runffmpeg -i file -map 0:s:Nwith no-ss, no-t, and buffer the entire output into abytes.Bufferbefore writing a single byte — for every embedded track, every request. This is strictly worse than the native path.
Web "off is instant" is expected: disable is pure client-side teardown (abort fetch, clear cues); no server round trip.
Why this matters
Plex toggles subtitles with only a momentary pause. Silo can beat that (no transcode restart needed), but today the enable path stalls on a cold whole-file ffmpeg pass on the two most common real-world cases: ASS subs on the web, and everything on Apple clients.
Proposed fixes
- Cache extracted subtitle tracks, keyed on media file (path + mtime or media source id) + stream index + output format. Embedded subtitle tracks are immutable for a given file; a small on-disk cache (similar to trickplay/attachment caches) makes every enable after the first instant, and makes even the first enable a one-time cost that could be pre-warmed at playback start.
- Fix the compat endpoint: stream ffmpeg stdout instead of buffering the full output, and reuse the native path's windowed/seeked extraction (
StreamExtractSubtitle) where the format allows, instead of the whole-fileExtractSubtitle. - Optional: pre-warm extraction when a playback session starts (kick off extraction of the default/likely subtitle track in the background) so the first toggle hits the cache.
Pointers
internal/playback/subtitles.go:58-132— compat whole-file buffered extractioninternal/playback/subtitle_stream.go:114-187— native windowed streaming extraction (windowablegate at :129)internal/jellycompat/streams.go:543-670—HandleSubtitleStreaminternal/api/handlers/stream.go:174-256— nativeHandleSubtitleweb/src/player/hooks/useSubtitleTracks.ts,useASSSubtitles.ts,usePGSSubtitles.ts— client renderers (off-instant/on-slow asymmetry)
Related
The Apple clients have a separate, purely client-side cause for the same symptom on direct play (CoreMedia demuxer discards subtitle packets for already-buffered media and doesn't re-seek on enable) — being fixed in silo-apple. Fixing this server issue additionally covers the sidecar/transcode cases and the web player.
Activity
zZebrahz commentedon Jul 3, 2026
I can handle this later, just making a note of it
Quick104 commentedon Sep 11, 2026
Closing: addressed by merged #938 (Related issues: #296; extraction caching and subtitle delivery reliability).