Files
hyperframes/packages/engine/src/services/softwareEncoderThreads.ts
T
Miguel Ángel db5950c004 fix(engine): renders under a CPU quota get their workers back (#8262)
* fix(engine): renders under a CPU quota get their workers back

* fix(engine): the usable CPU count stays within the host's online CPUs
2026-11-20 00:46:36 +00:00

14 lines
508 B
TypeScript

import { cpuBudget } from "./systemMemory.js";
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 = cpuBudget(),
): void {
const cap = encoder === "libx265" ? X265_MAX_THREADS : Infinity;
args.push("-threads", String(Math.min(cap, Math.max(1, Math.floor(parallelism)))));
}