fix: budget workers for expensive captures

This commit is contained in:
Miguel Ángel
2026-04-27 22:53:27 -04:00
parent 37827cdaec
commit 36b3fc8cd9
10 changed files with 978 additions and 101 deletions
+14 -4
View File
@@ -5,7 +5,6 @@ const BASE: DockerRenderOptions = {
fps: 30,
quality: "standard",
format: "mp4",
workers: 4,
gpu: false,
hdr: false,
crf: undefined,
@@ -43,17 +42,28 @@ describe("buildDockerRunArgs", () => {
"standard",
"--format",
"mp4",
"--workers",
"4",
]
`);
});
it("omits --workers when auto sizing should happen inside the container", () => {
const args = buildDockerRunArgs({ ...FIXED_INPUT, options: BASE });
expect(args).not.toContain("--workers");
});
it("matches snapshot when every renderer flag is enabled", () => {
expect(
buildDockerRunArgs({
...FIXED_INPUT,
options: { ...BASE, gpu: true, hdr: true, crf: 18, videoBitrate: undefined, quiet: true },
options: {
...BASE,
workers: 4,
gpu: true,
hdr: true,
crf: 18,
videoBitrate: undefined,
quiet: true,
},
}),
).toMatchInlineSnapshot(`
[
+2 -3
View File
@@ -22,7 +22,7 @@ export interface DockerRenderOptions {
fps: 24 | 30 | 60;
quality: "draft" | "standard" | "high";
format: "mp4" | "webm" | "mov";
workers: number;
workers?: number;
gpu: boolean;
hdr: boolean;
crf?: number;
@@ -54,8 +54,7 @@ export function buildDockerRunArgs(input: DockerRunArgsInput): string[] {
options.quality,
"--format",
options.format,
"--workers",
String(options.workers),
...(options.workers != null ? ["--workers", String(options.workers)] : []),
...(options.crf != null ? ["--crf", String(options.crf)] : []),
...(options.videoBitrate ? ["--video-bitrate", options.videoBitrate] : []),
...(options.quiet ? ["--quiet"] : []),