Repository navigation
feat(playback): restart keyframe-planned copy streams mid-stream - #1770
Conversation
A complete VOD playlist for copied video needs the segment boundaries before FFmpeg starts (Silo-Server#1466). This reads the video keyframe times from a Matroska file's Cues, following the seek head to Cues stored after the clusters and never reading the clusters, and plans segment starts with the rule FFmpeg's HLS muxer uses for copied video: cut at the first keyframe at or after the target, then move the target on one segment. Tests check the reader against ffprobe and the plan against the segments FFmpeg writes, on a file with irregular keyframes; they skip without ffmpeg. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copy-remux HLS served FFmpeg's growing playlist, and Safari's native player can fall back to a partial copy of it and stop mid-episode (Silo-Server#1466). Behind the new playback.copy_keyframe_playlist setting (off by default), a copy stream that starts at the beginning is served as one complete VOD playlist, planned from the source's Matroska Cues. From the start of the file FFmpeg's HLS muxer cuts copied video at the planned keyframes, so its seg_NNNNN files are the planned segments. A seek restart would cut elsewhere, so until mid-stream restarts land a planned session waits for segments ahead of FFmpeg and restarts from the beginning when one is gone. The flag is frozen into recipe cards, stream tokens, transcode-node requests and Jellycompat's play-session source so rebuilt sessions keep the playlist. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The transcode-node start request gained keyframe_playlist; the system info fixture carries the contract digest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ists Review fixes for the keyframe playlist: - Matroska recommends but doesn't require a cue for every video keyframe, and a plan missing one would cut segments where FFmpeg doesn't. The reader now checks a few clusters spread through the file, and the cluster after each, reading only block headers, and reports ErrIncompleteIndex (an ErrNoIndex) if any video keyframe has no cue. - A transcode node attests that it understood a requested keyframe playlist; both remote start paths reject a node that doesn't, as they do for the throttle and copy recipes. - Jellycompat records the flag only for copy streams, after subtitle delivery can turn a copy into a transcode, and compares it only for copy streams, so encoded sessions still match their recipes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o fix/copy-remux-vod-playlist-1466-part2 # Conflicts: # contracts/api/v2/fixtures/get_system_info_ok.json # internal/config/admin_settings.go
Sampling a few clusters can't prove the Cues list every video keyframe: an uncued keyframe in an unsampled cluster would still let the plan cut where FFmpeg doesn't. VerifyMatroska now walks every cluster's block headers and requires a cue for each video keyframe and a keyframe for each video cue; a cluster too large to read completely fails the check. Because that reads every block header, Load runs it once per file in the background: the first playback gets ErrUnverified (an ErrNoIndex) and FFmpeg's playlist, and later playbacks use the verified index from the cache. LoadVerified runs the check itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Track in-flight full checks apart from the evictable result cache and cap the queue; a file that finds it full is checked on a later playback, so cycling through many files can't pile up goroutines. - Cache malformed files as having no index; only errors reading the file are retried, so a damaged MKV isn't rescanned on every playback. - The v3 paths request a keyframe playlist only for copied video, so an older transcode node isn't rejected for an encoded job. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A planned copy stream could only restart from the beginning, since FFmpeg's HLS muxer counts its cuts from where it starts (Silo-Server#1466). Now a planned run cuts at every keyframe into one-group files, and the session joins them into the planned segments: it maps each group's first video presentation time to a keyframe of the plan, and once a segment's keyframes all have groups it writes seg_NNNNN.m4s (keeping moof/mdat pairs and the first styp, dropping sidx). Group boundaries don't depend on where FFmpeg starts, so a missing segment restarts FFmpeg at it, and assembled segments survive restarts. Each run's timeline shift is measured and tfdt rewritten so every run lines up with the first. Progress, startup readiness and the pruner's retention come from the plan and the assembler. MPEG-TS copy keeps FFmpeg's playlist. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emux-vod-playlist-1466-part3
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
The background check cleared its in-flight marker before storing its result, and admission didn't look at stored results, so a Load in between could queue the same file again. The result and the marker now change under one lock, and a file with a stored result isn't queued. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emux-vod-playlist-1466-part3
A load that missed the cache, then found the check already done when it tried to queue one, still reported ErrUnverified. It now looks again and returns the stored result. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emux-vod-playlist-1466-part3
The plan took the probed duration as the stream's end on the container's timeline, but the duration counts from the file's start and container timestamps can start later than zero. For such a file the last segment came out negative and the plan was dropped. The end is now the first keyframe plus the duration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n zero FFmpeg's output starts at zero (-start_at_zero) while the plan's keyframe times are the container's, so for a source whose timestamps start later the first group matched no keyframe and the run stopped assembling. Group times are now measured from the first keyframe. The end-to-end test also runs on a copy of its source shifted 7s later. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emux-vod-playlist-1466-part3 # Conflicts: # internal/playback/copy_keyframe_plan.go
- Record whether a session serves a keyframe playlist in its output directory. A session rebuilt from its recipe follows the record, so it can't switch playlists once the file's index has been verified. - Reject segment numbers outside a planned playlist in recovery, and clamp restarts into it, so a bad request can't panic the executor. - Report the current run's last group as the playlist's time, so the throttler can pause FFmpeg for a planned stream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The plan ended the last segment at the catalog's runtime. That is the container's duration, which can include an audio or subtitle track running past the video. FFmpeg ends its last segment with the copied video even when the selected audio is longer (checked with FFmpeg 8.0.1 and jellyfin-ffmpeg 8.1.3), so the plan advertised media that doesn't exist. VerifyMatroska already reads every block, so it now records when the video's last frame ends: its timestamp plus the track's default frame duration, or the gap to the frame before. The plan ends there, and falls back to FFmpeg's playlist when that is unknown. The FFmpeg comparison test now has an unselected audio track that runs 20s past the video, and checks the last segment too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emux-vod-playlist-1466-part3 # Conflicts: # internal/playback/copy_keyframe_plan.go # internal/playback/copy_keyframe_plan_test.go
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
-start_at_zero subtracts the input's start time, which is the earliest stream's start, not the first keyframe's. When audio starts before the video, the assembler measured groups from the wrong zero: it placed the first group on a later keyframe and stopped assembling. The plan now records the start time from ffprobe, which opens the file with the same demuxer as FFmpeg. Without it, the session uses FFmpeg's playlist. The time is also kept in the session's plan record. The end-to-end test adds a source whose audio starts 2s before its video. 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: 2d0ab3a5df
ℹ️ 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".
#19) * fix(catalog): say a far seek restarts the copied-video playlist's copy Silo-Server/silo-server#1770 restarts the copy at a seek well past what has been copied, instead of waiting for it to get there. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(translations): copied-video playlist far-seek description in seven languages Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
With segment retention on, a restart keeps the assembled segments after its start. The player can download them, and the pruner remove them, before the new run reaches them. The run then rebuilt them behind the pruner's cursor, which never visits those numbers again in the generation, so they stayed on disk. A run now drops the groups of a segment the pruner removed during it; a run restarted at that segment still rebuilds it. The pruner also left the removed file's DV8.1 conversion entry, keyed by name and generation, so a planned segment written again under that name in the same generation was served without conversion. Removing a segment now drops its entry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's Silo-Server#2515 plans copy playlists from the file's Cues without the full check, and checks the plan against the segments FFmpeg writes to its own playlist. Take its planning: the rebuild path loads the index with keyframes.Load, and the plan carries the file version to reject. Planned runs here write keyframe groups, not FFmpeg's segment playlist, so the check moves to the group assembler. A group that starts where the plan has no keyframe, or a planned keyframe FFmpeg skips, stops the run and rejects the file version (keyframes.Reject), so later playbacks keep FFmpeg's playlist. checkCopyPlan, checkCopyPlanOutput and the never-written rule, which read FFmpeg's playlist, are dropped with their tests. Reconstructed stays: a rebuild whose probe of the source's start fails still returns the error rather than serve FFmpeg's playlist to a player holding the plan. A first start with a failed probe now records nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…places it A session rebuilt without its plan record starts from the beginning, and a request far ahead restarts it before that run has placed a group. The seek run then set the session's timeline, a B-frame delay short of the original from-start run's, so the rebuilt segments sat that far off the ones the player had (80 ms on a -bf 2 source). The record kept the timeline only while the output directory survived. A planned restart now waits, up to 3 seconds, for the run it replaces to set the timeline, or for its FFmpeg to exit. A copy from the start places its first two groups within moments. 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: 94f212d141
ℹ️ 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 pruner removes a segment under s.mu and tells the assembler after releasing it. A restart in between replaced the run, so the late notice marked the new run's segment pruned, and that run dropped the groups of the segment it was restarted for. Each run now records the generation it was started for, and a prune notice marks only the run of the generation its pass checked. The segment's assembled flag is cleared either way. Calling forget under s.mu instead would make the session lock wait for an assembler scan, which reads and writes segment files under its own lock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…meline wait main's restart now keeps the stopped throttler's threshold for a restart hook that times out (Silo-Server#4127). The planned restart still lets the run it replaces set the session's timeline before stopping it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… rebuilt segment counted Two gaps on the keyframe-planned path: - A native segment or playlist request for a planned session the server lost (no session, no runtime) rebuilt the session first and the runtime separately. When the plan record could no longer be served (ErrKeyframePlanChanged), the player got a 404 and the rebuilt session stayed registered, holding a stream slot. Planned cards now take the atomic rebuild tone-mapped cards already use: the session is removed again and the player gets 410 playback_session_ended. - A prune notice that reports after a restart rebuilt the segment cleared its assembled flag, so the new run's head stopped short of it. forget now unmarks a segment only when its file is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
Review of fc62fd380, which is this branch with current main merged in. Two findings, both on the planned path. I'm fixing both in a commit on this branch, so there's no need to change anything yourself.
🤖 Claude Code (claude-opus-5-5), with a cross-provider review by gpt-6.1-sol
…d restart On fast storage FFmpeg copies keyframe groups faster than the assembler joins them. On the sandbox it had written groups through segment 640 while segments were assembled through 335. A seek restart stops the run and waits for its monitor, which first joined that whole backlog: the restart's new FFmpeg started 10 s late and the segment took 22.7 s. A run whose FFmpeg was cancelled (a restart or close) now stops assembling between segments. It still reads groups until it is anchored, since its first groups can set the session's timeline. A run that ends on its own still finishes its last segments. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
One more finding from the live check on a sandbox at 7a7654722, fixed in c428fd3d2.
🤖 Claude Code (claude-opus-5-5)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c428fd3d22
ℹ️ 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".
…or a passed segment - Two groups 40 ms apart fit keyframes 0 and 1 alike when keyframes are evenly spaced near a restart's seek. The run took the later one, so its third group matched no keyframe: the run stopped, the session failed, and a valid file was rejected. A run now holds its first groups while more than one keyframe within a B-frame-sized shift fits them, up to eight, and anchors once the groups tell them apart. - A queued restart treated a missing segment at or behind the new run's head as about to be written. The pruner had removed it after the run passed it, so nothing wrote it and the request ended in a 404. It now restarts, as plannedSegmentRecoveryDecision already decides. 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: e3f7b26699
ℹ️ 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".
Problem
Related issue: #1466 (part 3 of the copy-remux VOD playlist)
Part 2 (#1760) has merged into main. The later parser repairs on #1756 are separate and are not included here. This PR adds mid-stream restarts and group assembly on that base.
Builds on #2515 (fix for #2453), now merged: plans come from the file's Cues, without the full keyframe check. Here the check that the plan matches the file moves into the group assembler: a group that starts where the plan has no keyframe, or a planned keyframe FFmpeg skips, stops the run and rejects the file version (
keyframes.Reject), so later playbacks keep FFmpeg's playlist.Validation tasks: none
No passed case is affected: with the setting off, every changed path behaves as on main. The related copy-remux cases (#1250 C5, #1252 C3 and C5, #1246 C1, and the matching Apple and Android Series cases) are Not run.
With part 2, a keyframe-planned stream can only restart from the beginning. FFmpeg's HLS muxer counts its cuts from where it starts, so a seek restart would cut at keyframes the playlist doesn't list. Instead, a seek ahead of FFmpeg waits for it to copy that far, and a seek back past pruned segments recopies from the start. On slow storage either can outlast a player's segment timeout. This PR lets a planned stream restart anywhere, as the design on #1466 describes.
Approach
hls_time, so each file it writes,gop<run>_NNNNNN.m4s, holds one keyframe group. A group's boundaries don't depend on where FFmpeg started.copyGroupAssemblerwatches the run's groups:tfdtplus the first sample's composition offset) and maps it to a keyframe of the plan;seg_NNNNN.m4sand removes the groups;styp, and dropssidx, whose byte ranges would be wrong. Fragment offsets are moof-relative, so this is a plain concatenation.tfdtin the segments it writes, moving every run onto the first run's timeline.tfdtcan't go below zero, so the assembler drops that fragment's audio samples that end by zero and starts the fragment at the first one it keeps. The samples it keeps stay where the timeline puts them, so there is no discontinuity; only the first one or two audio frames go. A video fragment that would go below zero is still an error.RecipeOpts) keeps the first run's start, not the start of the latest restart. The plan, not the run, is the session's timeline, so a session rebuilt after an audio switch plans the same segments from the verified index again. A segment request then restarts FFmpeg at the player's position.ErrKeyframePlanChanged: no session can serve that playlist, so the player needs a new playback session rather than a silent switch to FFmpeg's playlist.SegmentProgress, the startup readiness check behindWaitForManifest, and the pruner's retention window read the assembler and the plan's durations instead of FFmpeg's playlist. The planned mode now needs fMP4; MPEG-TS copy (webOS Dolby Vision) keeps FFmpeg's playlist.Validation
Run in WSL2:
TestPlannedCopySessionSwitchesAudioAtTheStart). The source has B-frame-free H.264 and two FLAC tracks, the first starting 100 ms late, and audio is encoded to AAC. The test switches to the other track at 0:00, and segment 0 must assemble and decode cleanly. It fails without the priming fix (negative decode time, segment 0 never assembled) and passes with it on FFmpeg 8.0.1 and jellyfin-ffmpeg 8.1.3.TestRecipeOptsKeepsAPlannedSessionAtItsStart: a planned session restarted at segment 2 persists a recipe that still plans.TestResolveCopyPlanMigratesADurationsOnlyRecord: a feat(playback): serve copy remux from a complete keyframe playlist #1760 record with matching durations becomes a full plan record. Mismatched durations, or an index that gives no plan, fail withErrKeyframePlanChanged.TestShiftFMP4DecodeDropsAudioBeforeZero: the priming trim, its data offsets, and a fragment wholly before zero.tfdtshifting), the plan's keyframe ranges, restart seek and retention floor, the missing-segment decisions, and the restart target.internal/playback/...,internal/jellycompat, and theinternal/api/handlerstests for the changed recipe call.golangci-linton the changed packages, from currentmain, is clean.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-1770/
The page has the latest checks, at
c428fd3d2ande3f7b2669. Two dev-builder sandboxes, one built frommainand one from this branch, get the same Safari-style native HLS start on a 2-hour H.264 MKV, with the setting on. A request for segment 978 (minute 73) one second after start takes 29.1 s onmain, which waits for the copy from the start, and 0.40 s and 0.86 s on this branch, which restarts FFmpeg at the keyframe before the segment. Restarted segments sit on the from-start run's timeline (0.082 s after their playlist position, like segments 0, 100 and 200) and decode cleanly. It does not establish real-player playback.Recovery and audio-switch fixes
None of the three fixes changes anything on screen: they are server-side recovery paths behind the same off-by-default setting, so there is no new screenshot to take. The settings screenshots below still show the only visible change. The effect of each fix is in the server's output.
Early audio switch. The
TestPlannedCopySessionSwitchesAudioAtTheStartsource, switching to the second audio track at 0:00.Before (
da00acbbf):After: segment 0 assembles, and init plus segment 0 decode with
ffmpeg -xerrorand no output.Rebuild after an audio switch. Before, the recipe persisted the restart's seek and segment. A rebuild without its plan record read that as a mid-stream start, recorded
planned:false, and served FFmpeg's growing playlist to a player holding the VOD one. After, the recipe keeps the first run's start, and the rebuild plans the same segments.#1760 plan records. Before, a durations-only record failed the new field checks and the session silently went unplanned. After, it is upgraded from the verified index when the durations match, and otherwise the rebuild fails with
ErrKeyframePlanChanged.Mid-stream restart (earlier pushes)
The author's original timing comparison and captures below are historical, at the source revisions they name, and have not been repeated for the current head.
The same requests on the same server data, first on #1760 (part 2, this PR's base), then on this branch, both with Complete playlists for copied video on. #1760's Evidence section shows the change from
main: the setting and the complete playlist.The source is a 20-minute MKV with irregular keyframes (H.264 video, AC3 5.1 audio). A Safari-style client that plays only HLS starts playback at 0:00 (
server_remux_hls, video copied), gets the 369-segment planned playlist (1200.000 s,#EXT-X-ENDLIST), and one second later requests segment 277, which starts at 902.708 s, far ahead of what FFmpeg has copied.Before (#1760): the request waits for FFmpeg to copy from the beginning to minute 15.
After (this branch): FFmpeg restarts at the keyframe before the segment.
Both segments start on the same frame, where the playlist places them, and init plus segment decode without errors.
The setting is the one #1760 adds, in Playback → Advanced, off by default:
main)Surface and build: native playback API, local builds of #1760 at
7801c3dbfand this branch at2965f56abagainst one database, with generated test media.Risks
Review fixes and remaining work
At
da00acbbf, groups select the nearest keyframe within timestamp tolerance, and the process monitor drains final group assembly before reporting completion. The focused regressions, playback/config race tests, changed-package lint, and Jellyfin FFmpeg 8.1.3 restart/decode tests pass. Two local Jellycompat Dolby Vision tests also fail on current main and remain baseline failures.The three open review concerns are fixed in this push, with the policies the author chose:
The setting remains off by default.
User manual: Silo-Server/siloserver.org#198 tracks
/docs/playback: the experimental/off-by-default setting, fMP4 eligibility, background keyframe verification/first-play fallback, and seek/recovery behavior. The setting and background verification landed in #1760; #1770 proposes the fMP4 assembly and mid-stream recovery changes. The required manual-impact issue is open. Documentation of #1770-specific shipped behavior waits for merge and playback verification; player/Safari acceptance remains untested. Apple and Android need playback verification, but no new client API implementation was identified. Jellycompat uses the shared path.Review fixes at
7a7654722,c428fd3d2ande3f7b2669mainis merged in atfc62fd380. The one conflict was inTranscodeSession.restart, and both sides were kept. A maintainer review of that merge found three defects on the planned path, all fixed on this branch:410 playback_session_ended). Before, it answered 404 and left the rebuilt session holding a stream slot.Each fix has a regression test that fails without it.
Review fixes at
798c2ab5eA maintainer review of
df73a7d8bfound ten defects on the planned path; one commit on this branch fixes them (see the review threads):ErrKeyframePlanChangedis terminal:410 playback_session_endednatively, 404 on jellycompat.A planned restart also waits, up to 3 s, for the run it replaces to set the session's timeline, so a session rebuilt without its output directory keeps the from-start timeline. The setting's description, which still says a seek ahead waits, is fixed in Silo-Server/silo-translations#19; once that release is out, this branch syncs it with
scripts/sync-translations.Checklist
AI Disclosure
Review fixes: Codex (
gpt-6.1-sol, xhigh), six read-only GPT-6.1 Sol review agents, and one read-only Claude Opus 5.5 (claude-opus-5-5, high) round. The two bounded repairs were written by Codex and checked with focused tests and sandbox evidence.Recovery and priming fixes: Claude Code (
claude-opus-5-5), with the author's choice of policies, checked with focused tests and real FFmpeg in WSL2.Merge of
mainand the fixes at7a7654722,c428fd3d2ande3f7b2669: Claude Code (claude-opus-5-5), with one read-only review round by Codex (gpt-6.1-sol, xhigh). Checked with focused tests, real FFmpeg in the sandbox image, and live sandbox requests.Harness: Claude Code (Claude desktop app, Code tab)
Tool(s): Claude Code, GitHub CLI, FFmpeg/ffprobe (upstream 8.0.1 and jellyfin-ffmpeg 8.1.3) in WSL2
Model(s): claude-opus-5-5
Involvement: Fully AI-generated, human verified
Adversarial review: Self-review. It checked that a restart keeps assembled segments but removes the previous run's groups; that pruned segments are rebuilt when a later run reaches them; and that the startup readiness check and the throttler read the assembler rather than a playlist that no longer exists. It also checked that the measured timeline step between runs is removed rather than assumed away, and that MPEG-TS copy stays on FFmpeg's playlist. For this push, it checked that the priming trim moves every trun's data offset in a moof that shrinks, and refuses fragments not based on their moof.
🤖 Generated with Claude Code
Summary
Adds an opt-in, keyframe-planned VOD playlist for eligible copy-remux playback, allowing FFmpeg to restart mid-stream without changing the segment list already provided to the player. This is intended to address Safari playback stalls caused by growing, partial HLS playlists.
Changes
playback.copy_keyframe_playlist), disabled by default.Tests Added
Adds coverage for keyframe parsing, verification and caching; segment planning and manifests; recovery decisions; persisted planning decisions; recipe and token preservation; remote acknowledgment; and fMP4 assembly and timestamp alignment. FFmpeg integration tests cover irregular keyframes, shifted source timestamps, delayed video starts, mid-stream restarts, and decoding assembled output.
Automated Review Findings
Two high-severity findings were reported:
Note
Support mid-stream restarts for keyframe-planned copy streams
checkCopyPlan,checkCopyPlanOutput, and related helpers are removed). See copy_group_assembler.go and copy_keyframe_plan.go.TranscodeSession.restartseeks to the restart keyframe and starts a new assembler run at the requested segment. A new seen-generation timestamp onRestartSegmentLocked/RestartSegmentSinceskips a restart when a newer run already covers the segment.ErrKeyframePlanChanged, which handlers map to a session-ended response. Subtitle spans and progress reporting now derive timing from the assembler and plan.ErrKeyframePlanChangedand end the session (HTTP 410/404) instead of serving; checkmigrateCopyPlanRecordin copy_keyframe_plan.go and the error mappers in playback_missing.go and streams.go.Macroscope summarized e3f7b26.