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 the GPU decoder rejects the source - #4057
Related issue: #4030
Validation tasks: unblocks #1172 C2
Other clients: N/A (no client-visible change)
With Hardware acceleration set to NVENC, every HEVC transcode fails on an NVIDIA card whose decoder can't take HEVC, such as a GTX 970. FFmpeg exits with Hardware is lacking required capabilities, and the startup retry runs the same -hwaccel cuda command again, so playback ends with transcode_start_failed. Auto already recovers by decoding on the CPU and encoding on the GPU, but the explicit settings never try that.
This change makes the startup retry recognise that decoder error and decode on the CPU instead. NVENC keeps encoding when it can, and software is the last step.
It covers local v3 starts, transcode node starts and download preparation. It leaves #4030 open because Jellyfin-compatible starts with an explicit backend start once without waiting for a manifest, so they never reach a retry and still fail the same way. Node reconstructs have the same gap.
Approach
When FFmpeg's stderr contains Hardware is lacking required capabilities, the retry builds a fallback from the same AutoTranscodePipeline stages Auto uses after its first one: CPU decode with the configured hardware encoder, then CPU decode and encode. Reusing the pipeline means the mixed stage keeps NVENC (the same hwupload graph Auto runs) and still has a software step if the upload fails. The fallback has its own cache, so an explicit setting never changes what Auto remembers for a file.
The fallback only applies to a hardware backend whose attempt decoded on the GPU, and never to a tone-map recipe or copied video. Any other early exit keeps the existing retry. Download preparation walks the same two stages, but moves on to software only when the CPU-decode attempt failed before writing any output. FFmpeg writes the container header only once every encoder has opened, so an attempt with output got past hardware startup, and a later failure such as a full disk doesn't cost a second full encode.
The marker is the only decoder message matched. It's the one NVDEC prints when the card has no decoder for the codec, profile or bit depth. I left out the generic Failed setup for format cuda line because other CUDA init failures print it too. The check reads FFmpeg's whole retained stderr (the 64 KiB tail buffer) and marks the startup error with ErrHardwareDecodeUnsupported, so it doesn't depend on the 500-byte excerpt the error message keeps.
A ready-gated node start under an explicit hardware backend can now run up to three attempts, so the API server gives those starts the same deadline as Auto (one manifest wait per attempt). This also covers the existing VideoToolbox software retry, which already needed a second wait.
worker-http-protocol.md now describes the node retry and the deadline.
Validation
go test ./internal/playback/ -run 'TestStartReadyTranscode|TestStartReconstructTranscode|TestWaitForGenerationManifest' -count=1: passes. The new table case fails on main: the decoder rejection is retried with the same GPU decode and never reaches software. One row puts the rejection after 600 bytes of earlier output.
go test ./internal/api/handlers/ -run 'TestPrepareLocalTransportV3|TestRemotePlaybackTransportTimeout' -count=1: passes. The new case drives the reported v3 path with a fake FFmpeg that prints the NVDEC error, and fails on main.
go test ./internal/playback/ -run TestPrepareFileRetriesRejectedDecodeOnCPU -count=1: passes. A fake FFmpeg rejects the CUDA decode. The download moves on to libx264 when the CPU-decode attempt dies without output, and stops when it fails after writing output. Two existing prepare-file tests (TestPrepareFileRetriesVideoToolboxFailureInSoftware, TestPrepareFileDoesNotDropHardwareToneMapGraphOnSoftwareRetry) fail on my Mac with and without this change, so CI on Linux is the check for those.
go build ./internal/api/handlers/, go vet ./internal/playback/, gofmt -l: clean.
Full Go gate and lint: left to CI on this pull request.
Not tested on real hardware. I don't have an NVIDIA card without HEVC decode.
Evidence
No capture on real hardware: I don't have a GPU that reproduces this. The reporter's logs on #4030 show Auto's CPU-decode stage playing the same file on a GTX 970 with NVENC, and that's the path this change now takes with an explicit NVENC setting.
FFmpeg arguments Silo builds for the same v3 local start (H.264 720p target, Hardware acceleration = NVENC), from the handler test's fake FFmpeg that prints Hardware is lacking required capabilities for any -hwaccel cuda command. Trimmed to the decode, encoder and filter arguments.
RESULT: transcode_start_failed
ATTEMPT 1: -hwaccel cuda -hwaccel_output_format cuda -noautorotate ... -c:v h264_nvenc ... -vf scale_cuda=w=-2:h=720:format=nv12
ATTEMPT 2: -hwaccel cuda -hwaccel_output_format cuda -noautorotate ... -c:v h264_nvenc ... -vf scale_cuda=w=-2:h=720:format=nv12
After (this branch):
RESULT: ready
ATTEMPT 1: -hwaccel cuda -hwaccel_output_format cuda -noautorotate ... -c:v h264_nvenc ... -vf scale_cuda=w=-2:h=720:format=nv12
ATTEMPT 2: -init_hw_device cuda=cu -filter_hw_device cu ... -c:v h264_nvenc ... -vf format=nv12,hwupload,scale_cuda=w=-2:h=720:format=nv12
Risks
A start that hits this error now runs up to three FFmpeg processes instead of two. The decoder rejection exits in under a second in the reporter's logs, so the extra attempts cost little.
The longer deadline means an unresponsive node holding an explicit hardware start fails over after about 95 seconds instead of 35, the same as an Auto start.
On a host with two different NVIDIA cards in hw_device, a decoder rejection used to retry on the other card. It now decodes on the CPU and still encodes on NVENC, so it plays at a higher CPU cost.
Every start on an affected card still makes one failed GPU-decode attempt first. Probing decode per codec would avoid that and is a bigger change.
A reconstruct of a session that recovered this way re-resolves from live config and the recipe card's CPU-decode flag, so it encodes with libx264 rather than NVENC. Before this change those sessions never started.
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 (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 correctness: retry-loop invariants, cache side effects, exclusions, lock and error handling in the v3 branch, startup deadlines, and whether the stderr excerpt keeps the marker. It found no bugs and two risks: the shared node deadline and hosts with two different NVIDIA cards. I corrected the comments and doc that claimed the retry would fail on every device, and listed the multi-GPU case above. Review bots then raised the node deadline, the prepare path stopping before software or retrying after a late failure (first with a time limit, then with the written-output check), classification from the stderr excerpt, and a goconst finding, and those are fixed here.
Note
Retry playback transcodes on CPU decode when a hardware decoder rejects the source
When FFmpeg's hardware decoder rejects a video source, the pipeline now retries with CPU decoding while keeping the configured hardware encoder, then falls back to software encoding only if the retry fails before writing output.
Adds ErrHardwareDecodeUnsupported and classifyFFmpegFailure in transcode_startup.go to detect the decoder-rejection marker in retained FFmpeg stderr, plus NewSoftwareDecodeRetryPipeline to build the retry sequence.
RequireReady remote starts with an explicit hardware backend (not auto/none, not video-copy) now get the multi-attempt readiness timeout via remoteHardwareRetryPossibleV3 in playback_transport.go.
Risk: requests with tone mapping, video copy, or already-software decoding are excluded from the retry; check NewSoftwareDecodeRetryPipeline eligibility gates and the legacyDecodeRetryPipeline policy gate if a path should retry but does not.
With an explicit hardware backend, a transcode whose FFmpeg exits with
"Hardware is lacking required capabilities" (NVDEC without HEVC on a
Maxwell GTX 970, for example) retried the identical command, so every
HEVC transcode on that card failed. The startup retry now recognises the
decoder rejection and walks CPU decode with the hardware encoder, then
full software, the same order hw_accel=auto already takes.
This covers the v3 local start, transcode node starts and download
preparation. Other early exits keep the existing retry.
Related issue: Silo-Server#4030
No actionable comments were generated in the recent review.
Walkthrough
Startup now detects eligible hardware-decoder rejection errors and retries with CPU video decoding. File preparation and local transport startup use the retry pipeline. Required-ready starts can receive extended readiness timeouts, as reflected in tests and protocol documentation.
Changes: Hardware decoder rejection fallback
Layer / File(s)
Summary
Retry eligibility and startup policy internal/playback/transcode_startup.go, internal/playback/transcode.go, internal/playback/gpudetect.go, internal/playback/transcode_startup_test.go
Startup logic classifies hardware-decoder rejection errors and builds a CPU-decode retry pipeline for eligible hardware configurations. The retry can retain NVENC encoding before a later software-acceleration attempt. Tests cover retry-policy limits and errors that do not trigger the fallback.
File and local transport retry paths internal/playback/prepare_file.go, internal/playback/prepare_file_test.go, internal/api/handlers/playback_v3.go, internal/api/handlers/playback_v3_test.go
File preparation and local transport startup can retry with CPU decoding. File-preparation tests cover partial-output handling and software-encoding fallback. Local transport tests cover explicit NVENC and automatic-mode startup paths.
Readiness deadlines and protocol internal/api/handlers/playback_transport.go, internal/api/handlers/playback_v3_test.go, docs/architecture/worker-http-protocol.md
Required-ready explicit-hardware video starts receive an extended timeout when retry attempts are possible. Tests and protocol documentation describe readiness wait limits.
sequenceDiagram
participant PrepareFile
participant TranscodeStartup
participant FFmpeg
PrepareFile->>TranscodeStartup: Start transcode attempt
TranscodeStartup->>FFmpeg: Run hardware-decode attempt
FFmpeg-->>TranscodeStartup: Return decoder-rejection error
TranscodeStartup->>FFmpeg: Retry with CPU video decoding
FFmpeg-->>PrepareFile: Return retry result
Loading
Suggested reviewers:quick104, rhainland
Merge Risk: Minimal · up to 0dbc3
Playback and downloads that fail because a GPU decoder rejects the source now retry with CPU decoding. A tester confirmed this on real hardware, and no remaining merge-blocking risk was found.
Security architecture risk: Low · up to 0dbc3
Retries are bounded and preserve existing session identity, output handling, and cleanup. No introduced access-control weakness was established. The main residual risk is additional CPU work and longer startup waits on shared workers; production capacity and real hardware behavior were not validated.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The changed resource exposure is additional CPU decoding or encoding on the existing execution host for eligible media jobs. Retries retain the same source, session, and output destination. Concurrent eligible jobs can increase shared-worker load; bounded attempt count does not itself bound total CPU consumption.
Trust Boundaries and Controls
observed — The remote start continues through the existing signed API-to-worker request. The fallback is selected inside that execution flow rather than introducing another remote endpoint or authority-bearing request.
Resilience and Maintainability Implications
observed — Retries remain inside existing session-lifecycle publication controls: local preparation retains commit and rollback handling, while worker replacement uses a separate directory when an existing session is present and publishes only after startup succeeds.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: when the GPU decoder rejects a source, the transcode decodes on the CPU. The changeset adds a CPU-decode retry for FFmpeg's 'Hardware is lacking required capabilities'…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is specific and related to the changeset. It explains the problem: explicit NVENC HEVC transcodes fail on GPUs whose decoder lacks HEVC support, with FFmpeg reporting 'Hardware is lack…
Full details: Title check
Explanation
The title names the main change: when the GPU decoder rejects a source, the transcode decodes on the CPU. The changeset adds a CPU-decode retry for FFmpeg's 'Hardware is lacking required capabilities' startup failure, which matches the title.
Full details: Description check
Explanation
The description is specific and related to the changeset. It explains the problem: explicit NVENC HEVC transcodes fail on GPUs whose decoder lacks HEVC support, with FFmpeg reporting 'Hardware is lacking required capabilities'. It describes the approach: a CPU-decode retry that keeps the hardware encoder, then software encoding as a last step, covering local v3 starts, transcode node starts, and download preparation. It also lists the files and deadline changes, risks, validation commands, and the known gaps left open (Jellyfin-compatible starts and node reconstructs). This matches the raw summary's changes in playback_v3.go, prepare_file.go, transcode_startup.go, playback_transport.go, and the docs.
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: 4f4ae9b1-0edc-43d3-aedc-71f2bf7acfda
Commits
Reviewing files that changed from the base of the PR and between 0dcc7b2 and 0dbc356.
Files selected for processing: 4
docs/architecture/worker-http-protocol.md
internal/playback/gpudetect.go
internal/playback/prepare_file.go
internal/playback/prepare_file_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.
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: 493a766b-3ff3-4712-8309-4eeb26081241
Commits
Reviewing files that changed from the base of the PR and between 0387303 and fc4008b.
Files selected for processing: 7
docs/architecture/worker-http-protocol.md
internal/api/handlers/playback_v3.go
internal/api/handlers/playback_v3_test.go
internal/playback/prepare_file.go
internal/playback/transcode.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; 3 remain after this review.
A ready-gated node start under an explicit hardware backend can now run
the CPU-decode and software attempts after a decoder rejection, and the
VideoToolbox software retry already needed a second wait. Size the API
server's deadline for those starts to two manifest waits.
Related issue: Silo-Server#4030
…tderr
The startup error keeps only the first 500 bytes of FFmpeg's stderr, so
earlier output could hide the decoder rejection from the retry. Mark the
error from the retained stderr instead and test a rejection that follows
longer output.
Related issue: Silo-Server#4030
@aske2002 this should fix the GTX 970 failure from #4030. I don't have a card that reproduces it, so could you test the branch on yours when you get a chance? There's no prebuilt image for pull requests, so it needs building from blurbery/silo-server branch fix/cuda-startup-software-decode.
To check it:
Set Hardware acceleration to NVENC (not Auto).
Play an HEVC file that has to transcode, for example with the Chromecast H.264/AAC profile you used before.
Playback should start. The log should show hardware decoder rejected the source during startup; retrying with CPU decoding, then an FFmpeg command with -init_hw_device cuda and h264_nvenc and no -hwaccel cuda.
If you can, prepare a download of the same file too. It should finish with the same CPU decode and NVENC encode.
Thanks for the detailed report, the logs made this easy to track down.
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: 5d8de029-b659-4ad9-ae18-551b8cf6b656
Commits
Reviewing files that changed from the base of the PR and between fc4008b and 36a4c28.
Files selected for processing: 7
docs/architecture/worker-http-protocol.md
internal/api/handlers/playback_transport.go
internal/api/handlers/playback_v3_test.go
internal/playback/prepare_file.go
internal/playback/transcode.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; 2 remain after this review.
Each attempt after a decoder rejection may use its whole readiness wait
before it exits, so give a ready-gated explicit hardware start the same
deadline as hw_accel=auto. Add playback.HWAccelAuto for the new check.
Related issue: Silo-Server#4030
A CPU-decode attempt that failed after encoding for a while (a full disk,
for example) would fail a software encode too, so only an attempt that
died while starting moves on to software.
Related issue: Silo-Server#4030
…sed time
A slow input probe could push a genuine startup failure past the startup
window and skip the software attempt. FFmpeg writes the container header
only once every encoder has opened, so move on to software only when the
CPU-decode attempt wrote no output.
Related issue: Silo-Server#4030
Tested on my GTX 970 and it works, for both playback and a download.
Build: upstream image build-2222 (main 0387303) with a binary from main plus this branch at 284e8ca (merged with #4059 and #4060). Hardware acceleration was set to NVENC, not Auto.
Playback. I cast The Odyssey (HEVC Main 10, AC3 5.1) with an H.264/AAC stereo profile, starting at 1:05:48. It started playing:
The first attempt with -hwaccel cuda exited after about 0.7 s with Hardware is lacking required capabilities.
Then the log showed hardware decoder rejected the source during startup; retrying with CPU decoding.
The retry used -init_hw_device cuda=cu -filter_hw_device cu, -c:v h264_nvenc and -vf format=nv12,hwupload,scale_cuda=w=-2:h=1080:format=nv12, with no -hwaccel cuda. The session was ready about 2 s later.
Download. I prepared a converted download of the same file at the 720p preset:
The first attempt failed the same way.
Then the log showed prepared encode failed in the hardware decoder; retrying with CPU decoding.
The retry ran -init_hw_device cuda=cu, -c:v hevc_nvenc -b:v 1800k and -vf format=nv12,hwupload,scale_cuda=w=-2:h=720:format=nv12.
It finished in about 39 minutes. ffprobe shows a complete file: HEVC 1280x720 with stereo AAC and two mov_text tracks, 10355.7 s long (2.6 GB). That's the full runtime.
No software-encode step was needed in either case.
The reason will be displayed to describe this comment to others. Learn more.
Maintainer review of 284e8ca. The fix is sound: on main, explicit NVENC reruns the same -hwaccel cuda command (local v3) or doesn't retry at all (node), and all four new or changed tests fail on main for that reason. Three findings below, none blocking. I'm fixing all three on this branch. A summary comment follows.
When a download's CPU-decode attempt failed and the retry moved on to
libx264, the NVENC/QSV/VAAPI workload reservation stayed counted for the
whole software encode, skewing the device's active count and QSV/VAAPI
device selection.
Related issue: Silo-Server#4030
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ately
On main the node didn't retry an explicit NVENC start at all, so the walk
replaces a failed start, not a repeated command, and it applies only to a
GPU-decoded video transcode without tone mapping. Derive hwAccelAuto from
HWAccelAuto so the package has one value for "auto".
Related issue: Silo-Server#4030
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewed head: 0dbc356 (the author's 284e8ca plus two review commits)
The defect is real and this fixes it. On main, explicit NVENC doesn't recover from Hardware is lacking required capabilities. StartupRetryHWAccel returns the same accel for NVENC, so the local v3 start reruns the identical -hwaccel cuda command and the node's AccelChange policy doesn't retry at all. The four new or changed tests (TestStartReadyTranscodeRetriesDecoderRejectionOnCPU, TestPrepareFileRetriesRejectedDecodeOnCPU, TestPrepareLocalTransportV3NVENCRetriesRejectedDecodeOnCPU, TestRemotePlaybackTransportTimeoutCoversAutoFallbackAttempts) all fail on main for that reason and pass here. On main, the v3 handler test logs the same CUDA command twice before transcode_start_failed.
Addressed in this review
f28dbb8: when a download moved on to libx264, it kept its GPU workload reservation for the whole software encode. It's released now. The test assertion fails on 284e8ca.
0dbc356: worker-http-protocol.md said the node used to "repeat the command". It used to fail the start. The text now names the conditions the retry applies under. hwAccelAuto now derives from the new HWAccelAuto.
Left for the maintainers to settle (all disclosed in the PR's Risks section)
After a session recovers onto CPU decode with NVENC, a reconstruct or a rehome to another node rebuilds from the recipe card. The card can record CPU decode but not "keep NVENC", so the rebuild encodes with libx264 mid-session. Sessions on this path never started before this change, so this isn't a regression. Carrying the mixed stage on the card would be a follow-up.
Every RequireReady explicit-hardware node start now gets the 95s deadline, including starts that can't take this retry: an older node, or a request already marked for CPU decode. A hung node takes longer to fail over, as with auto today, and a rehome spends more of its 2-minute budget on one candidate.
Validated features:unblocks #1172 C2 (NVENC forced, auto and disabled modes, plus software fallback on unsupported hardware; not run yet). I found no passed case this changes. The #1177 C3 failover case runs explicit-hardware rehomes into the longer deadline only if its sandbox used an explicit backend. I couldn't confirm the setting and judged it a minor change at most. The board script was unavailable to me, so these cases come from the validation issue bodies.
User manual: unaffected. The playback page doesn't describe how explicit modes fall back, and Activity still shows the hardware encoder after a mixed recovery.
Other clients: N/A. Server-only, no API change.
Cross-provider review: one round on 284e8ca. It found the download reservation issue, fixed above, and nothing else blocking.
Fit: 8/10 · Readiness: 8/10, conditional (assuming CI is green)
Fit: it fixes a broken 1.0 playback path by reusing the existing auto fallback order instead of adding a setting. It stretches in two named ways: three separate call sites, and a longer failover for explicit-hardware node starts.
…GPU can't decode the source (#4097)
With Hardware acceleration set to an explicit backend, a GPU whose decoder
rejects the source (HEVC on a GTX 970) made FFmpeg exit at startup. #4057
retried on the CPU for starts that wait for a first manifest. Four paths
started FFmpeg without waiting and handed back the exited process:
Jellyfin-compatible local and node starts, and local and node reconstructs.
These paths now wait for the first manifest when the start decodes on the GPU,
and walk the same CPU-decode retry on a decoder rejection. Any other outcome is
returned as before, except that a Jellyfin node start is now sent with
RequireReady.
Related issue: #4030
Co-authored-by: Claude Fable 5.2 <[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: P2Limited scope, workaround exists, or polishsize/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
Related issue: #4030
Validation tasks: unblocks #1172 C2
Other clients: N/A (no client-visible change)
With Hardware acceleration set to NVENC, every HEVC transcode fails on an NVIDIA card whose decoder can't take HEVC, such as a GTX 970. FFmpeg exits with
Hardware is lacking required capabilities, and the startup retry runs the same-hwaccel cudacommand again, so playback ends withtranscode_start_failed. Auto already recovers by decoding on the CPU and encoding on the GPU, but the explicit settings never try that.This change makes the startup retry recognise that decoder error and decode on the CPU instead. NVENC keeps encoding when it can, and software is the last step.
It covers local v3 starts, transcode node starts and download preparation. It leaves #4030 open because Jellyfin-compatible starts with an explicit backend start once without waiting for a manifest, so they never reach a retry and still fail the same way. Node reconstructs have the same gap.
Approach
When FFmpeg's stderr contains
Hardware is lacking required capabilities, the retry builds a fallback from the sameAutoTranscodePipelinestages Auto uses after its first one: CPU decode with the configured hardware encoder, then CPU decode and encode. Reusing the pipeline means the mixed stage keeps NVENC (the samehwuploadgraph Auto runs) and still has a software step if the upload fails. The fallback has its own cache, so an explicit setting never changes what Auto remembers for a file.The fallback only applies to a hardware backend whose attempt decoded on the GPU, and never to a tone-map recipe or copied video. Any other early exit keeps the existing retry. Download preparation walks the same two stages, but moves on to software only when the CPU-decode attempt failed before writing any output. FFmpeg writes the container header only once every encoder has opened, so an attempt with output got past hardware startup, and a later failure such as a full disk doesn't cost a second full encode.
The marker is the only decoder message matched. It's the one NVDEC prints when the card has no decoder for the codec, profile or bit depth. I left out the generic
Failed setup for format cudaline because other CUDA init failures print it too. The check reads FFmpeg's whole retained stderr (the 64 KiB tail buffer) and marks the startup error withErrHardwareDecodeUnsupported, so it doesn't depend on the 500-byte excerpt the error message keeps.A ready-gated node start under an explicit hardware backend can now run up to three attempts, so the API server gives those starts the same deadline as Auto (one manifest wait per attempt). This also covers the existing VideoToolbox software retry, which already needed a second wait.
worker-http-protocol.mdnow describes the node retry and the deadline.Validation
go test ./internal/playback/ -run 'TestStartReadyTranscode|TestStartReconstructTranscode|TestWaitForGenerationManifest' -count=1: passes. The new table case fails onmain: the decoder rejection is retried with the same GPU decode and never reaches software. One row puts the rejection after 600 bytes of earlier output.go test ./internal/api/handlers/ -run 'TestPrepareLocalTransportV3|TestRemotePlaybackTransportTimeout' -count=1: passes. The new case drives the reported v3 path with a fake FFmpeg that prints the NVDEC error, and fails onmain.go test ./internal/playback/ -run TestPrepareFileRetriesRejectedDecodeOnCPU -count=1: passes. A fake FFmpeg rejects the CUDA decode. The download moves on tolibx264when the CPU-decode attempt dies without output, and stops when it fails after writing output. Two existing prepare-file tests (TestPrepareFileRetriesVideoToolboxFailureInSoftware,TestPrepareFileDoesNotDropHardwareToneMapGraphOnSoftwareRetry) fail on my Mac with and without this change, so CI on Linux is the check for those.go build ./internal/api/handlers/,go vet ./internal/playback/,gofmt -l: clean.Evidence
No capture on real hardware: I don't have a GPU that reproduces this. The reporter's logs on #4030 show Auto's CPU-decode stage playing the same file on a GTX 970 with NVENC, and that's the path this change now takes with an explicit NVENC setting.
FFmpeg arguments Silo builds for the same v3 local start (H.264 720p target, Hardware acceleration = NVENC), from the handler test's fake FFmpeg that prints
Hardware is lacking required capabilitiesfor any-hwaccel cudacommand. Trimmed to the decode, encoder and filter arguments.Before (
mainat 0387303):After (this branch):
Risks
hw_device, a decoder rejection used to retry on the other card. It now decodes on the CPU and still encodes on NVENC, so it plays at a higher CPU cost.Checklist
AI Disclosure
Note
Retry playback transcodes on CPU decode when a hardware decoder rejects the source
ErrHardwareDecodeUnsupportedandclassifyFFmpegFailurein transcode_startup.go to detect the decoder-rejection marker in retained FFmpeg stderr, plusNewSoftwareDecodeRetryPipelineto build the retry sequence.RequireReadyremote starts with an explicit hardware backend (notauto/none, not video-copy) now get the multi-attempt readiness timeout viaremoteHardwareRetryPossibleV3in playback_transport.go.NewSoftwareDecodeRetryPipelineeligibility gates and thelegacyDecodeRetryPipelinepolicy gate if a path should retry but does not.Macroscope summarized 0dbc356.