perf(engine): gated hwaccel auto for SDR opaque extraction#435
Closed
jrusso1020 wants to merge 1 commit intoperf/producer-webp-extraction-formatfrom
Closed
perf(engine): gated hwaccel auto for SDR opaque extraction#435jrusso1020 wants to merge 1 commit intoperf/producer-webp-extraction-formatfrom
jrusso1020 wants to merge 1 commit intoperf/producer-webp-extraction-formatfrom
Conversation
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Apr 23, 2026
Collaborator
Author
|
Closed: inert on validation host (no hardware decoder). Deferring to standalone PR once we can measure benefit on a NVDEC/VideoToolbox host. See hyperframes-notes/perf-stack-rebuild-plan-2026-04-23.md |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

What
Enables
-hwaccel autoon the Phase 3 ffmpeg extract, gated so it only kicks in for inputs that can safely take it: SDR, opaque pixel format, segment duration above a floor. Default on, with a config opt-out.To support the gating,
VideoMetadatanow exposespixelFormat: stringandhasAlpha: boolean, derived from ffprobe'spix_fmtfield via a newpixelFormatHasAlpha(pixFmt)helper.Why
Final PR of the 5-PR stack from
hyperframes-notes/producer-render-architecture-review-2026-04-21.md.The doc explicitly calls for gated hwaccel:
And warns against a blanket default:
This PR lands both gates exactly as described. Impact is measurable via
RenderPerfSummary.videoExtractBreakdown.extractMs(PR 1) on SDR-heavy compositions.How
pixelFormatHasAlpha(ffprobe.ts)Substring/exact-match check against the canonical alpha-bearing pixel formats:
yuva*— planar YUV + alpha (including 10/12-bit variants likeyuva444p10le)rgba/bgra/argb/abgr— 8-bit packed RGBA (exact match sobgrdoesn't false-positive)rgba64*/bgra64*/argb64*/abgr64*— 16-bit packed RGBACase-insensitive. Everything else (including
yuv420p,gbrp,nv12,rgb48le) returns false.VideoMetadataadditionspixelFormat: stringpopulated fromvideoStream.pix_fmt;hasAlpha: booleanderived via the helper. Still-image fallback path sets both to empty/false since image alpha detection lives elsewhere (the HDR/PNG path in the orchestrator).shouldEnableHwaccelSdr({ isHdr, hasAlpha, durationSeconds, config })Extracted as a pure function in
videoFrameExtractor.tsso the gating contract is unit-testable without spawning ffmpeg. Returns true iff:config.hwaccelSdrDecode === true(master switch)!isHdr(HDR takes the existing macOS VideoToolbox path; generic hwaccel would conflict)!hasAlpha(hardware decoders generally strip alpha)durationSeconds >= config.hwaccelMinDurationSeconds(default 2.0)The extractor calls this once per input. When true,
-hwaccel autois added to the args — ffmpeg picks the best available accelerator (VideoToolbox on macOS, VAAPI on Linux, NVDEC on CUDA hosts). When nothing is available, ffmpeg silently falls back to software decode.Config
Two new
EngineConfigfields, both with env var fallbacks:hwaccelSdrDecode: booleanPRODUCER_HWACCEL_SDR_DECODEtruehwaccelMinDurationSeconds: numberPRODUCER_HWACCEL_MIN_DURATION_SECONDS2.0Opt-out: set
PRODUCER_HWACCEL_SDR_DECODE=false. Floor is tunable per platform based on PR 1's measurements.Mutual exclusivity with the HDR path
-hwaccel videotoolboxon the existing HDR+macOS branch and-hwaccel autoon the new SDR branch are in an if/else — never both at once.Test plan
ffprobe.test.tscoveringpixelFormatHasAlphaagainst 11 alpha-bearing pix_fmts, 10 opaque ones, an empty string, and case-insensitivity.videoFrameExtractor.test.tscovering theshouldEnableHwaccelSdrgating fence posts:Stack
Final PR of the 5-PR stack, built on #434 → #433 → #432 → #430.
Every improvement in the stack is measurable via the perf summary added in PR 1 — validation plan in the architecture review doc is now runnable end-to-end against real compositions.
Follow-ups (out of scope for the current stack)
Rough ordering if further work is desired, roughly following the architecture review's tier B/C: