Repository navigation
Conversation
…ndition
A client that sends hls_subtitle_renditions_all_v1 (with
hls_subtitle_renditions_v1, and hls_remux_subtitle_renditions_v1 for a
copy remux) to /api/v2, which now advertises it, gets every embedded text
track of an HLS plan as a WebVTT rendition in one SUBTITLES group:
- The multivariant playlist lists the tracks in inventory order, NAME the
row's label made unique, LANGUAGE, FORCED, AUTOSELECT=YES, and
DEFAULT=YES only on the selected track. Each listed inventory row
carries hls_rendition {group_id, name, index}; subtitle.hls_rendition
keeps naming the selected one, now with its name and index.
- Each segment (sub_<track>_NNNNN.vtt, playlist
silo_rendition=subtitles&silo_track=<track>) is read when requested:
the window's packets come from the source's index (embeddedsub) and go
through the same FFmpeg WebVTT options on the clock the stream's own cue
output uses, then are cut with today's windows, origins, spans and
X-TIMESTAMP-MAP. Segments ahead of FFmpeg carry their cues at once.
Indexes, start times and windows are cached per process.
- The planner reads the index at start (3 s bound). A file it can't read,
or whose selected track it can't find, keeps the single pipeline
rendition. Replans on the same file reuse the set the stream serves.
- A track_change, or a subtitle_track_changed recovery, that keeps the
same set keeps the running stream and generation.
- Executors: nodes advertise hls_on_demand_subtitle_renditions_v1 and
attest the track count; recipes freeze the tracks (version 6); recipe
cards carry them, stream tokens only their numbers and the default.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cache.Index ran a shared miss detached from its callers with no deadline. A read that hung, as on a stalled network mount, never finished, so every later caller of that file waited out its own context. The shared read now gets 30 s: at the deadline its callers fail and the next caller reads again, while a read still blocked finishes on its own and is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes for on-demand renditions: - Stream tokens that carry them use a new method (transcode_subtitle_renditions_v1, or its copy-fMP4 twin), so older binaries refuse to rebuild the stream with one rendition for every silo_track. The proxy relays both methods. - Rehoming and the API's token rebuild take the renditions' names, languages and FORCED from the attempt's frozen recipe when it lists the same tracks; only a node rebuilding from a token alone names them by number. - A replan on the playing HLS stream's file pins the renditions it serves, none included, so turning subtitles off or moving to a sidecar on a single-rendition stream keeps it again. A failure_recovery classified subtitle_track_changed on an on-demand stream is a track_change: same file, the named track, Off when none is named. - The plan records the source version its index read; segments refuse any other. A read that fails or runs out of time answers 404 for the player to retry, as does a planned copy's segment no generation reaches; only a track the file can't give answers empty. The conversion slot now also bounds ReadPackets. - One 3 s bound and one read per file cover every planning pass of a start or replan, including the output-change fallback. - Nits: the MPEG-TS epoch is chosen on the cue clock, 90 kHz conversion can't overflow, repeated track numbers are listed once, segments require an active recipe, start-time probes are shared, and LANGUAGE is canonical BCP 47. - The protocol doc tells clients to disable subtitle selection explicitly when subtitles are off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dows from kept tracks On top of kept tracks: - The process keeps one embeddedsub.Cache (playback.SubtitleIndexes) for sources and kept tracks alike. Kept-track serving (keptsub), on-demand renditions and the planner's check for them read through it, so a file indexed for one is indexed for all. - On a server that keeps tracks, an on-demand segment reads its window from the track's kept copy when there is one (SetRenditionKeptTracks, wired in main), before reading the source. Its packets keep the source's timestamps, so the bytes match a source read; a test cuts every segment both ways. A window open to the end, or a track the recipe names without its catalog identity, still reads the source. Rendition tracks now record their codec, and transcode options the media file, to find the kept copy. - The end-to-end replan tests run on the /api/v2 service, since /api/v1 decisions are frozen. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The frozen /api/v1 decision drops each inventory row's hls_rendition and subtitle.hls_rendition's index, as it drops the other fields that came after the freeze. /api/v1 never negotiates on-demand renditions, so this only matters for a plan built for /api/v2 answered there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 43 minutes. View limit details
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)
ℹ️ 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. |
|
The Evidence section says evidence will be published once the PR has a number, but PR #3273 is numbered and no evidence link or captures are present.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 608ac76950
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| readCtx, cancel := context.WithDeadline(ctx, reads.deadline) | ||
| defer cancel() | ||
| indexed, err := playback.CueIndexedSubtitleTracks(readCtx, file.FilePath) |
There was a problem hiding this comment.
Include the initial file stat in the index-read timeout
When the API server's media mount stalls, this call can block playback planning indefinitely despite the three-second deadline. CueIndexedSubtitleTracks calls embeddedsub.Cache.Index, which synchronously runs fspath.Stat (os.Stat) before reaching its context-aware wait; canceling readCtx cannot interrupt that syscall. This also prevents falling back to the pipeline rendition when a healthy remote executor could still serve the file. Run the entire lookup, including its initial stat, behind the bounded wait so start/replan can actually fall back when the deadline expires.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 608ac76950
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| readCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), subtitleSegmentProductionWait) | ||
| go func() { | ||
| defer cancel() | ||
| c.load(readCtx, key, load, read) | ||
| }() |
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Security: Cancel abandoned subtitle rendition loads
An authenticated profile with an on-demand-rendition HLS session can request and cancel many distinct sub_<track>_<segment>.vtt URLs. Each cache miss strips request cancellation and starts a goroutine before the 8-slot read/conversion semaphore, so the handler exits while queued file reads and FFmpeg conversions continue for up to 30 seconds. Live encodes also accept segment numbers outside the advertised playlist, providing arbitrary cache keys. Rate limiting and the worker cap mitigate active work but do not bound queued goroutines or loading entries. Cancel a load when its last waiter leaves, bound the queue, and reject out-of-range segments.
Useful? React with 👍 / 👎.
…s-all # Conflicts: # docs/design/schemas/playback-v3/v3/decision-response.schema.json # internal/playback/subtitle_inventory_v3.go
A segment request that missed the window cache started a detached read that ran on for up to 30 s after the request left, before even taking a conversion slot. A client could request and cancel many segments and leave reads and FFmpeg conversions queued behind them. Now: - A window's read stops when the last request waiting on it gives up. - At most 256 window reads run or queue at once; a miss past that answers 404, which the player retries. - An encode's segment past its playlist's synthetic grid answers 404 instead of reading a window beyond the source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…included The start's 3 s bound on reading a source's index covered only the wait on the shared read. The index cache stats the file first, and a stat on a stalled mount ignores the context, so planning could wait on it past the deadline instead of keeping the pipeline rendition. The lookup now runs on its own and planning stops waiting at the deadline. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7bde0046d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // the frozen surface neither advertises nor negotiates them. | ||
| func NativeServerFeaturesV3() []string { | ||
| return append(ServerFeaturesV3(), FeatureBufferingQualityV1, FeaturePlaybackPlanSummaryV1, FeatureSubripSidecarV3, FeatureMarkerThumbnailsV3, FeatureHLSSubtitleRenditionsV3, FeaturePlanActiveQualityV3, FeatureHLSRemuxSubtitleRenditionsV3, FeatureHLSCopyMPEGTSV3, FeatureHLSVariableSubstitutionV3, FeatureCodecChannelCeilingsV3, FeatureNativeEmbeddedLimitationsV3) | ||
| return append(ServerFeaturesV3(), FeatureBufferingQualityV1, FeaturePlaybackPlanSummaryV1, FeatureSubripSidecarV3, FeatureMarkerThumbnailsV3, FeatureHLSSubtitleRenditionsV3, FeaturePlanActiveQualityV3, FeatureHLSRemuxSubtitleRenditionsV3, FeatureHLSCopyMPEGTSV3, FeatureHLSVariableSubstitutionV3, FeatureCodecChannelCeilingsV3, FeatureNativeEmbeddedLimitationsV3, FeatureHLSSubtitleRenditionsAllV3) |
There was a problem hiding this comment.
File the required Apple and Android follow-up work
This adds a client-visible playback capability, but the commit description explicitly says Apple and Android do not negotiate it and no follow-up is filed for either. AGENTS.md requires follow-up work to be completed or filed for both first-party clients; keeping the feature opt-in avoids breaking them but leaves the required coordination unfinished. File the client follow-ups, or document why each platform needs no work, before considering this change complete.
AGENTS.md reference: AGENTS.md:L150-L156
Useful? React with 👍 / 👎.
| // read is read (SubtitleRenditionSource). Windows are kept per file version, | ||
| // track and clock, so every session on the file shares them. | ||
| func readOnDemandCues(ctx context.Context, opts TranscodeOpts, number uint64, segNum int, span subtitleCueSpan, window subtitleCueWindow) ([]byte, error) { | ||
| idx, err := subtitleIndexes.Index(ctx, opts.InputPath) |
There was a problem hiding this comment.
Bound the initial stat when serving subtitle segments
If the media mount stalls after playback starts, every on-demand subtitle segment can block indefinitely here: embeddedsub.Cache.Index synchronously calls fspath.Stat before its context-aware wait. This happens before renditionCues.get establishes its bounded read, so neither that timeout nor a client disconnect releases the handler. The planning lookup now wraps this same operation with lookupWithin, but segment serving still bypasses that protection. Put the entire segment lookup, including the initial stat, behind a bounded wait so it can return the intended retryable error.
Useful? React with 👍 / 👎.
|
Superseded by #3331, which combines this change with the rest of the stack for review. |
Problem
Related issue: #1406
Validation tasks: none
In an HLS transcode or copy remux, Silo carries only the selected embedded text track as a WebVTT rendition, written by the stream's FFmpeg. Picking another track means a new FFmpeg and a new stream, so the viewer waits through a restart, and a player's own subtitle menu can't offer the other tracks because the playlist doesn't list them. On a file with 22 subtitle tracks, the viewer sees one.
This pull request lists every embedded text track of an HLS plan as a WebVTT rendition, for clients that ask for it. A rendition's segments are read when requested, through the file's index (#3270) or the kept track (#3272), independent of how far the transcode has got. Switching subtitles becomes a replan that keeps the running stream.
Depends on #3272, and through it on #3270 and #3271. The base is #3272's branch.
Approach
hls_subtitle_renditions_all_v1(withhls_subtitle_renditions_v1, andhls_remux_subtitle_renditions_v1for a copy remux) to/api/v2, which advertises it. Other clients get today's single rendition.SUBTITLESgroup lists the tracks in inventory order, withNAMEset to the row's label made unique,LANGUAGEas BCP 47,FORCED,AUTOSELECT=YES, andDEFAULT=YESonly on the selected track. Each listed inventory row carrieshls_rendition {group_id, name, index}, andsubtitle.hls_renditiongains the selected one's name and index.sub_<track>_NNNNN.vtt(playlistsilo_rendition=subtitles&silo_track=<track>) is built on request: the window's packets go through the same FFmpeg WebVTT options on the clock the stream's own cue output uses, then through today's windows, origins, spans andX-TIMESTAMP-MAP. A segment ahead of FFmpeg carries its cues at once. Indexes, start times and windows are cached per process.track_change, or afailure_recoveryclassifiedsubtitle_track_changed, on the same file and set of renditions keeps the running stream and HLS generation. Turning subtitles off keeps it too.transcode_subtitle_renditions_v1,transcode_copy_fmp4_subtitle_renditions_v1), so an older binary refuses them instead of rebuilding the stream with one rendition. Nodes advertisehls_on_demand_subtitle_renditions_v1and attest the track count, recipes freeze the tracks (version 6), and the proxy relays the new methods and segment names.playback.SubtitleIndexes, 64 MiB) serves feat(playback): keep embedded subtitle tracks and serve sidecars through the index #3272's kept-track reads and these segments. A shared index read now gives up after 30 s, so one hung read on a stalled mount no longer blocks every later caller of that file./api/v1never negotiates this, and its frozen decisions drop the new fields.docs/architecture/playback-protocol-v3.md,embedded-subtitle-index.md,docs/transcode-node-api.mdanddocs/playback-api.md, with the decision schema, a fixture, OpenAPI and generated web types.Validation
/api/v1view.go build ./...andgo vet ./...pass.maintoo (TestPlaybackInfoWithoutStripOrToneMapStillHasNoRoute,TestPlaybackInfoSkipsStripWhenRPUCannotBeStripped).make verify-actionlintrejects the local binary's version string;actionlintitself passes. The size ratchet failed in that run on feat(playback): keep embedded subtitle tracks and serve sidecars through the index #3272'ssubtitle_cache.go; after feat(playback): keep embedded subtitle tracks and serve sidecars through the index #3272 moved its eviction code into a new file, build, vet,make lint-changed,make verify-size-ratchetand the playback package tests pass again here.DEFAULT=YESon the selected English track. The subtitle playlist listed all 3,482 segments up front; segments came back in about 3 ms with correctly timed cues, and the TV drew them.NAMEuses the track title.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3273/
Risks
hls_on_demand_subtitle_renditions_v1gets no such plans, and tokens with renditions use methods older binaries refuse.Checklist
AI Disclosure
FORCED; turning subtitles off on a single-rendition stream restarted it; tokens with renditions used the old method, so an older binary could rebuild the stream with one rendition; afailure_recoveryclassifiedsubtitle_track_changedrestarted the stream; failed or slow reads answered empty segments instead of a retryable 404, as did a planned copy's segment no generation reached; index loads had no bound, and one hung shared read blocked every later caller; segments didn't check the source version; and smaller items (the MPEG-TS epoch chosen on the wrong clock, a 90 kHz conversion that could overflow, repeated track numbers,LANGUAGEnot canonical BCP 47). A later pass found/api/v1decisions carrying the new rendition fields; fixed.🤖 Generated with Claude Code
Note
Add on-demand HLS subtitle renditions for every embedded text track
sub_<track>_NNNNN.vtt). Segments are read from the source index and converted with FFmpeg; cue-cache size, conversions, loads, and start times are bounded.hls_subtitle_renditions_all_v1client feature. Nodes must advertise the newTransportFeatureHLSOnDemandSubtitleRenditionsV1transport feature; plans fall back to the single pipeline rendition when a node lacks support or an on-demand plan already failed.ErrSubtitleRenditionNotFound;ServeSubtitleSegmentandParseSubtitleSegmentNumberin subtitle_rendition.go now accept segment names instead of numbers; subtitle segment documents drop the duration fallback and MPEG-TS epoch adjustment; frozen V1 decision responses strip inventory HLS rendition metadata.Macroscope summarized 7bde004.