fix(engine): encode with the same x264 and x265 thread count on any host size (#6127)

* fix(engine): encode with the same x264 and x265 thread count on any host size

libx264 and libx265 pick their thread count from the host core count when
ffmpeg is not told one, and the bitstream depends on it, so the same frames
encoded to different bytes on 8, 16 and 32 vCPU nodes and chunks of one
render could differ. Both encoders now pass the thread count from the CPU
quota (Node reads the container limit), which is fixed per pod.

* chore(engine): raise the packed size budget for the encoder thread module
This commit is contained in:
Miguel Ángel
2026-10-23 14:13:57 +00:00
committed by GitHub
parent 2ed882ccf2
commit 132a504b69
8 changed files with 143 additions and 15 deletions
@@ -0,0 +1,9 @@
import { availableParallelism } from "node:os";
/** 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[],
parallelism: number = availableParallelism(),
): void {
args.push("-threads", String(Math.max(1, Math.floor(parallelism))));
}