Adds a per-FFmpeg-profile boolean QsvPreferNativeDecoder (default ON) that mirrors Jellyfin's "Prefer OS native decoders" checkbox: on the QSV acceleration path, decode with the error-tolerant VA-API decoder while still encoding with QSV, instead of the strict QSV decoder that fails on imperfect H.264 (the reported ~50% channel cold-start failures on the Intel i7-10700K).
How
QsvHardwareAccelerationOption emits -hwaccel vaapi (no -hwaccel_output_format) so frames download to system memory; the existing VA-API→QSV derived-device chain (-init_hw_device vaapi=va:… / qsv=hw@va) is retained for the encoder.
New DecoderVaapiToSoftware (software-output implicit VA-API decoder); QsvPipelineBuilder sets the decoder mode to Vaapi on this path so the decoded software frames flow through the existing format=nv12,hwupload,vpp_qsv/deinterlace_qsv branch to the QSV encoder — the same graph the production software-decode+QSV-encode error-loop already runs. This is a PCIe round-trip, not Jellyfin's zero-copy hwmap (out of scope).
Native decode is Linux-only (!OperatingSystem.IsWindows() guard — ffmpeg has no vaapi hwaccel on Windows).
Full chain: bool? domain column (dual-provider migration, HasDefaultValue(true) → existing QSV profiles adopt it on upgrade; nullable so an explicit false persists), Application records/mapper/handlers, REST DTOs (bool? = null + ?? true for /api/v1 additive-compat), OpenAPI regen, and a QSV-only "Prefer native decoder" checkbox in the SPA.
Verification
Full solution build 0 errors; ErsatzTV.Tests 1753/1753 + FFmpeg.Tests 24/24 (incl. new arg-level tests pinning: -hwaccel vaapi, no -hwaccel_output_format, hwupload precedes every vpp_qsv/deinterlace_qsv, h264_qsv encoder; and false-persists-as-false round-trip tests guarding the EF nullable-bool gotcha).
SQLite migration applies to a fresh DB (column nullable, default 1). MySQL apply is covered by the CI migrations job.
BOM + dotnet format gate clean (normalized two legacy files touched, whitespace-only).
Hardware validation on the Intel QSV host is NOT claimed here — the arg-level tests are the automated net; real iHD decode-tolerance / upload-bandwidth verification happens on the i7-10700K post-deploy (the amd64/macOS dev+CI machines have no QSV).
Reviews
Design + plan pre-reviewed (Fable). Every task independently reviewed. Final whole-branch adversarial review (Fable): MERGEABLE. Its findings dispositioned in commit 650d5bf9: Windows guard, IsIntelVaapiOrQsv Nut-parity, a non-vacuous test assertion, doc corrections — all re-reviewed Approved.
Accepted trade-off / follow-up
With native decode ON, HDR content on a QSV profile tonemaps in software (decoder mode Vaapi skips tonemap_qsv). Correct but higher CPU; the escape hatch (flag OFF) keeps GPU tonemap for HDR-heavy users who don't need the tolerant decoder. Optimizing the native path to tonemap_qsv is tracked in #505. Recorded in docs/decisions.md.
fixes #498
## What
Adds a per-FFmpeg-profile boolean **`QsvPreferNativeDecoder`** (default **ON**) that mirrors Jellyfin's "Prefer OS native decoders" checkbox: on the QSV acceleration path, decode with the error-tolerant **VA-API** decoder while still encoding with **QSV**, instead of the strict QSV decoder that fails on imperfect H.264 (the reported ~50% channel cold-start failures on the Intel i7-10700K).
## How
- `QsvHardwareAccelerationOption` emits `-hwaccel vaapi` (no `-hwaccel_output_format`) so frames download to system memory; the existing VA-API→QSV derived-device chain (`-init_hw_device vaapi=va:… / qsv=hw@va`) is retained for the encoder.
- New `DecoderVaapiToSoftware` (software-output implicit VA-API decoder); `QsvPipelineBuilder` sets the decoder mode to `Vaapi` on this path so the decoded software frames flow through the existing `format=nv12,hwupload,vpp_qsv`/`deinterlace_qsv` branch to the QSV encoder — the same graph the production software-decode+QSV-encode error-loop already runs. **This is a PCIe round-trip, not Jellyfin's zero-copy `hwmap` (out of scope).**
- Native decode is **Linux-only** (`!OperatingSystem.IsWindows()` guard — ffmpeg has no vaapi hwaccel on Windows).
- Full chain: `bool?` domain column (dual-provider migration, `HasDefaultValue(true)` → existing QSV profiles adopt it on upgrade; nullable so an explicit `false` persists), Application records/mapper/handlers, REST DTOs (`bool? = null` + `?? true` for `/api/v1` additive-compat), OpenAPI regen, and a QSV-only "Prefer native decoder" checkbox in the SPA.
## Verification
- Full solution build 0 errors; **ErsatzTV.Tests 1753/1753** + **FFmpeg.Tests 24/24** (incl. new arg-level tests pinning: `-hwaccel vaapi`, no `-hwaccel_output_format`, `hwupload` precedes every `vpp_qsv`/`deinterlace_qsv`, `h264_qsv` encoder; and false-persists-as-false round-trip tests guarding the EF nullable-bool gotcha).
- SQLite migration applies to a fresh DB (column nullable, default 1). MySQL apply is covered by the CI `migrations` job.
- BOM + `dotnet format` gate clean (normalized two legacy files touched, whitespace-only).
- **Hardware validation on the Intel QSV host is NOT claimed here** — the arg-level tests are the automated net; real iHD decode-tolerance / upload-bandwidth verification happens on the i7-10700K post-deploy (the amd64/macOS dev+CI machines have no QSV).
## Reviews
Design + plan pre-reviewed (Fable). Every task independently reviewed. Final whole-branch adversarial review (Fable): **MERGEABLE**. Its findings dispositioned in commit `650d5bf9`: Windows guard, `IsIntelVaapiOrQsv` Nut-parity, a non-vacuous test assertion, doc corrections — all re-reviewed **Approved**.
## Accepted trade-off / follow-up
With native decode ON, HDR content on a QSV profile tonemaps in **software** (decoder mode `Vaapi` skips `tonemap_qsv`). Correct but higher CPU; the escape hatch (flag OFF) keeps GPU tonemap for HDR-heavy users who don't need the tolerant decoder. Optimizing the native path to `tonemap_qsv` is tracked in **#505**. Recorded in `docs/decisions.md`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Mirrors Jellyfin's default-on "prefer native decoder" hybrid via a new
QsvPreferNativeDecoder profile boolean. Reverified against code before
designing; records the rejected decode-family-enum alternative (Option C).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Blocker 1: VA-API decode to SOFTWARE frames (drop -hwaccel_output_format,
new DecoderVaapiToSoftware) so the proven hwupload/vpp_qsv branch bridges to
the QSV encoder — the naive hardware-surface path emits a bare vpp_qsv on
VA-API frames and fails on ~all content.
- Blocker 2: bool? domain property + != false coercion (DeinterlaceVideo
pattern) so create-with-false actually persists false.
- High 3: REST DTOs bool?=null + ?? true for /api/v1 additive-compat.
- Medium 4: correct Task 4 test scaffolding (DefaultHardwareCapabilities).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Field-reference update skipped: docs/channels.md and docs/domain-model.md
have no per-field FFmpeg-profile catalogue (channels.md's Encoding bullet
is a one-line summary, not a field list; grep for QsvExtraHardwareFrames
or HardwareAcceleration finds no such list in either doc).
Whitespace-only (git diff -w is empty); the #311 format job checks whole
touched files, and these two legacy files carried pre-existing violations
never caught before (no PR had touched them since the gate landed).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
From the Fable whole-branch review:
- M1: guard native VA-API decode with !OperatingSystem.IsWindows() (no vaapi
hwaccel on Windows; QSV caps over-reported there) — DRY'd into a preferNativeDecode local.
- L2: IsIntelVaapiOrQsv also matches decoder mode Vaapi, preserving Intel
audio-dup parity on the (producerless) Nut-output branch.
- L1: replace the vacuous ShouldNotContain(" deinterlace_qsv") with an
occurrence-count assertion that actually catches a second bare occurrence.
- N1/H1: decisions.md — correct the column to nullable-with-default (not NOT NULL),
and record the accepted HDR software-tonemap trade-off + Linux-only guard, with
the tonemap_qsv optimization tracked in #505.
H1 (HDR tonemap reroute) accepted-and-deferred per that decision; #505 filed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Final whole-branch adversarial review (Fable) returned MERGEABLE; its findings (Windows guard, IsIntelVaapiOrQsv Nut-parity, non-vacuous test assertion, doc corrections) were fixed in commit 650d5bf9 and independently re-reviewed Approved. The one High finding (HDR content tonemaps in software on the native-decode path) was accepted-and-deferred with an escape hatch (flag OFF), documented in docs/decisions.md, and tracked in #505. Local gate green: full build 0 errors, ErsatzTV.Tests 1753/1753 + FFmpeg.Tests 24/24, BOM + format clean, SQLite migration applies to a fresh DB. Hardware validation on the Intel QSV host is deferred to post-deploy (no QSV on the dev/CI machines) — the arg-level tests are the pre-merge net.
Review-verdict: MERGEABLE @ 650d5bf9725a1b1b6c693e74fdb58d6168baa357
Final whole-branch adversarial review (Fable) returned MERGEABLE; its findings (Windows guard, `IsIntelVaapiOrQsv` Nut-parity, non-vacuous test assertion, doc corrections) were fixed in commit `650d5bf9` and independently re-reviewed **Approved**. The one High finding (HDR content tonemaps in software on the native-decode path) was accepted-and-deferred with an escape hatch (flag OFF), documented in `docs/decisions.md`, and tracked in #505. Local gate green: full build 0 errors, ErsatzTV.Tests 1753/1753 + FFmpeg.Tests 24/24, BOM + format clean, SQLite migration applies to a fresh DB. Hardware validation on the Intel QSV host is deferred to post-deploy (no QSV on the dev/CI machines) — the arg-level tests are the pre-merge net.
Rebased onto current main (picked up #67). The reviewed code is byte-identical (git rebase preserved every blob) — the only change vs the prior verdict (@ 650d5bf9) is the append-only docs/decisions.md merge (both the #67 and #498 entries kept, in order) and the new base. Re-verified locally on top of #67: full build 0 errors, ErsatzTV.Tests 1760/1760 (incl. #67's new tests) + FFmpeg.Tests 24/24, OpenAPI regenerated + check:api clean (both imageSource and qsvPreferNativeDecoder present), BOM clean. Fable whole-branch verdict MERGEABLE + fix-commit re-review Approved still hold for this identical code.
Review-verdict: MERGEABLE @ 374528250b4b6e6336520a9d550b92fd86c4e083
Rebased onto current `main` (picked up #67). The reviewed code is byte-identical (git rebase preserved every blob) — the only change vs the prior verdict (`@ 650d5bf9`) is the append-only `docs/decisions.md` merge (both the #67 and #498 entries kept, in order) and the new base. Re-verified locally on top of #67: full build 0 errors, ErsatzTV.Tests 1760/1760 (incl. #67's new tests) + FFmpeg.Tests 24/24, OpenAPI regenerated + `check:api` clean (both `imageSource` and `qsvPreferNativeDecoder` present), BOM clean. Fable whole-branch verdict MERGEABLE + fix-commit re-review Approved still hold for this identical code.
timothy
scheduled this pull request to auto merge when all checks succeed 2026-07-20 21:59:37 +02:00
timothy
merged commit 36499a96e0 into main2026-07-20 22:16:37 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
fixes #498
What
Adds a per-FFmpeg-profile boolean
QsvPreferNativeDecoder(default ON) that mirrors Jellyfin's "Prefer OS native decoders" checkbox: on the QSV acceleration path, decode with the error-tolerant VA-API decoder while still encoding with QSV, instead of the strict QSV decoder that fails on imperfect H.264 (the reported ~50% channel cold-start failures on the Intel i7-10700K).How
QsvHardwareAccelerationOptionemits-hwaccel vaapi(no-hwaccel_output_format) so frames download to system memory; the existing VA-API→QSV derived-device chain (-init_hw_device vaapi=va:… / qsv=hw@va) is retained for the encoder.DecoderVaapiToSoftware(software-output implicit VA-API decoder);QsvPipelineBuildersets the decoder mode toVaapion this path so the decoded software frames flow through the existingformat=nv12,hwupload,vpp_qsv/deinterlace_qsvbranch to the QSV encoder — the same graph the production software-decode+QSV-encode error-loop already runs. This is a PCIe round-trip, not Jellyfin's zero-copyhwmap(out of scope).!OperatingSystem.IsWindows()guard — ffmpeg has no vaapi hwaccel on Windows).bool?domain column (dual-provider migration,HasDefaultValue(true)→ existing QSV profiles adopt it on upgrade; nullable so an explicitfalsepersists), Application records/mapper/handlers, REST DTOs (bool? = null+?? truefor/api/v1additive-compat), OpenAPI regen, and a QSV-only "Prefer native decoder" checkbox in the SPA.Verification
-hwaccel vaapi, no-hwaccel_output_format,hwuploadprecedes everyvpp_qsv/deinterlace_qsv,h264_qsvencoder; and false-persists-as-false round-trip tests guarding the EF nullable-bool gotcha).migrationsjob.dotnet formatgate clean (normalized two legacy files touched, whitespace-only).Reviews
Design + plan pre-reviewed (Fable). Every task independently reviewed. Final whole-branch adversarial review (Fable): MERGEABLE. Its findings dispositioned in commit
650d5bf9: Windows guard,IsIntelVaapiOrQsvNut-parity, a non-vacuous test assertion, doc corrections — all re-reviewed Approved.Accepted trade-off / follow-up
With native decode ON, HDR content on a QSV profile tonemaps in software (decoder mode
Vaapiskipstonemap_qsv). Correct but higher CPU; the escape hatch (flag OFF) keeps GPU tonemap for HDR-heavy users who don't need the tolerant decoder. Optimizing the native path totonemap_qsvis tracked in #505. Recorded indocs/decisions.md.🤖 Generated with Claude Code
From the Fable whole-branch review: - M1: guard native VA-API decode with !OperatingSystem.IsWindows() (no vaapi hwaccel on Windows; QSV caps over-reported there) — DRY'd into a preferNativeDecode local. - L2: IsIntelVaapiOrQsv also matches decoder mode Vaapi, preserving Intel audio-dup parity on the (producerless) Nut-output branch. - L1: replace the vacuous ShouldNotContain(" deinterlace_qsv") with an occurrence-count assertion that actually catches a second bare occurrence. - N1/H1: decisions.md — correct the column to nullable-with-default (not NOT NULL), and record the accepted HDR software-tonemap trade-off + Linux-only guard, with the tonemap_qsv optimization tracked in #505. H1 (HDR tonemap reroute) accepted-and-deferred per that decision; #505 filed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>Review-verdict: MERGEABLE @
650d5bf972Final whole-branch adversarial review (Fable) returned MERGEABLE; its findings (Windows guard,
IsIntelVaapiOrQsvNut-parity, non-vacuous test assertion, doc corrections) were fixed in commit650d5bf9and independently re-reviewed Approved. The one High finding (HDR content tonemaps in software on the native-decode path) was accepted-and-deferred with an escape hatch (flag OFF), documented indocs/decisions.md, and tracked in #505. Local gate green: full build 0 errors, ErsatzTV.Tests 1753/1753 + FFmpeg.Tests 24/24, BOM + format clean, SQLite migration applies to a fresh DB. Hardware validation on the Intel QSV host is deferred to post-deploy (no QSV on the dev/CI machines) — the arg-level tests are the pre-merge net.650d5bf972to374528250bReview-verdict: MERGEABLE @
374528250bRebased onto current
main(picked up #67). The reviewed code is byte-identical (git rebase preserved every blob) — the only change vs the prior verdict (@ 650d5bf9) is the append-onlydocs/decisions.mdmerge (both the #67 and #498 entries kept, in order) and the new base. Re-verified locally on top of #67: full build 0 errors, ErsatzTV.Tests 1760/1760 (incl. #67's new tests) + FFmpeg.Tests 24/24, OpenAPI regenerated +check:apiclean (bothimageSourceandqsvPreferNativeDecoderpresent), BOM clean. Fable whole-branch verdict MERGEABLE + fix-commit re-review Approved still hold for this identical code.