Files
hyperframes/packages/engine/src/services/softwareEncoderThreads.ts
T
Miguel Ángel 395c845cd3 fix(engine): render work is sized by the CPUs the process may use (#7612)
* fix(engine): render work is sized by the CPUs the process may use

* fix(engine): keep the usable CPU count comment under the line limit
2026-11-12 17:07:45 +00:00

14 lines
518 B
TypeScript

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