Repository navigation
Conversation
…on-keyframes FFmpeg 8.1 and later stop a run with exit 69 when a decoder's errors exceed two thirds of its errors and returned frames together. A frame that -skip_frame skips counts as neither, so a keyframes-only read of a window whose non-keyframes are damaged failed although every keyframe decoded. The credits tail pass then failed on such files and was retried every week. Every read that passes -skip_frame:v now also passes -max_error_rate 1. Closes Silo-Server#5558
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:
|
A hardware attempt falls back to software only when it fails. With the limit lifted, a GPU that fails decode frame after frame on FFmpeg 8.1 or later would exit 0 with few or no frames, and the credits tail would store that as a sparse tail until the file changes. Lift the limit only on software attempts, so the hardware attempt still fails over; a damaged file reaches the software attempt the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quick104
left a comment
There was a problem hiding this comment.
Review of a2f37cf. The fix holds: with the release image's jellyfin-ffmpeg 8.1.3, the new real-FFmpeg test fails on the merge base with exit 69 and passes on this branch, and a sandbox built from the base reproduced the credits-tail failure on a damaged episode. One finding below, which I'm fixing in a commit on this branch, so there's no need to change it yourself.
🤖 Claude Code (claude-opus-5-5)
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:
|
Build the Sheets list and window arguments through buildSheetsArgs, so a call site that passes the wrong attempt fails the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| if attempt.Hardware { | ||
| return []string{skipFrameOption, skip} | ||
| } | ||
| return []string{"-max_error_rate", "1", skipFrameOption, skip} |
There was a problem hiding this comment.
Damaged keyframes are silently accepted as successful video samples
Damaged keyframes can produce incomplete frame statistics while the sample is reported as successful. Distinguish required keyframe decoding failures from errors in skipped non-keyframes before accepting the result.
Prompt for LLM
File internal/mediasample/concat.go, line 72:
Damaged keyframes are silently accepted as successful video samples
The software attempt also accepts decoding failures in keyframes, so a file with some damaged keyframes returns incomplete frame statistics as a successful sample instead of taking the existing failure path. Distinguish failures of required keyframes from errors in skipped non-keyframes before accepting the result.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
FFmpeg's error-rate check can't separate the two cases: it counts every decode error a decoder reports, keyframe or not, against every frame it returns. So before 8.1 enforced it, and on main today whenever errors stay under two thirds, a window with some damaged keyframes already returns its surviving frames as a success. The callers have their own guards for thin results, and those don't depend on the exit status. The credits tail stores a window with fewer than one keyframe per 30 s as sparse (tailUnusableAfterSampling). Sheets fail with ReasonEmpty when nothing decoded or too many cells had to be filled (sheetAssembler.finish). A window whose keyframes all fail still exits non-zero with invalid data. A per-keyframe check would need a different signal than this limit, so I'm leaving it out of this PR.
🤖 Claude Code (claude-opus-5-5)
There was a problem hiding this comment.
That explanation addresses my concern. The error-rate limit cannot distinguish damaged keyframes from damaged skipped frames, and the existing caller guards reduce the risk of accepting unusably sparse results. I agree that a per-keyframe check would require a different signal and can be considered separately.
The remaining tradeoff is that partially damaged keyframe output can now be accepted in cases where FFmpeg 8.1 would previously have stopped the run. Given the documented behavior and guards, I would not block this PR on that concern.
Review summaryReviewed head: ce88bd9 Evidence: https://evidence.siloserver.org/r/silo-server/pr-5604/ Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green) The fix holds. On an isolated sandbox with the release jellyfin-ffmpeg 8.1.3, a damaged episode's credits tail and credits fingerprint failed with exit 69 on the merge base, and the season stayed partial. Rebuilt from this branch with the same database, both complete, the season completes, and the episode gets a credits marker. The new real-FFmpeg test fails on the base with exit 69 and passes here under 8.1.3. Addressed
Left for the maintainers
Checks
Council
ce88bd9 changes only the new test, as round 2 asked. Fit is 9 because this repairs a core 1.0 analysis path at the boundary where FFmpeg's behavior changed, without new settings or surface. Readiness is 8 because the audio decision above is still open. With it accepted, nothing else blocks. 🤖 Claude Code (claude-opus-5-5) |
Problem
Closes #5558
Related issue: N/A
Validation tasks: none passed that this reaches; it touches credits detection, which #1148 C1 tests (open, failed on #4275)
Other clients: N/A (no client-visible change)
On FFmpeg 8.1 and later, which the release image ships, the credits tail pass fails with exit 69 on episodes whose non-keyframe video packets are damaged near the end. The tail and the credits fingerprint are stored as failed, the season stays partial, and Silo decodes the tail again every week without ever getting credits markers for those episodes. This change lets the pass keep the keyframes, silences and fingerprint it decoded.
Approach
FFmpeg 8.1 started enforcing
-max_error_rate(default 2/3): a decoder whose failed packets exceed two thirds of failed packets plus returned frames stops the run. A frame that-skip_frame nokeyskips counts as neither, so a keyframes-only read of a window with a few hundred damaged non-keyframes reports a rate near 0.9, while a full decode of the same window stays far under the limit.Every software attempt of a sampling read that passes
-skip_frame:v(keyframes-only windows, Samples lists, Sheets) now also passes-max_error_rate 1, which turns the check off. The result is the behaviour Silo had with FFmpeg 7.1, where the check never fired. Hardware attempts keep the limit: the credits tail and trickplay run software only after a hardware attempt fails, so a GPU that fails decode frame after frame must still fail its attempt. A damaged file on a hardware host fails the hardware attempt with exit 69 and then succeeds in software. Rows that already failed pick this up on their next scheduled retry; no analysis version bump is needed.The option is global, so it also stops audio decode errors from failing the run. A tail window whose audio is entirely undecodable (file 10260 in the issue) now succeeds with video statistics and an empty fingerprint, which the analyzer stores as having no audio, instead of being retried every week. A window with partly damaged audio gives a shorter fingerprint, as it already did below the 2/3 limit. The other options the issue lists (classifying exit 69, keeping partial output of a failed run, or splitting audio and video into separate reads) need more changes and a second decode, so I left them out.
Validation
internal/mediasampleand its dependents (intromarkers,trickplay,chapterthumbs,transcodenode,proxy,subsync,taskmanager/tasks): pass with the host FFmpeg 8.0.1 and with the release image's jellyfin-ffmpeg 8.1.3.TestKeyframeReadsLiftErrorLimitOnlyInSoftwarebuilds the window, Samples, Sheets-list and Sheets-window arguments for software and hardware attempts and checks that only software attempts lift the limit. It fails on a2f37cf, before the hardware split.go build ./...,gofmt,go mod tidy -diff,go vet ./...,make lint-changed(0 issues),verify-local-paths,verify-size-ratchet,verify-bidi,verify-case-collisions: pass.make test-gowith a test database (no DB code changed), and the Web half (no web change).Evidence
Local build with the release image's jellyfin-ffmpeg 8.1.3. A series library with three synthetic 600 s H.264/AAC MP4 episodes; in S01E01 (file 2) the NAL length prefix of the last 300 non-key video packets is overwritten, as in the issue's recipe.
POST /api/v2/admin/tasks/detect_intro_markers/run, then a second run after moving the season'sanalyzed_atback 8 days and the failed rows'retry_afterinto the past (the weekly revisit).Before,
origin/mainat 5d0006f, second run:After, this branch, same database and steps:
Files 1 and 3 (undamaged) and every intro fingerprint stay as they were; no "credits tail pass failed" line is logged.
Risks
FFmpeg no longer stops a keyframes-only read on decode errors, so a badly damaged file decodes its whole window instead of stopping early. The window is already bounded by its duration and attempt timeout. Undecodable tail audio is stored as no audio rather than retried. On a host with hardware decoding, a damaged file decodes its window twice: once in the hardware attempt that fails, then in software.
Checklist
Council review
Rounds: 2, last reviewed 807b4a8 (ce88bd9 after it changes only the new test, as round 2 asked)
Fixed: hardware attempts kept the lifted limit and lost their software fallback (807b4a8); the argument test now covers every builder (ce88bd9). Answered: a fully undecodable video window fails with invalid data before and after this change. Left for the maintainers: undecodable audio shifts the credits fingerprint's later points earlier (main already does this below the two-thirds limit; this branch extends it to combined tail runs above it), and trickplay window reads carry the last image across keyframes that fail to decode (also already on main below the limit).
AI Disclosure
Note
Fix keyframes-only media sampling failing on damaged non-keyframes
decode-error-limitoverride before the skip-frame option; hardware attempts keep the skip-frame option alone.skipFrameArgshelper in concat.go.Macroscope summarized ce88bd9.