You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(playback): decode on the CPU when VA-API or QSV can't decode the source - #4478
Closes#4319
Related issue: #4279, #402
Validation tasks: changes #1174 C2; changes #1173 C2
Other clients: N/A (no client-visible change; the server now starts the transcode the client already asked for)
With Hardware acceleration set to VA-API or QSV, a transcode fails to start when the GPU can't decode the source video, and Silo never falls back to decoding on the CPU. Two reports show it:
This change plans WMV1/WMV2 and the Microsoft MPEG-4 variants on CPU decode from the start, and lets the existing start-path CPU-decode retry (#4057) recognise both VA-API/QSV failures. VA-API and QSV still encode on the GPU in both cases.
The start-path markers that mark a failure as ErrHardwareDecodeUnsupported gain FFmpeg's AV1 line and Impossible to convert between the formats supported by the filter. The second is what a GPU-decoded QSV or VAAPI start prints when no hardware decoder took the source, so it also covers codecs or profiles the list above doesn't name. This closes the "ready-gated start" gap fix(playback): restart Intel transcodes on CPU decode after a filter graph failure #4105 left for its filter-graph rule. The retry is still gated by HardwareDecodeRetryEligible (GPU decode, no tone mapping, not video copy). I left out the generic Failed setup for format vaapi line for the same reason fix(playback): decode on the CPU when the GPU decoder rejects the source #4057 left out the CUDA one: FFmpeg prints it for other init failures and then carries on in software.
When FFmpeg's AV1 decoder prints that line on a command that asked for GPU decoding, Silo kills FFmpeg's process group straight away (the configured FFmpeg path can be a wrapper script). The same text anywhere else, such as an input path FFmpeg echoes in an error, doesn't count. No frame can follow, and the exit is then classified like any other decoder rejection, so explicit backends take the CPU-decode retry and Auto moves to its next stage without waiting for the end of the file. Every caller (local v3 starts, transcode nodes, reconstructs, jellycompat, download preparation) already handles that exit.
Review follow-ups: download preparation watches a GPU-decode command for the same line, so its CPU-decode retry also runs without reading the whole file first. A session FFmpeg was stopped in restarts on CPU decode (exit monitor and segment restarts), as one whose filter graph failed already does. The stop skips the kill once FFmpeg has been reaped, so it can't signal a reused process group.
One PR rather than two: both issues are the same gap (VA-API can't decode codec X, so decode on the CPU), and both changes edit the same marker list.
A per-GPU decode probe would avoid the one failed AV1 attempt on GPUs without AV1 decode. That is a much bigger change (fixtures, cache, multi-node), so I left it out; the failed attempt now costs well under a second.
go test ./internal/playback/: the new tests pass. 14 other tests fail on this Mac (hardware probe, VideoToolbox and real-FFmpeg tests) and fail the same way on main; CI is the check for those.
Focused runs of ./internal/jellycompat/, ./internal/api/handlers/ (decode and transport tests), ./internal/transcodenode/ and ./internal/mediasample/: pass.
The new and existing startup, reconstruct and restart tests pass under -race. gofmt and go vet ./internal/playback/: clean.
Review follow-ups (Linux): TestPrepareFileStopsAV1DecodeTheGPUCannotRun and the new AV1 row in TestLocalExitMonitorRestartsFilterReinitFailureOnCPUDecode fail on the previous head and pass now. go test ./internal/playback/ ./internal/downloads/ ./internal/transcodenode/ ./internal/jellycompat/ passes, and make lint-changed reports 0 issues.
No VA-API or QSV hardware run was possible. I don't have an Intel GPU; the FFmpeg behaviour comes from real FFmpeg runs on macOS described under Evidence.
Captured on macOS from main at 651e55a and this branch at 17b3a01 (the follow-up commit only narrows which line stops FFmpeg). There's no VA-API here, so:
The same two graph shapes on real FFmpeg 9.0.2 with VideoToolbox standing in for VA-API and a generated WMV2 ASF clip. The GPU-frame shape fails with the issue's exact error chain and writes no segment. The CPU decode and upload shape writes 11 HEVC 1080p hvc1 segments.
Startup logs for the three startup test cases. On main: one attempt each, then failure (the AV1 starts wait out the full 10 s test wait). On this branch: FFmpeg is stopped within a second, and the next command decodes on the CPU with the same encoder.
Risks
A GPU-decoded QSV or VAAPI start that fails on a filter-format mismatch for some other reason now gets one CPU-decode attempt, then software, before it fails. Those starts were failing anyway.
On a host with two GPUs where only the other one can decode the source, the decoder-rejection retry now goes to CPU decode on the same GPU before the other-device retry would have tried the second card. The NVDEC marker already works this way.
WMV and MS-MPEG-4 transcodes use more CPU than before (decode and scaling). They didn't play at all under VA-API or QSV before, and FFmpeg was decoding them on the CPU anyway. With an explicit NVENC setting they encode on libx264, as H.264 High 10 does.
If FFmpeg ever printed the AV1 line mid-stream (after a sequence header change), the session would stop there and restart on CPU decode.
A queued WMV or MS-MPEG-4 download whose job froze an execution fingerprint before this change fails once after the upgrade ("frozen execution recipe no longer matches source metadata"), because the fingerprint now records CPU decode. Requesting the download again works.
An HDR AV1 source that needs tone mapping isn't eligible for the CPU-decode retry, so it still fails on these GPUs, now quickly instead of after the wait.
A community tester confirmed the AV1 fallback on Intel QSV hardware (CPU decode, hevc_qsv encode, about 100 ms after the first attempt). The WMV2 path hasn't been run on Intel hardware.
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.
Council review
Rounds: 2, last reviewed 147cfbe (the final head adds only the round-2 polish: the kill right after the reap check, the download watcher limited to GPU-decode commands, and log and comment wording)
Member
Round 1
Round 2
Sol (gpt-6.2-sol, xhigh)
6/10
7/10
Opus (claude-opus-5-5, high)
8/10
8/10
Gemini (gemini-4-neon, xhigh)
6/10
8.5/10
Fixed: the early AV1 stop for download preparation, the CPU-decode restart after an AV1 stop, the kill after the reap, the zombie-unaware test check, and doc and comment accuracy. Answered: the two-GPU retry order, the broad filter-format marker, libx264 under explicit NVENC, and the one-time failure of queued WMV downloads are left for the maintainers (see Risks). Visual review: none, since nothing a user sees changed.
AI Disclosure
Harness: Claude Code (Claude desktop app, Code tab)
Tool(s): Claude Code
Model(s): claude-opus-5-5
Involvement: AI-assisted. AI-assisted with Claude Opus. I directed the task and designed the work.
Adversarial review: a separate Claude Opus subagent reviewed the diff for races, locking, kill and retry behaviour, marker misclassification, backend effects and test quality. It found one bug: the early stop killed only FFmpeg's direct process, so under a wrapper script the real FFmpeg kept reading the file outside the device allocator. It now kills the process group, and the startup test checks a wrapper-style child is gone. Its other notes (the two-GPU retry order, libx264 under explicit NVENC, a mid-stream AV1 line, download preparation) are listed under Risks. The maintainer review is under Council review.
Note
Stop FFmpeg and retry with CPU decode when GPU decode of the source fails
When a -hwaccel FFmpeg run reports the AV1 hardware-decoder rejection, ffmpegStderrWriter.stopOnHardwareDecodeUnavailable kills the process group so playback does not wait for FFmpeg to read the whole input. Only the AV1 decoder's own line on a GPU-decode command triggers the stop; CPU-decode commands and unrelated lines are ignored.
playback.gpuDecodeFailedFilterSetupLocked now also classifies the AV1 rejection (and a filter-format conversion failure) as unsupported hardware decoding, so eligible QSV/VAAPI sessions retry with CPU decode and GPU encode.
playback.RequiresSoftwareVideoDecode returns true for codecs with no hardware video decoder (WMV1, WMV2, and listed Microsoft MPEG-4 variants; WMV3 excluded), checked before the existing profile and bit-depth rules.
playback.newStderrWriter and playback.PrepareFile pass the FFmpeg command to the stderr writer so both initial and restarted processes can be stopped. Architecture docs in restart-resilient-playback.md and worker-http-protocol.md are updated.
Risk: the stop match in stopOnHardwareDecodeUnavailable depends on the exact ffmpegAV1HardwareDecodeUnavailable text and ffmpegAV1DecoderLogPrefix in transcode_startup.go; changes in FFmpeg's message wording would silently disable the kill.
… source
Windows Media Video 7 and 8 and the Microsoft MPEG-4 variants have no GPU
decoder in FFmpeg, so they are now planned on CPU decode. VA-API, QSV and
VideoToolbox keep their GPU encoder through the upload graphs; an explicit
NVENC setting encodes them on libx264, as it does H.264 High 10 (Silo-Server#4319).
The start-path CPU-decode retry now also runs when FFmpeg reports that its
AV1 decoder has no GPU to run on, or that the hardware-frame graph cannot
take CPU-decoded frames. The AV1 decoder has no software path and reads
the whole input before exiting, so FFmpeg's process group is stopped as
soon as it prints that line (Silo-Server#4279).
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.
No actionable comments were generated in the recent review.
Walkthrough
Playback startup and preparation now recognize additional hardware-decoder failures and retry eligible transcodes with CPU decoding. The changes also identify more codecs that require software decoding and stop FFmpeg promptly for a specific AV1 hardware-decoder rejection.
Changes: Playback startup fallback
Layer / File(s)
Summary
Software decoding for unsupported codecs internal/playback/transcode.go, internal/playback/transcode_args_test.go, internal/playback/transcode_startup_test.go
WMV1, WMV2, and Microsoft MPEG-4 variants now require software video decoding. Tests cover codec eligibility and verify WMV2 VAAPI arguments use CPU decoding with an upload filter, without VAAPI decoder options.
Hardware-decoder rejection and process stopping internal/playback/transcode_startup.go, internal/playback/transcode.go, internal/playback/transcode_startup_test.go
Startup detection includes AV1 hardware-decoder rejection and filter-format conversion failure. For a GPU-decode command with the specific AV1 rejection, the stderr writer stops the process group once. Restart detection also recognizes the AV1 rejection as a CPU-decode retry reason. Tests cover when the stop condition applies.
Tests cover CPU-decode retries, retained GPU encoding, and stopping a lingering process. Preparation passes stderr through the rejection-handling writer. The documentation describes fallback conditions and the retry sequence.
This change makes WMV1, WMV2 and Microsoft MPEG-4 sources, and AV1 sources the GPU cannot decode, fall back to CPU decoding while keeping GPU encoding, instead of failing at startup. The visible changes show no concrete regression, and the tests cover the fallback conditions. The remaining caveats are the unverified WMV2 path on Intel hardware and the dependence on FFmpeg's message text. Neither blocks merging.
Security architecture risk: Low · up to 6a725
The fallback should recover more playback and download attempts. There is a narrow risk that an early stop could terminate an unrelated process on the same machine if the operating system reuses the original process-group ID at the wrong moment.
Retained concerns
Low · security · inferred: The new Unix early-stop path checks that the FFmpeg leader is live, then signals its group by numeric ID. Concurrent reaping leaves a window in which the old group can disappear and its ID can be reused, potentially terminating an unrelated local workload. The liveness check catches an already-reaped leader but does not preserve group identity through delivery of the signal.
Security review details
Security Blast Radius
inferred — The new signal originates on the host running FFmpeg, including download preparation. Any collateral impact is bounded by the executor's local process visibility and signal permissions; isolation between workloads was not verified.
Trust Boundaries and Controls
observed — Media-dependent FFmpeg output can trigger a stop, but the target comes from the command captured at launch, not from text in the diagnostic. Each writer can attempt the stop only once.
Resilience and Maintainability Implications
observed — Download preparation removes failed partial output before retrying and renames the artifact into its final location only after a successful encode and file sync.
Hardening Proposals
proposed — Coordinate early group termination with child reaping so the group ID cannot be recycled before the signal, while preserving cleanup of any wrapper descendants.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(playback): decode on the CPU when VA-API or QSV can't decode the source" matches the main change. The changeset adds CPU decode for WMV1/WMV2/MS-MPEG-4 codecs, recognizes the AV1 hardwa…
Description check
The description explains the problem (VA-API/QSV transcodes fail when the GPU cannot decode the source, with WMV2 and AV1 reports), the approach (codec list for CPU decode, new markers for the retry, …
Linked Issues check
Directly linked issue #4319 has two coding requirements. (1) Fix VA-API startup for WMV2/ASF sources. RequiresSoftwareVideoDecode in internal/playback/transcode.go returns true for wmv1, wmv2, msmpeg4…
Out of Scope Changes check
The AV1 changes serve the same fallback goal as #4319: a GPU decoder cannot decode a codec, so Silo must switch to CPU decode. These include the AV1 marker, the early stop in ffmpegStderrWriter limite…
Full details: Title check
Explanation
The title "fix(playback): decode on the CPU when VA-API or QSV can't decode the source" matches the main change. The changeset adds CPU decode for WMV1/WMV2/MS-MPEG-4 codecs, recognizes the AV1 hardware-decoder rejection and filter-format failures as reasons to retry on CPU decode, and stops FFmpeg early on the AV1 rejection line. The title is concise and specific, and it follows a conventional commit style. It does not mention the AV1 early-stop behavior, but that is a secondary detail.
Full details: Description check
Explanation
The description explains the problem (VA-API/QSV transcodes fail when the GPU cannot decode the source, with WMV2 and AV1 reports), the approach (codec list for CPU decode, new markers for the retry, early FFmpeg stop on the AV1 line, doc updates), validation, risks, and evidence. This matches the changeset directly.
Full details: Linked Issues check
Explanation
Directly linked issue #4319 has two coding requirements. (1) Fix VA-API startup for WMV2/ASF sources. RequiresSoftwareVideoDecode in internal/playback/transcode.go returns true for wmv1, wmv2, msmpeg4v1, msmpeg4v2 and msmpeg4v3/msmpeg4, so these sources use CPU decode with a hwupload graph. transcode_args_test.go adds a WMV2 VA-API argument-shape case. WMV3 and VC-1 stay on GPU decode. (2) On the ready-gated start path, fall back to CPU decode instead of repeating the failing GPU command. The filter-format marker 'Impossible to convert between the formats supported by the filter' is added to hardwareDecodeUnsupportedMarkers in transcode_startup.go, which routes the failure to the existing CPU-decode retry gated by HardwareDecodeRetryEligible. transcode_startup_test.go runs StartReadyTranscode for VA-API node, VA-API local and QSV node starts with the issue's stderr text. An incremental diff of transcode_startup.go from the previous reviewed head to the current head is empty, so the marker logic is unchanged since the prior review. Limits: I did not run the tests. No VA-API or QSV hardware run was possible, so real-GPU behaviour is unverified. The build 2405 failure scope is context only.
Full details: Out of Scope Changes check
Explanation
The AV1 changes serve the same fallback goal as #4319: a GPU decoder cannot decode a codec, so Silo must switch to CPU decode. These include the AV1 marker, the early stop in ffmpegStderrWriter limited to GPU-decode commands, the PrepareFile and restart wiring, the restart_locked_test row and the documentation updates. PR #4279 is cited as related, not linked, and its AV1 work is closely tied to the same fallback path. The maintainer-noted trade-offs (two-GPU retry order, broad filter-format marker causing extra attempts, frozen download fingerprints) are behaviour risks, not unrelated changes. Splitting the AV1 work into a separate PR is a scope preference, not a demonstrated unrelated change. The incremental diff of transcode_startup.go is empty, and the diff tool could not return the full incremental diff, so incremental coverage beyond that file is not fully verified.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent 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: c7d5515b-2658-46f6-8191-cd83a3e0c91b
Commits
Reviewing files that changed from the base of the PR and between 3167b59 and 6a7256e.
Files selected for processing: 2
docs/architecture/worker-http-protocol.md
internal/playback/transcode.go
Files skipped from review as they are similar to previous changes: 1
docs/architecture/worker-http-protocol.md
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
…U-decode command
FFmpeg echoes input paths in other stderr lines, so a file named after the message could stop a transcode that was working, including a CPU-decoded one.
The reason will be displayed to describe this comment to others. Learn more.
I tested the fix from PR #4478 on my QNAP NAS using Intel QSV. My test image was based on build-2563 (d4a2117), which already includes PR #3660, with #4478 applied on top.
I forced a 1080p AV1 source to transcode to HEVC at 360p. Before applying #4478, FFmpeg repeatedly reported that hardware AV1 decoding was unsupported, and playback failed to start with QSV. The same source could be transcoded in software.
With #4478 applied, playback started successfully. In the same playback session, the first FFmpeg command used -hwaccel vaapi. Silo detected that hardware AV1 decoding was unavailable, stopped FFmpeg, and launched a second command 107 ms after the first. The second command omitted -hwaccel and used hwupload with -c:v hevc_qsv. The player reported HEVC at 360p with the HW QSV badge.
This confirms that the AV1 fallback works on my setup: the CPU decodes AV1 and Intel QSV encodes HEVC.
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: 06999597-4291-4f75-8547-b62eecf1ad28
Commits
Reviewing files that changed from the base of the PR and between 6515ece and d9b02e0.
Files selected for processing: 6
docs/architecture/restart-resilient-playback.md
docs/architecture/worker-http-protocol.md
internal/playback/transcode.go
internal/playback/transcode_args_test.go
internal/playback/transcode_startup.go
internal/playback/transcode_startup_test.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Review of d9b02e0 (this branch with main merged in; the merge had no conflicts). The approach holds: planning WMV7/8 and MS-MPEG-4 on CPU decode with GPU encode, reusing the existing CPU-decode retry, and stopping FFmpeg's AV1 decoder early is the smallest fix for both reports, and it adds no setting. The new tests fail on main for the reported reasons (WMV2 args, codec list, and all three startup cases) and pass here.
Four findings are on the diff lines below. Two more sit outside the diff:
Download preparation doesn't get the early AV1 stop (low).PrepareFile builds its own stderr chain (internal/playback/prepare_file.go, runOnce), so on a GPU without AV1 decode a download of a large AV1 file still reads the whole input before the CPU-decode retry runs. The PR's Risks section notes this. The GPU reservation stays held for that whole read. The repair is small: add the same line watcher to that chain.
A crashed or seek-restarted session that FFmpeg stopped at the AV1 line restarts on GPU decode again (low).gpuDecodeFailedFilterSetupLocked (internal/playback/transcode.go) only recognises Error reinitializing filters!, so the exit monitor tears such a session down instead of restarting it on CPU decode, and a segment-request restart runs the same -hwaccel command, which gets stopped again. The repair: recognise the AV1 line there too.
I'm fixing all six in commits on this branch, so there's no need to change anything yourself.
Not changed, for the maintainers to weigh (each is already in the PR's Risks section or predates it): on a host with two GPUs, the CPU-decode retry now runs before the other-device retry; the broad Impossible to convert marker gives any filter-format failure up to two extra quick attempts; explicit NVENC encodes WMV on libx264.
Download preparation now watches FFmpeg's stderr for the AV1 decoder's
rejection, as a playback start does, so its CPU-decode retry runs without
reading the whole input first. A session that FFmpeg was stopped in
restarts on CPU decode, as one that failed to set up its filter graph
does, instead of running the same GPU-decode command again.
The stop also skips the kill once Wait has reaped FFmpeg: Wait reaps the
process before it finishes copying stderr, and the group id may then
belong to another process.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mments
The AV1 startup test now uses procgrouptest.RequireExited, which treats an
unreaped zombie as exited, so it passes where PID 1 doesn't reap orphans.
The reconstruct doc says the filter-format line counts whatever caused it,
and the WMV3 comment no longer says every GPU decodes VC-1.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 4 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
Preserve durable media identity and share identity-evidence precedence
Bound decoder throughput trades and share direct-play eligibility
… downloads
The AV1 stop now signals FFmpeg straight after checking it wasn't reaped
and logs afterwards, so the window between the two stays as short as it
can be. Download preparation adds the line watcher only to a command that
decodes on the GPU. The CPU-decode restart log no longer blames the
filter graph when the AV1 decoder was the cause.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewed head: 6a7256e. Since the last review (819f204), the branch gained two merges of main and no other changes. The PR's own diff is the same as the head I reviewed before. I merged the latest main in (no conflicts) and pushed it.
Fit: 9/10 · Readiness: 9/10 — ready
Fit. With VA-API or QSV set explicitly, WMV2 and AV1 files didn't play. This makes them play by reusing the CPU-decode retry Silo already has, and it adds no setting. CPU decode with GPU encode keeps the work low on small Intel boxes. Two choices stretch a little, and the PR explains both: explicit NVENC encodes WMV on libx264, the same rule as H.264 High 10, and a broad filter-format line now triggers the retry.
Readiness. Every new test fails on main for the reported reason and passes here. A community tester confirmed the AV1 fallback on Intel QSV hardware. The WMV2 path hasn't run on Intel hardware, and I couldn't reproduce either report live because the host I reviewed on has no Intel GPU. The validation-board check that couldn't run last time has now run (below). The trade-offs under "Left for the maintainers" are bounded and disclosed, so they don't hold the score down.
Tests on the merged head:go test over playback, downloads, transcodenode, jellycompat and mediasample passes. The stderr, startup, restart and download-preparation tests pass under -race. go vet and gofmt are clean.
CI: all checks pass on 6a7256e. The earlier "Go vet and contracts" failure was a run that stopped partway through one step after 48 minutes; the rerun passed.
Addressed in the last review
Download preparation stops a GPU-decode AV1 attempt at FFmpeg's first rejection line instead of reading the whole file first (TestPrepareFileStopsAV1DecodeTheGPUCannotRun).
A session whose FFmpeg was stopped restarts on CPU decode, from the exit monitor and from segment restarts (new AV1 row in TestLocalExitMonitorRestartsFilterReinitFailureOnCPUDecode).
The early stop skips the kill once FFmpeg has been reaped. The startup test counts an unreaped zombie as exited. Docs and comments were corrected.
Left for the maintainers
Two GPUs, and the broad Impossible to convert marker. On a host with two GPUs, the CPU-decode retry now runs before the other-device retry. Any filter-format failure, audio included, gets up to two extra quick attempts. The PR's Risks section discloses both. Starts that used to fail outright now play.
Queued WMV and MS-MPEG-4 downloads whose jobs froze an execution fingerprint before this change fail once after the upgrade, because the fingerprint now records CPU decode. Requesting the download again works.
These predate the PR and are only noted here:
Download preparation tries the VideoToolbox software retry before the CPU-decode retry.
A Jellyfin remote start with cluster auto and a node that declares its own backend doesn't wait for readiness.
HDR AV1 that needs tone mapping gets no CPU-decode retry, and the tone-map preflight has no early stop.
Validated features
Validation tasks: changes #1174 C2; changes #1173 C2 is accurate. C2 on both tasks covers forced hardware modes and software fallback, and neither has been run yet (C1–C3 on #1173 and #1174 are all not run), so no passed result is invalidated. The two passed cases nearest this code are unaffected: #1155 C2 (chapter thumbnails on a hardware path) doesn't use RequiresSoftwareVideoDecode or the startup retry, and #1177 C3 (worker removal during playback) doesn't involve a decoder rejection.
Other checks
User manual: unaffected. No docs page describes fallback under an explicit backend.
Apple/Android parity: not applicable. This is a server-side change with no client-visible API.
Evidence: the existing page still matches. Merging main doesn't change the WMV2 argument lines or the startup retries it shows.
Council
No new round: the PR's code hasn't changed since round 2 on 147cfbe, and the new commits only merge main.
Member
Round 1
Round 2
Sol (gpt-6.2-sol, xhigh)
6/10
7/10
Opus (claude-opus-5-5, high)
8/10
8/10
Gemini (gemini-4-neon, xhigh)
6/10
8.5/10
Sol's remaining points are the two-GPU and marker trade-off and the queued downloads, both listed above, plus a few-microsecond window between the reap check and the kill. Opus and Gemini consider that window negligible.
Main's AV1 hardware-decode stop (Silo-Server#4478) added fields and a per-line hook to
ffmpegStderrWriter; keep both it and this branch's demux-error flag.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workinggoPull requests that update go codeimpact: playbackCan't play, stalls, or wrong mediapriority: P1Core-path bug; painful workaround — next after P0size/L200–499 added + deleted lines (all files); change volume, not priority.
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #4319
Related issue: #4279, #402
Validation tasks: changes #1174 C2; changes #1173 C2
Other clients: N/A (no client-visible change; the server now starts the transcode the client already asked for)
With Hardware acceleration set to VA-API or QSV, a transcode fails to start when the GPU can't decode the source video, and Silo never falls back to decoding on the CPU. Two reports show it:
-hwaccel vaapiquietly decodes it on the CPU, and the all-VA-API graph (-hwaccel_output_format vaapi,scale_vaapi) can't take system-memory frames:Impossible to convert between the formats supported by the filter ... Error reinitializing filters!. Both transcode nodes gave up, and the local retry ran the byte-identical command.doesn't support hardware accelerated AV1 decodingfor every packet and keeps reading to the end of the file before it exits. On a large file that outlasts the 30 s startup wait, so no fallback runs, even under Auto.This change plans WMV1/WMV2 and the Microsoft MPEG-4 variants on CPU decode from the start, and lets the existing start-path CPU-decode retry (#4057) recognise both VA-API/QSV failures. VA-API and QSV still encode on the GPU in both cases.
Approach
RequiresSoftwareVideoDecodenow returns true forwmv1,wmv2,msmpeg4v1,msmpeg4v2andmsmpeg4v3/msmpeg4. FFmpeg has no VAAPI, QSV, CUDA or VideoToolbox decoder for any of them. They take the same CPU decode andhwuploadgraph that H.264 High 10 already uses, so the [bug] Explicit VA-API: a WMV2 (ASF) file fails at transcode startup on every executor, and the start never falls back to CPU decoding (the start-path gap #4105 lists) #4319 file starts on the first attempt on every executor. As with High 10, an explicit NVENC setting encodes them on libx264. WMV3 is VC-1, which NVIDIA and most Intel GPUs decode, so it isn't listed; a GPU without it takes the marker retry.ErrHardwareDecodeUnsupportedgain FFmpeg's AV1 line andImpossible to convert between the formats supported by the filter. The second is what a GPU-decoded QSV or VAAPI start prints when no hardware decoder took the source, so it also covers codecs or profiles the list above doesn't name. This closes the "ready-gated start" gap fix(playback): restart Intel transcodes on CPU decode after a filter graph failure #4105 left for its filter-graph rule. The retry is still gated byHardwareDecodeRetryEligible(GPU decode, no tone mapping, not video copy). I left out the genericFailed setup for format vaapiline for the same reason fix(playback): decode on the CPU when the GPU decoder rejects the source #4057 left out the CUDA one: FFmpeg prints it for other init failures and then carries on in software.One PR rather than two: both issues are the same gap (VA-API can't decode codec X, so decode on the CPU), and both changes edit the same marker list.
A per-GPU decode probe would avoid the one failed AV1 attempt on GPUs without AV1 decode. That is a much bigger change (fixtures, cache, multi-node), so I left it out; the failed attempt now costs well under a second.
Validation
mainand pass here: the [bug] Explicit VA-API: a WMV2 (ASF) file fails at transcode startup on every executor, and the start never falls back to CPU decoding (the start-path gap #4105 lists) #4319 argument shape for WMV2 on VA-API, the codec list (including WMV3 and VC-1 staying on GPU decode), and a startup test that runsStartReadyTranscodeagainst a fake FFmpeg printing each issue's real stderr, for a VA-API node, VA-API local and QSV node start.go test ./internal/playback/: the new tests pass. 14 other tests fail on this Mac (hardware probe, VideoToolbox and real-FFmpeg tests) and fail the same way onmain; CI is the check for those../internal/jellycompat/,./internal/api/handlers/(decode and transport tests),./internal/transcodenode/and./internal/mediasample/: pass.-race.gofmtandgo vet ./internal/playback/: clean.TestPrepareFileStopsAV1DecodeTheGPUCannotRunand the new AV1 row inTestLocalExitMonitorRestartsFilterReinitFailureOnCPUDecodefail on the previous head and pass now.go test ./internal/playback/ ./internal/downloads/ ./internal/transcodenode/ ./internal/jellycompat/passes, andmake lint-changedreports 0 issues.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-4478/
Captured on macOS from
mainat 651e55a and this branch at 17b3a01 (the follow-up commit only narrows which line stops FFmpeg). There's no VA-API here, so:mainSilo builds the-hwaccel vaapi -hwaccel_output_format vaapiandscale_vaapicommand from the issue's log. On this branch it builds-init_hw_device vaapi ... -vf ...,scale=-2:1080,format=nv12,hwupload -c:v hevc_vaapi, with no-hwaccel.hvc1segments.-hwaccel, FFmpeg pickslibdav1d, which the CPU-decode retry uses.main: one attempt each, then failure (the AV1 starts wait out the full 10 s test wait). On this branch: FFmpeg is stopped within a second, and the next command decodes on the CPU with the same encoder.Risks
hevc_qsvencode, about 100 ms after the first attempt). The WMV2 path hasn't been run on Intel hardware.Checklist
Council review
Rounds: 2, last reviewed 147cfbe (the final head adds only the round-2 polish: the kill right after the reap check, the download watcher limited to GPU-decode commands, and log and comment wording)
Fixed: the early AV1 stop for download preparation, the CPU-decode restart after an AV1 stop, the kill after the reap, the zombie-unaware test check, and doc and comment accuracy. Answered: the two-GPU retry order, the broad filter-format marker, libx264 under explicit NVENC, and the one-time failure of queued WMV downloads are left for the maintainers (see Risks). Visual review: none, since nothing a user sees changed.
AI Disclosure
Note
Stop FFmpeg and retry with CPU decode when GPU decode of the source fails
-hwaccelFFmpeg run reports the AV1 hardware-decoder rejection,ffmpegStderrWriter.stopOnHardwareDecodeUnavailablekills the process group so playback does not wait for FFmpeg to read the whole input. Only the AV1 decoder's own line on a GPU-decode command triggers the stop; CPU-decode commands and unrelated lines are ignored.playback.gpuDecodeFailedFilterSetupLockednow also classifies the AV1 rejection (and a filter-format conversion failure) as unsupported hardware decoding, so eligible QSV/VAAPI sessions retry with CPU decode and GPU encode.playback.RequiresSoftwareVideoDecodereturns true for codecs with no hardware video decoder (WMV1, WMV2, and listed Microsoft MPEG-4 variants; WMV3 excluded), checked before the existing profile and bit-depth rules.playback.newStderrWriterandplayback.PrepareFilepass the FFmpeg command to the stderr writer so both initial and restarted processes can be stopped. Architecture docs in restart-resilient-playback.md and worker-http-protocol.md are updated.stopOnHardwareDecodeUnavailabledepends on the exactffmpegAV1HardwareDecodeUnavailabletext andffmpegAV1DecoderLogPrefixin transcode_startup.go; changes in FFmpeg's message wording would silently disable the kill.Macroscope summarized 6a7256e.