feat(producer): add codec knob to DistributedRenderConfig

This commit is contained in:
James
2026-05-15 01:57:08 +00:00
committed by James Russo
parent d1e5ac2939
commit eccea88daf
3 changed files with 111 additions and 13 deletions
@@ -209,3 +209,62 @@ describe("plan() — golden planDir + planHash determinism", () => {
TIMEOUT_MS,
);
});
describe("plan() — codec knob", () => {
const TIMEOUT_MS = 30_000;
it(
"defaults `codec` to h264 (libx264-software) for mp4",
async () => {
const planDir = join(runRoot, "plan-codec-default");
mkdirSync(planDir, { recursive: true });
await plan(projectDir, { fps: 30, width: 320, height: 240, format: "mp4" }, planDir);
const encoder = JSON.parse(
readFileSync(join(planDir, "meta", "encoder.json"), "utf-8"),
) as Record<string, unknown>;
expect(encoder.encoder).toBe("libx264-software");
expect(encoder.pixelFormat).toBe("yuv420p");
},
TIMEOUT_MS,
);
it(
'maps `codec: "h265"` to libx265-software for mp4',
async () => {
const planDir = join(runRoot, "plan-codec-h265");
mkdirSync(planDir, { recursive: true });
await plan(
projectDir,
{ fps: 30, width: 320, height: 240, format: "mp4", codec: "h265" },
planDir,
);
const encoder = JSON.parse(
readFileSync(join(planDir, "meta", "encoder.json"), "utf-8"),
) as Record<string, unknown>;
expect(encoder.encoder).toBe("libx265-software");
// SDR 8-bit yuv420p, same as h264. Distributed mode is SDR-only —
// anyone reading this and tempted to bump to 10-bit, that's HDR
// territory and lives in v1.5.
expect(encoder.pixelFormat).toBe("yuv420p");
},
TIMEOUT_MS,
);
it("rejects `codec` with format other than mp4", async () => {
const planDir = join(runRoot, "plan-codec-bad-format");
mkdirSync(planDir, { recursive: true });
let caught: unknown;
try {
await plan(
projectDir,
// @ts-expect-error — runtime check is the test's purpose.
{ fps: 30, width: 320, height: 240, format: "mov", codec: "h265" },
planDir,
);
} catch (err) {
caught = err;
}
expect(caught).toBeInstanceOf(Error);
expect((caught as Error).message).toMatch(/codec.*only valid for format="mp4"/);
});
});