Skip to content

fix(playback): serve a resumed copy stream from a complete keyframe playlist - #4400

Merged
Quick104 merged 7 commits into
Silo-Server:mainfrom
rangoDJ:fix/copy-keyframe-playlist-resume-1466
Nov 17, 2026
Merged

Quick104 merged 7 commits into
Silo-Server:mainfrom
rangoDJ:fix/copy-keyframe-playlist-resume-1466

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1466 (stays open: the reporter's failures aren't confirmed to be resumes)
Builds on: #1760, #2515 and #1770, all merged. No unmerged dependency.
Validation tasks: none

Other clients: Apple N/A (no client change needed; the server builds the playlist); Android N/A (same); Roku N/A (same)

With Complete playlists for copied video (playback.copy_keyframe_playlist) on, only a copy stream that starts at 0:00 gets the planned VOD playlist. planCopySegments refuses any session with a seek or a start segment, so every resume still gets FFmpeg's growing playlist. That is the playlist Safari's native player can fall back to a partial copy of and stop mid-episode (#1466). The reporter on #1466 still sees Safari remux failures with the setting on.

This change gives a resume the complete playlist too, from the keyframe it starts at to the end.

Approach

  • Plan from the resume keyframe. When the handler has resolved the resume's copy seek anchor (CopySeekAnchorResolved, StreamOriginSeconds > 0), the plan's segments start at the latest keyframe at or before that origin, within 0.1s. The origin trails its keyframe by up to a B-frame delay and never leads it, so a later keyframe nearer the origin isn't the one. If two keyframes fall within 0.1s before the origin, the origin doesn't say which one the stream starts at, and the resume keeps FFmpeg's playlist. The plan keeps every keyframe of the file. A start that no keyframe is near, or a seek without a resolved anchor, keeps FFmpeg's playlist as before.
  • A resume is marked on the plan. The plan and its record say it is a resume's, rather than inferring it from the first segment's keyframe. Audio that starts before the video gives a resume at the first keyframe a positive origin.
  • Rebuilds keep the first start's playlist, through the recipe. A resume's plan numbers and cuts segments differently from FFmpeg's playlist, and the plan record in the output directory doesn't survive a clean shutdown. So the decision travels with the recipe as KeyframePlanResume. A session that starts a resume's plan sets it on its options. The local v3 recipe, jellycompat's recipe and the node's start response (keyframe_plan_resume) carry it, and so do the recipe card and the stream token. A rebuilt resume without it keeps FFmpeg's playlist: its first start fell back, or ran on a build that never planned a resume. One with it plans again, or fails with ErrKeyframePlanChanged when it can't.
  • Moves to another node. rehomeStartRequestV3 asks for a keyframe playlist for a resume only when it planned, and then sends keyframe_plan_resume: true, which requires the plan. docs/transcode-node-api.md describes the new field.
  • Same timeline the player was given. The API's stream origin and seek window don't change, so the web player needs nothing new. A seek back before the resume point still starts a new session, as it does today.
  • First run as a restart. The session's first FFmpeg run seeks to the keyframe before the plan's first segment, the seek feat(playback): restart keyframe-planned copy streams mid-stream #1770 uses for a restart. Its groups before that segment belong to no segment and are dropped.
  • Kept across restarts and rebuilds. Planned restarts keep the resume's origin. RecipeOpts keeps the requested position, so a rebuild plans the same segments. SegmentAt maps a source position into the resume's plan.
  • Jellycompat. BuildSourceAlignedPlaybackManifest adds the same gap and EXT-X-START before a resume's plan that a seeked FFmpeg playlist gets.

The alternative was to serve the whole file's plan from 0:00 and have the player seek to the resume position. That would change the handler's timeline contract, the web player and jellycompat, so this PR doesn't do it.

Validation

  • New unit tests for planning a resume: the basic one fails on main. The keyframe choice, first-keyframe resume and failed-probe rebuild tests fail on this PR's first commit, the clean-shutdown rebuild test fails on d99bc21, the close-keyframes test fails on 49a75af, and the recipe-decision rebuild tests (did not plan, must plan and can't) fail on 4b3d193. All pass at 4864bf0, with tests for the recipe card and token round trip and the rehome request.
  • Not tested: the node's keyframe_plan_resume echo in a real start response, and a rebuild from a real saved recipe after a restart.
  • The origin trailing its keyframe and never leading it is what all three FFmpeg test resumes show (13.000/13, 18.520/18.5, 26.120/26.1). I haven't verified it from ResolveCopySeekAnchor's code.
  • New real-FFmpeg test with jellyfin-ffmpeg 8.1.3. On main it fails for all three resumes (14s, 20s, 27.3s): the session serves FFmpeg's growing playlist. Here, each resume gets a complete VOD playlist, every segment assembles and the stream decodes cleanly. Segment 0's first frame matches today's unplanned resume exactly. ffprobe measures the assembled video's length, in all and in its last segment, to match the playlist. A restart back to segment 0 rebuilds the same segment. The source-aligned playlist carries the gap and starts at the requested position.
  • go test for internal/playback/..., internal/jellycompat, internal/transcodenode and internal/api/handlers: pass.
  • make lint-changed: no issues.
  • Review fixes at 14c731b: the regenerated contracts/api/v2/openapi.json, which CI's contract check and TestCommittedArtifactMatchesRouter required, and a keyframe playlist attestation that also requires the keyframe_plan_resume echo. TestValidateKeyframePlaylistAttestation failed on 4864bf0 before that fix.
  • Not run: Safari or any real player, real-world files (only synthetic MKVs), remote transcode nodes, and the copy-remux validation cases (Series — Server #1250 C5, Series — Web #1252 C3 and C5, Compatibility layers (Jellyfin / Audiobookshelf) — Jellyfin compatibility #1246 C1).

Evidence

Nothing a user sees changes in the UI. Checked with the tests above on main at 8f93594. Resume start times, planned against today's unplanned resume:

Resume at Resolved origin Unplanned first frame Planned first frame Planned segments
14.0s 13.000s 13.080s 13.080s 8
20.0s 18.520s 18.600s 18.600s 6
27.3s 26.120s 26.200s 26.200s 4

Before, on main at 8f93594 (go test ./internal/playback -run 'TestPlanCopySegmentsForAResume|TestPlannedCopySessionResumes', trimmed):

--- FAIL: TestPlanCopySegmentsForAResume (0.00s)
    copy_keyframe_resume_test.go:26: no plan for a resume at a resolved keyframe
--- FAIL: TestPlannedCopySessionResumes (0.73s)
    --- FAIL: TestPlannedCopySessionResumes/14s (0.01s)
        copy_keyframe_resume_test.go:110: resume at 14.0s (origin 13.000s): no plan, the session serves FFmpeg's growing playlist
    --- FAIL: TestPlannedCopySessionResumes/20s (0.01s)
        copy_keyframe_resume_test.go:110: resume at 20.0s (origin 18.520s): no plan, the session serves FFmpeg's growing playlist
    --- FAIL: TestPlannedCopySessionResumes/27.3s (0.01s)
        copy_keyframe_resume_test.go:110: resume at 27.3s (origin 26.120s): no plan, the session serves FFmpeg's growing playlist
FAIL

After, at d99bc21 (go test ./internal/playback -run Resume -v, trimmed):

--- PASS: TestPlanCopySegmentsForAResume (0.00s)
--- PASS: TestPlanCopySegmentsForAResumeTakesTheKeyframeBefore (0.00s)
--- PASS: TestPlanCopySegmentsForAResumeAtTheFirstKeyframe (0.00s)
--- PASS: TestResolveCopyPlanKeepsFFmpegPlaylistForARebuiltResumeWithoutARecord (0.00s)
    copy_keyframe_resume_test.go:279: resume 14.0s: origin 13.000s, unplanned starts 13.080s, planned 13.080s, 8 planned segments
    copy_keyframe_resume_test.go:279: resume 20.0s: origin 18.520s, unplanned starts 18.600s, planned 18.600s, 6 planned segments
    copy_keyframe_resume_test.go:279: resume 27.3s: origin 26.120s, unplanned starts 26.200s, planned 26.200s, 4 planned segments
--- PASS: TestPlannedCopySessionResumes (1.65s)
ok  	github.com/Silo-Server/silo-server/internal/playback	1.772s

Risks

  • Only with the setting on, which is off by default. With it off, every path behaves as on main.
  • A jellycompat resume's source-aligned playlist puts one gap segment before the plan, so EXT-X-TARGETDURATION rises to the resume position. Not tested with a jellycompat client.
  • Node API: the start request and response gain keyframe_plan_resume. An older node omits it in its response; older nodes never plan a resume, so the recipe correctly records none. Moving a planned resume to an older node fails the move's attestation check, the same way a node that ignores keyframe_playlist does. A resume that planned and is rebuilt after its file's index was rejected now fails with ErrKeyframePlanChanged, so its player starts a new session, rather than getting mismatched segments.
  • A plan that doesn't match FFmpeg's cuts rejects the file version, as for any planned session (feat(playback): restart keyframe-planned copy streams mid-stream #1770), and later plays fall back to FFmpeg's playlist.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code (desktop app)
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Serve resumed copy transcodes from a complete keyframe playlist

  • A copy stream resumed at a resolved seek anchor now gets a keyframe segment plan built from the keyframe at or before the resume origin (within a 0.1s tolerance, rejected if ambiguous), planned through to the video's end in copy_keyframe_plan.go
  • The session keeps the originally requested seek position separate from FFmpeg's adjusted seek, and manifests, segment lookup, recipe options, and restarts use the plan's stream origin (transcode.go)
  • The resume-plan flag propagates through KeyframePlanResume in recipe cards, stream-token claims (kfpr), the transcode-node API (request, response, attestation validation), and the OpenAPI schema
  • resolveCopyPlan keeps FFmpeg's playlist for rebuilt resumes whose recipe says the original run did not plan, but fails with ErrKeyframePlanChanged when a resume must reproduce a plan and planning fails
  • The copy group assembler discards groups produced before a resume plan's first keyframe
  • Behavioral Change: rehomeStartRequestV3 now requests keyframe planning on rehome only when the recipe records the original run planned the resume; resumes that must plan but cannot (keyframe index unavailable) now fail instead of falling back to FFmpeg's playlist

Macroscope summarized 14c731b.

…laylist

With Complete playlists for copied video on, only a copy stream that
started at 0:00 got the planned VOD playlist. A resume still got FFmpeg's
growing playlist, which Safari's native player can fall back to a partial
copy of and stop mid-episode (Silo-Server#1466).

A resume whose copy seek anchor was resolved to a keyframe now plans its
segments from that keyframe to the end. The plan keeps every keyframe of
the file, so the groups of a run whose seek lands earlier still place, and
those before the first segment are dropped. The first run starts at the
plan's first segment the way a restart for it does. The stream origin the
handler gave the player doesn't change, and the source-aligned playlist
still carries the gap before it. A start no keyframe is near keeps
FFmpeg's playlist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 16, 2026
@silo-kody

silo-kody Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish labels Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

Copy playback can create keyframe-planned sessions for resolved resumes. These sessions preserve the requested position, start at a matching source keyframe, align playlists and segment lookup to the source timeline, and discard pre-plan groups during assembly. Tests cover planning, reconstruction, restart behavior, playlist alignment, and decoding.

Changes: Copy Playback Resume

Layer / File(s) Summary
Plan segments from the resume keyframe
internal/playback/copy_keyframe_plan.go, internal/playback/copy_keyframe_resume_test.go
Resolved resumes can use a plan when their origin matches a source keyframe within 0.1 seconds. Planning validates the video end, starts from the matching keyframe, and persists resume status in plan records. Tests cover origin matching, fallback behavior, and plan reconstruction.
Carry resume-plan state through sessions
internal/playback/transcode.go, internal/playback/recipecard.go, internal/streamtoken/token.go, internal/transcodenode/server.go, internal/api/handlers/playback_transcode_rehome.go, internal/api/handlers/playback_transcode_rehome_resume_test.go, internal/api/handlers/playback_v3.go, internal/jellycompat/handlers_playback.go
Sessions preserve the requested resume position and plan origin. Recipe cards, stream-token claims, transcode-node requests and responses, and rehome requests carry the resume-plan choice.
Align and assemble resumed output
internal/playback/transcode.go, internal/playback/copy_group_assembler.go, internal/playback/copy_keyframe_resume_test.go, docs/transcode-node-api.md
Resume playlists include the source-time gap, and segment lookup uses the plan-relative position. Assembly drops groups before the plan’s first keyframe and reports progress before its first segment. Tests cover playlist alignment, assembly, restart behavior, and decoding. The API documentation describes resume-plan eligibility and reconstruction.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ResumeRequest
  participant planCopySegments
  participant TranscodeSession
  participant FFmpeg
  participant copy_group_assembler
  participant Playlist
  ResumeRequest->>planCopySegments: Provide resolved origin and keyframes
  planCopySegments-->>TranscodeSession: Return plan from matching keyframe
  TranscodeSession->>FFmpeg: Start at first planned segment
  FFmpeg->>copy_group_assembler: Provide keyframe groups
  TranscodeSession->>Playlist: Align planned playlist to source timeline
Loading

Possibly related issues

Possibly related PRs

  • Silo-Server/silo-server#2515: Both PRs use the copy keyframe index and its planning contract. This PR plans resumed playback from a keyframe at or before the resolved origin.

Suggested reviewers: quick104

Merge Risk: Moderate · up to 4864b

Moving a resumed copy stream to an older transcode node can silently succeed while that node serves a different segment layout than the recipe records. A later rebuild could then change the content behind URLs the player already holds. Add the resume attestation check to the move validation before merging. A minor documentation wording fix is also pending.

Security architecture risk: Low · up to 4864b

Existing access controls remain in place. With the optional playlist feature enabled, mixed-version deployments or an unreadable recovery record can substitute an incompatible segment layout during recovery. The supported impact is limited to affected playback sessions.

Retained concerns

  • Medium · reliability · inferred: Resume-plan compatibility is not enforced across mixed versions. A new node can plan a fresh resume for an old API, which cannot preserve the new decision; after record removal, reconstruction selects FFmpeg’s incompatible playlist. Conversely, rehome can accept a pre-PR node that ignores keyframe_plan_resume, refuses resume planning, but echoes the older keyframe_playlist field. The current attestation accepts that response and permits the route change. Both transitions can change segment identity within an active playback rather than contain the incompatibility as a failed recovery.
  • Low · reliability · observed: An unreadable or inconsistent existing plan record returns a successful FFmpeg-playlist fallback before KeyframePlanResume is checked. Newly planned resumes therefore bypass their required-plan recovery behavior in this partial-failure state, although missing-record failures correctly reject an unavailable plan. The fallback predates this PR, but planned resumes are newly exposed to it. Atomic record publication reduces the likelihood; no attacker-controlled corruption path was established.
Security review details

Security Blast Radius

  • inferred — The supported failure scope is the playlist and segment identity of an affected copy-playback transport. The inspected flag flow establishes no additional user identity, source selection authority, or cross-session output path.

Trust Boundaries and Controls

  • observed — Token reconstruction verifies the signature and binds the claimed session ID before decoding the recipe. Node start requests require a signature checked against the destination node’s key, validate session IDs, and open the granted source before creating playback state. Rehome obtains a source grant for the replacement node.

Resilience and Maintainability Implications

  • inferred — The retained concerns concern recovery containment, not a demonstrated authentication bypass. Required resume plans can silently downgrade across version skew or an unreadable existing record. Ordinary missing-record failure handling and serialized reconstruction are counterevidence, but do not cover those branches.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a resumed copy stream is now served from a complete keyframe playlist under the copy_keyframe_playlist setting. The changeset matches this. The summary covers planning…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is specific and on-topic. It names the copy_keyframe_playlist setting, the resume planning change, and the affected files and functions (planCopySegments, rehomeStartRequestV3, Keyfram…
Full details: Title check

Explanation

The title names the main change: a resumed copy stream is now served from a complete keyframe playlist under the copy_keyframe_playlist setting. The changeset matches this. The summary covers planning from the resume keyframe, the restart seek, and the resume flag across rebuilds.

Full details: Description check

Explanation

The description is specific and on-topic. It names the copy_keyframe_playlist setting, the resume planning change, and the affected files and functions (planCopySegments, rehomeStartRequestV3, KeyframePlanResume, docs/transcode-node-api.md). It also gives validation evidence, risks, and a before/after test log. The changeset matches this description.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment thread internal/playback/copy_keyframe_plan.go Resolved
Comment thread internal/playback/copy_keyframe_plan.go Resolved
Comment thread internal/playback/copy_keyframe_plan.go Resolved
Comment thread internal/playback/transcode.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b28e4d4c-138a-4964-8a7c-3cc8cbb50a44
Commits

Reviewing files that changed from the base of the PR and between 8f93594 and 3413284.

Files selected for processing: 4

  • internal/playback/copy_group_assembler.go
  • internal/playback/copy_keyframe_plan.go
  • internal/playback/copy_keyframe_resume_test.go
  • internal/playback/transcode.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread internal/playback/copy_keyframe_plan.go Resolved
Comment thread internal/playback/transcode.go Resolved
…t across rebuilds

Review fixes for the resumed keyframe playlist:

- The resolved origin trails its keyframe by up to a B-frame delay and
  never leads it, so take the latest keyframe at or before it. The nearest
  one could be a later keyframe.
- Mark a resume on the plan and its record rather than infer it from the
  first segment's keyframe. Audio that starts before the video gives a
  resume at the first keyframe a positive origin, and it still needs the
  resume's start.
- A rebuilt resume without a plan record keeps FFmpeg's playlist. Its first
  start may have served that playlist after a failed start probe, and a
  resume's plan numbers and cuts segments differently.
- The FFmpeg test measures the resumed output with ffprobe, in all and in
  its last segment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/L 200–499 added + deleted lines (all files); change volume, not priority. labels Nov 16, 2026
@silo-kody

silo-kody Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment thread internal/playback/copy_keyframe_plan.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 352dd12f-cbc8-4a87-a361-3f39506a71b7
Commits

Reviewing files that changed from the base of the PR and between 3413284 and d99bc21.

Files selected for processing: 2

  • internal/playback/copy_keyframe_plan.go
  • internal/playback/copy_keyframe_resume_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Comment thread internal/playback/copy_keyframe_plan.go Resolved
A clean shutdown removes the output directory and its plan record. A
resume rebuilt after one kept FFmpeg's playlist, so a player that had the
planned playlist got segments it didn't list.

A rebuilt resume without a record now plans again, like any other
session. Instead, a resume whose first start falls back on a failed start
probe records that it isn't planned, so its rebuilds keep FFmpeg's
playlist. One case stays open: a failed probe followed by a clean
shutdown before the rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bdcb21d2-3af5-4b9e-ae9e-edf59dcd9edf
Commits

Reviewing files that changed from the base of the PR and between d99bc21 and 49a75af.

Files selected for processing: 2

  • internal/playback/copy_keyframe_plan.go
  • internal/playback/copy_keyframe_resume_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Comment thread internal/playback/copy_keyframe_plan.go Resolved
…'s origin

A resume's plan starts at the keyframe at or before its origin, which
trails that keyframe by up to a B-frame delay. Keyframes closer together
than that both fit, and the origin doesn't say which one the stream starts
at. Such a resume now keeps FFmpeg's playlist rather than guess.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

A resume's plan numbers and cuts segments differently from FFmpeg's
playlist, so a rebuild has to make the decision the first start made. The
plan record that held it lives in the output directory, which a clean
shutdown removes. A resume rebuilt after one could switch playlists. The
same happened to a resume started on a build that never planned one and
rebuilt on this one after a restart.

The decision now travels with the recipe as KeyframePlanResume:

- A session that starts a resume's plan sets it on its options, so the
  local recipe, jellycompat's recipe and the node's start response
  (keyframe_plan_resume) carry it. The recipe card and stream token keep it.
- A rebuilt resume without it keeps FFmpeg's playlist. One with it plans
  again, and fails with ErrKeyframePlanChanged when it can't.
- A resume moved to another node asks for a plan only when it planned, and
  then requires one.

This replaces the record written after a failed start probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8623af98-ef5b-41af-90fd-7d048ec8f9f7
Commits

Reviewing files that changed from the base of the PR and between 4b3d193 and 4864bf0.

Files selected for processing: 11

  • docs/transcode-node-api.md
  • internal/api/handlers/playback_transcode_rehome.go
  • internal/api/handlers/playback_transcode_rehome_resume_test.go
  • internal/api/handlers/playback_v3.go
  • internal/jellycompat/handlers_playback.go
  • internal/playback/copy_keyframe_plan.go
  • internal/playback/copy_keyframe_resume_test.go
  • internal/playback/recipecard.go
  • internal/playback/transcode.go
  • internal/streamtoken/token.go
  • internal/transcodenode/server.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Comment thread docs/transcode-node-api.md Resolved
Comment thread internal/api/handlers/playback_v3.go Resolved

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 4864bf0. The approach holds: planning from the resume keyframe keeps the handler's timeline contract, and both TestPlanCopySegmentsForAResume and TestPlannedCopySessionResumes fail on main and pass here. Two findings are already raised in open threads, and I'm replying there. One more has no diff line:

CI: contracts/api/v2/openapi.json is stale (blocks merge). keyframe_plan_resume joins the node start request, the start response and the recipe schema, so Go vet and contracts (verify-apiv2-openapi) and Go test (TestCommittedArtifactMatchesRouter) both fail. The repair is make apiv2-openapi, which adds the field to those three schemas and nothing else. I'm committing the regenerated artifact on this branch, so there's no need to change it yourself.

🤖 Claude Code (claude-opus-5-5)

Quick104 and others added 2 commits November 17, 2026 03:24
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sume's keyframe plan

A node built before keyframe_plan_resume echoes keyframe_playlist but
ignores the resume flag and serves FFmpeg's playlist, whose segment numbers
the moved player can't use. The keyframe playlist attestation now also
requires the resume echo when the request carries it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 14c731b (the author's 4864bf0 plus two review-fix commits)

Fit: 8/10 · Readiness: 8/10 — conditional (assuming CI is green)

Fit. This fixes a playback failure in the core experience (#1466: Safari can stop mid-episode on FFmpeg's growing playlist), and it keeps the player's timeline contract, so no client changes. It stays behind the experimental, off-by-default setting. What holds the score down is cost: the resume decision now threads through the recipe card, the stream token, the node's start request and response, jellycompat and the move path, a new contract field the node API has to keep.

Readiness. TestPlanCopySegmentsForAResume and the real-FFmpeg TestPlannedCopySessionResumes fail on main (no plan; the session serves FFmpeg's growing playlist) and pass here, with this host's FFmpeg as well as the author's. The remaining condition is the one the PR states: no real player has played a planned resume, and Safari is the client the change exists for.

Addressed in this review

  • Stale OpenAPI artifact (failed Go vet and contracts and Go test): regenerated in 9ffa1e3.
  • A planned resume could move to an older node that echoes keyframe_playlist, ignores keyframe_plan_resume, and serves FFmpeg's segments under the plan's numbering. The keyframe playlist attestation now requires the resume echo as well (14c731b). A regression case in TestValidateKeyframePlaylistAttestation failed before the fix.
  • Node API doc wording: a resume's plan starts at the selected keyframe, and the recipe keeps the first run's start position (14c731b).

Left for the maintainers

  • The origin can lead its keyframe. ResolveCopySeekAnchor reports the first packet FFmpeg's copy emits, and its own comment says that at an exact keyframe boundary that can be the packet before the keyframe. resumeKeyframe then lands on the previous keyframe, which is normally more than 0.1 s away, so the resume keeps FFmpeg's playlist. That is a missed improvement, not a wrong plan. It only happens when the resume position falls exactly on a keyframe.
  • Not covered by tests, as the PR says: a real node's keyframe_plan_resume echo, a rebuild from a saved recipe after a restart, and jellycompat clients with the gap segment before the plan.

Validated features

The setting is off by default, and with it off every path behaves as on main. With it on, the copy-remux cases the PR names (#1250 C5, #1252 C3 and C5, #1246 C1) can be reached by a resumed copy stream. None was re-run here; a validator should re-check them with the setting on once this merges.

User manual

siloserver.org#198 already tracks documenting Complete playlists for copied video. Its eligibility list says a planned playlist needs a start at the beginning; once this merges, that issue should add resumes at a resolved anchor. No new docs issue is needed.

Other clients

Server-only. The player's stream origin and seek window don't change, so Apple, Android, Roku and web need nothing new.

🤖 Claude Code (claude-opus-5-5)

@Quick104
Quick104 merged commit 92763e4 into Silo-Server:main Nov 17, 2026
24 checks passed
Quick104 added a commit to rangoDJ/silo-server that referenced this pull request Nov 17, 2026
Resolve conflicts with Silo-Server#4400, which added KeyframePlanResume beside this
branch's KeyframePlanned in the transcode options, recipe card, node start
response, and the jellycompat recipe. Both fields are kept. The node API doc
keeps Silo-Server#4400's resume conditions and describes the audio switch restart for a
session planned from the beginning. The OpenAPI contract is regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants