diff --git a/electron/ipc/handlers/__tests__/demo.handlers.test.ts b/electron/ipc/handlers/__tests__/demo.handlers.test.ts index 633a0ff86..31b98f7c9 100644 --- a/electron/ipc/handlers/__tests__/demo.handlers.test.ts +++ b/electron/ipc/handlers/__tests__/demo.handlers.test.ts @@ -22,7 +22,7 @@ const fsMock = vi.hoisted(() => ({ vi.mock("fs/promises", () => fsMock); vi.mock("fs", () => ({ - readdirSync: vi.fn(() => ["frame_0001.png", "frame_0002.png", "frame_0003.png"]), + readdirSync: vi.fn(() => ["frame-000001.png", "frame-000002.png", "frame-000003.png"]), mkdirSync: vi.fn(), })); @@ -196,7 +196,27 @@ describe("registerDemoHandlers", () => { outputPath: "/tmp/out.mp4", preset: "youtube-4k", }) - ).rejects.toThrow("No PNG frames matching frame_NNNN.png found"); + ).rejects.toThrow("No PNG frames matching frame-NNNNNN.png found"); + }); + + it("rejects old underscore-format frame names", async () => { + const fsMod = await import("fs"); + (fsMod.readdirSync as ReturnType).mockReturnValueOnce([ + "frame_0001.png", + "frame_0002.png", + "frame_0003.png", + ]); + + const handler = getEncodeHandler(); + const event = makeEvent(); + + await expect( + handler(event, { + framesDir: "/tmp/old-format", + outputPath: "/tmp/out.mp4", + preset: "youtube-4k", + }) + ).rejects.toThrow("No PNG frames matching frame-NNNNNN.png found"); }); it("rejects on spawn error event", async () => { @@ -303,7 +323,7 @@ describe("registerDemoHandlers", () => { expect(spawnMock).toHaveBeenCalledWith( expect.any(String), - expect.arrayContaining(["-c:v", "libx264"]), + expect.arrayContaining(["-i", "/tmp/frames/frame-%06d.png", "-c:v", "libx264"]), expect.any(Object) ); }); diff --git a/electron/ipc/handlers/demo.ts b/electron/ipc/handlers/demo.ts index 3d3851e57..2dfe3541a 100644 --- a/electron/ipc/handlers/demo.ts +++ b/electron/ipc/handlers/demo.ts @@ -315,20 +315,20 @@ export function registerDemoHandlers(deps: HandlerDependencies): () => void { const { framesDir, outputPath, preset, fps = 30 } = payload; const presetConfig = ENCODE_PRESETS[preset]; - const framePattern = /^frame_\d{4}\.png$/; + const framePattern = /^frame-\d{6}\.png$/; const pngFiles = fs .readdirSync(framesDir) .filter((f) => framePattern.test(f)) .sort(); if (pngFiles.length === 0) { - throw new Error(`No PNG frames matching frame_NNNN.png found in ${framesDir}`); + throw new Error(`No PNG frames matching frame-NNNNNN.png found in ${framesDir}`); } const totalFrames = pngFiles.length; fs.mkdirSync(path.dirname(outputPath), { recursive: true }); const startTime = Date.now(); - const inputPattern = path.join(framesDir, "frame_%04d.png"); + const inputPattern = path.join(framesDir, "frame-%06d.png"); const args = [ "-y",