Skip to content

fix(engine): h265 renders no longer fail on hosts with more than 16 cores - #6193

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/x265-thread-cap
Oct 24, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/x265-thread-cap

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Every h265 render failed on a host with more than 16 cores: ffmpeg exited 183 with frameNumThreads (--frame-threads) must be [0 .. X265_MAX_FRAME_THREADS). The thread count introduced for stable bitstreams passed the CPU quota straight to libx265, which accepts at most 16.

The one place that sets the count now caps libx265 at 16 (X265_MAX_THREADS) and leaves libx264 as it was. Output stays the same on every host above 16 cores.

Tests:

  • Unit: 64 cores gives 16 for libx265 and 64 for libx264 (the old signature cannot express this, so it fails on main).
  • Real ffmpeg: -c:v libx265 -threads 17 exits non-zero, -threads 16 encodes.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES · 1 blocker · 0 important · 0 nits · head 214459ff

The libx265 cap itself is right, and both engine call sites pass the encoder.

Blocker: packages/producer/src/services/distributed/assemble.ts:288 (cfrEncodeArgs) still calls appendSoftwareEncoderThreadsArg(args) with one argument. The new required encoder parameter means the producer no longer typechecks: tsc --noEmit -p packages/producer reports assemble.ts(288,3): error TS2554: Expected 2-3 arguments, but got 1. That encode is libx264, so the fix is appendSoftwareEncoderThreadsArg(args, "libx264").

CI: the Comments workflow already fails at this head. softwareEncoderThreads.ts goes from 10.0% to 13.3% comment share because of the new doc line on X265_MAX_THREADS, and the ratchet asks for it to move into a name or be cut. CI (Typecheck) was still running when I posted.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 148 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

…ores

libx265 rejects more than 16 frame threads, so the thread count taken from the
CPU quota is now capped at 16 for x265. x264 is unchanged.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE · 1 resolved, 0 open, 0 new · 214459ff → 5f51d2d3

The assemble.ts:288 caller now passes libx264, and the Comments ratchet passes. Locally, tsc for the producer and the engine is clean, and softwareEncoderThreads.test.ts passes (6 tests, including the real-ffmpeg 17-versus-16 case). CI and Windows render verification were still running when I posted.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit 53e1dfc Oct 24, 2026
75 checks passed
@miguel-heygen
miguel-heygen deleted the fix/x265-thread-cap branch October 24, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant