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

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

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.

* fix(engine): pass the encoder to the thread cap in the CFR re-encode
This commit is contained in:
Miguel Ángel
2026-10-24 05:33:56 +00:00
committed by GitHub
parent ebb057fb62
commit 53e1dfce9e
5 changed files with 44 additions and 7 deletions
@@ -1,9 +1,13 @@
import { availableParallelism } from "node:os";
export const X265_MAX_THREADS = 16;
/** x264/x265 bitstreams depend on the thread count, so it comes from the CPU quota, never ffmpeg's host-core guess. */
export function appendSoftwareEncoderThreadsArg(
args: string[],
encoder: "libx264" | "libx265",
parallelism: number = availableParallelism(),
): void {
args.push("-threads", String(Math.max(1, Math.floor(parallelism))));
const cap = encoder === "libx265" ? X265_MAX_THREADS : Infinity;
args.push("-threads", String(Math.min(cap, Math.max(1, Math.floor(parallelism)))));
}