Repository navigation
feat(playback): stream embedded text subtitles as HLS renditions in copy remuxes - #3033
Conversation
…opy remuxes HLS copy remuxes delivered embedded text subtitles as a sidecar that FFmpeg extracts from the whole source before the first cue, so on large files clients timed out waiting for subtitles. Transcodes already carry the track as a WebVTT rendition inside the stream (#2620); copy remuxes now do too. The subtitle playlist lists the video playlist's own keyframe-cut segments (the keyframe plan's VOD playlist, or FFmpeg's EVENT playlist), cue windows follow those segment durations, and closed generations record their durations in subtitle_spans.json. The remux multivariant playlist states VIDEO-RANGE PQ or HLG, fixed at plan time from the source track's scanned transfer. Each copy generation records its first video packet on the cues' clock, so the timestamp map declares how much later the HLS mux put the video (B-frame lead or AAC priming, two frames on a default x264 source). A keyframe-planned copy answers 404 for a subtitle segment FFmpeg has not reached after the wait, as its video segment does. Clients opt in with hls_remux_subtitle_renditions_v1, which requires hls_subtitle_renditions_v1; clients that send only the latter keep today's remux plan. Transcode nodes advertise hls_remux_subtitle_rendition_v1, and node selection, routing, and rehoming require it for a copy remux. Related: #1406 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
C4 needs re-validation for the new copy-remux rendition path. The recorded C4 result comments on Suggested Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
…waits toward the throttle A copy remux's subtitle origin now reads the video start its generation recorded before it probes the first segment, so a missing record costs no ffprobe run, and after three misses the origin is taken without a mux shift instead of being retried every few seconds for good. On a keyframe-planned copy, a subtitle segment FFmpeg has not reached now counts as the player's position for the throttle while it waits, as the matching video segment request does. A player that fetches subtitles ahead of video no longer waits on a paused FFmpeg and then gets a 404. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Evidence is incomplete for the visible playback change. The PR reports that the Roku run showed embedded captions without a sidecar, including after a replan, but says the run predates the timestamp-map correction; it therefore does not demonstrate caption synchronization with the corrected build. Please add a recording to the linked evidence page showing the final build with captions aligned to video, including after a seek or replan. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
writeFileAtomic created its temporary file and renamed it into place with paths joined onto the session output directory. It now opens the directory as an os.Root and creates, renames, and removes the files inside it, as the filesystem blob store does, so neither name can resolve outside the directory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
…ttle position A planned-copy subtitle request moved the throttler's position to any segment number it named. One past the plan never comes, and the throttler then measured FFmpeg's buffer against it and stopped pausing FFmpeg. Only segments inside the plan now move the position. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Main's Silo-Server#3033 moves recording a planned segment request into notePlannedSegmentRequest, which its subtitle renditions also call. Keep this branch's narrower near-head case and its planned progress, manifest and audio recipe helpers, and record the request through main's helper. Main's Silo-Server#2954 drops SegmentProgress.ProducedCount, which nothing read; planned progress no longer sets it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Related issue: #1406
Validation tasks: none
The Subtitle playback & appearance tasks have C4 passes recorded in comments
(Silo-Server/silo-apple#313, Silo-Server/silo-apple#314,
Silo-Server/silo-android#323, Silo-Server/silo-android#324). Those passes stay
valid for the current Apple and Android clients. They send
hls_subtitle_renditions_v1but nothls_remux_subtitle_renditions_v1, sotheir copy remuxes keep the sidecar (
TestPlanPlaybackV3KeepsTheRemuxPlanForTranscodeRenditionsOnly).Their transcode renditions go through refactored cue-window and segment-serving
code. The fixed-grid playlist and cue placement stay the same, and the existing
transcode rendition tests still pass. The one difference is that a long wait for
a segment not yet produced now polls at most once a second. When a client opts
into the new feature, its C4 case needs a re-test on remux renditions.
When a client plays an HLS copy remux with an embedded text subtitle, the
subtitle arrives as a sidecar that FFmpeg extracts from the whole source before
it returns the first cue. On large files that takes longer than clients wait:
on a 4K Dolby Vision remux the server log showed the extraction taking 278.6 s,
so the player showed "Loading subtitles" and then gave up. HLS subtitle
renditions (#2620) fixed this for transcodes by writing the track as WebVTT
from the stream's own FFmpeg process, but copy remuxes still used the sidecar.
This change gives HLS copy remuxes the same WebVTT subtitle rendition for
clients that opt in with a new feature,
hls_remux_subtitle_renditions_v1.Approach
hls_remux_subtitle_renditions_v1. It is/api/v2only, attempt-sticky, and has effect only together with
hls_subtitle_renditions_v1. It is a separate feature because Apple andAndroid already send
hls_subtitle_renditions_v1and have not been testedwith remux renditions. A client that sends only the existing feature gets
the same remux plan as today, and a test pins that.
at source keyframes, so their lengths vary. The subtitle playlist lists the
video playlist's segments (
sub_NNNNN.vtt) with the same durations, playlisttype, and end tag: the keyframe plan's VOD playlist when the remux has one,
otherwise FFmpeg's growing
EVENTplaylist. Each subtitle segment's cuewindow comes from those durations. FFmpeg replaces its playlist on a seek
restart, so a generation records its segment durations in
subtitle_spans.jsonwhen it closes. Cues from before the restart stay inplace, including in a session rebuilt from disk.
VIDEO-RANGE. With a rendition, the remux URLbecomes a multivariant playlist, and HLS treats a variant without
VIDEO-RANGEas SDR. The API fixes the range when the plan starts, from thesource video track's scanned transfer characteristic:
PQfor SMPTE ST 2084,HLGfor ARIB STD-B67, none for any other signaled transfer (Dolby Vision8.2's SDR base layer included). A track that signals no transfer is
PQforthe Dolby Vision to HDR10 strip and for
dvh1Dolby Vision (profile 5). Thevalue travels to the executor as
video_rangeon the node start request andin recipe cards and stream-token claims, and the executor only accepts
PQor
HLGon a copy. Every load of the playlist names the same range withoutwaiting for FFmpeg.
zero, B-frames or AAC priming give it negative decode times. fMP4's
make_non_negativethen delays the whole HLS output by that lead, andMPEG-TS's 10 s offset lands on the first decode time. The WebVTT output moves
with neither, so on a default x264 source cues showed two frames (83 ms)
early. Each copy generation now also writes its first video packet,
unshifted, as a one-packet
framecrcfile beside its cues. The timestamp mapadds the difference between that packet and the first segment's observed
start, and
subtitle_spans.jsonrecords it.404for a subtitle segment FFmpeg still hasnot reached after the 30 s wait, as its video segment does, instead of an
empty document the player would keep. Other remuxes and transcodes keep the
empty answer. A long wait now polls with backoff, up to once a second.
hls_remux_subtitle_rendition_v1. For a copy remux, the executor check, nodeselection, and rehoming require it and use the remux routing policy, so a
node that only has
hls_subtitle_rendition_v1is never sent a remuxrendition.
already reject a version 4 recipe that carries a rendition outside a
transcode, so they fail closed and do not drop the subtitle.
The protocol and node API docs (
docs/architecture/playback-protocol-v3.md,docs/transcode-node-api.md), the decision schema description, and theprotocol fixtures are updated. jellycompat does not plan protocol v3
renditions and is unchanged.
#1406 stays open. The web player, remuxes and transcodes without a rendition,
and every sidecar fallback still use the extraction path it describes; this
change only moves opted-in remuxes off it.
Follow-ups: silo-apple and silo-android can opt in once they have been tested
with remux renditions. Their copies of the protocol fixtures need the new
server_featuresentry at their next sync.Validation
Ultra played a 4K Dolby Vision profile 7 remux (HDR10 strip) on a development
server. Selecting its embedded English SubRip track showed WebVTT captions
8 s later, including after a replan. The node ran the track as a second
WebVTT output of the remux's own FFmpeg process, and the client made no
sidecar request. That run predates the timestamp-map correction.
ran on a development server with the same Roku Ultra and a different movie
with an embedded English SubRip track. Selecting the track had the player
playing with WebVTT captions 7 s later. The client made no sidecar request,
and the node's FFmpeg command carried the WebVTT rendition output and the
one-packet
framecrcoutput. Not yet confirmed: on-screen cue alignment(device screenshots do not capture the video plane, so it needs a person
watching), and seek or replan on this build. The later throttle fix
(cd53cdd) was not in that build.
go build ./...,gofmt -l .,go vet ./...,make lint-changed,make lint-router-recovery: pass.make test-goon 72edcd7, without FFmpeg onPATHas CI runs it: pass. With FFmpeg onPATH, two jellycompat Dolby Vision routing tests fail the same way they do onmain.go build ./...,go test ./internal/playback ./internal/transcodenode(without FFmpeg, so the real-FFmpeg tests skipped), andmake lint-changed: pass.verify-settings-bindings-all,verify-playback-fixtures,verify-route-inventory,verify-migration-ledger,verify-scenario-catalogs,verify-offline-routes,verify-apiv2-openapi,verify-apiv2-contract,verify-apiv2-fixtures,TestCommittedArtifactMatchesRouter,verify-local-paths,verify-case-collisions,verify-size-ratchet,verify-bidi,verify-migrations,verify-v1-route-freeze,verify-prometheus-rules): pass.v1.7.12and the Make target's exact check rejects that.web/is unchanged.The tests cover the planner's choice, fallback after a failed rendition, and
the unchanged plan for clients without the feature; subtitle playlists and cue
windows on variable-length segments; durations and the mux shift kept across
a seek restart and a rebuilt session; the
VIDEO-RANGEmapping and itsadmission check; the range surviving the recipe card and stream token; the
planned-copy
404and a request past the plan leaving the throttle position alone; node feature routing; and real FFmpeg output. No Apple,Android, or browser player has played a remux rendition.
Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/remux-subtitle-renditions/
Risks
on-screen cue alignment has not been checked on any device. The first of
those clients to opt in should test an
EVENTsubtitle playlist next to aremux that is still being produced, and an HDR remux's
VIDEO-RANGE, onreal hardware.
vrg, holding the range. Tokens without it name no range.copies a single video packet and closes.
mux delay; this change does not alter them.
changes once on upgrade. In a mixed-version pool, older nodes are never chosen
for a remux rendition.
Checklist
AI Disclosure
Note
Add embedded-text subtitle HLS renditions for copy remuxes
HLSSubtitleRenditionTransportFeatureV3) in protocol_v3.go. If the rendition route was already attempted, the plan falls back to the sidecar remux.vrgkey forVIDEO-RANGE) so rebuilt sessions restore remux timelines; unusable spans are discarded byloadSubtitleSpans.VideoRangetoTranscodeOptsandTranscodeStartRequest, with PQ/HLG derivation from transfer metadata and Dolby Vision detection inCopyHLSVideoRange; only PQ/HLG are valid for copy video.StartTranscoderejects invalid HLS video-range recipes; copy-remux span records use a new schema viawriteFileAtomic(nowos.Root-scoped), so older persisted span records without duration lists are discarded on load;ServeSubtitleSegmentreturns 404 for not-yet-reached planned-copy segments instead of a generic error.Macroscope summarized cd53cdd.