tests/render.test.ts
// Tests for the render tool (executes FFmpeg). The first block needs no FFmpeg. The "real FFmpeg"
// blocks run only when FFmpeg + ffprobe are found (FFMPEG_PATH, or on PATH) and are skipped with the
// reason otherwise, so the suite stays portable. Test media is generated here from FFmpeg's built-in
// lavfi sources (testsrc2 pattern + sine tone), so no third-party footage is involved.
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { execFileSync, spawn } from "node:child_process";
import { mkdtempSync, writeFileSync, readFileSync, existsSync, rmSync, statSync, readdirSync, mkdirSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
// @ts-expect-error -- plain JavaScript agent module without type declarations
import agentModule, { manifest, useNodeRunner } from "../src/index.js";
// @ts-expect-error -- plain JavaScript module without type declarations
import { runRender, locateBinaries } from "../src/run.js";
// The Node.js entry points plug the FFmpeg runner in (0.2.2); this suite calls the agent module directly, so it does too.
useNodeRunner({ runRender, locateBinaries });
const agent: any = agentModule;
const AGENT_DIR = fileURLToPath(new URL("..", import.meta.url));
function findBins(): { bins: { ffmpeg: string; ffprobe: string } | null; reason: string } {
try {
return { bins: locateBinaries(process.env), reason: "" };
} catch (e: any) {
return { bins: null, reason: e.message };
}
}
const { bins: BINS, reason: SKIP_REASON } = findBins();
const REAL = BINS ? "real FFmpeg" : `real FFmpeg (SKIPPED, set FFMPEG_PATH to run: ${SKIP_REASON.split(". ")[0]})`;
const newRoot = () => mkdtempSync(join(tmpdir(), "agentrove-vp-test-"));
const codeOf = async (p: Promise<unknown>) => {
try {
await p;
return "ok";
} catch (e: any) {
return e.code;
}
};
describe("video-production render: checks that need no FFmpeg", () => {
let root: string;
beforeAll(() => {
root = newRoot();
writeFileSync(join(root, "a.mp4"), "not really a video");
writeFileSync(join(root, "exists.mp4"), "x");
writeFileSync(join(root, "subs.srt"), "1\n00:00:00,000 --> 00:00:01,000\nHi\n");
});
afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 }));
const op = (o: any, extra: any = {}) => runRender({ operations: [o], ...extra }, { root, env: { FFMPEG_PATH: join(root, "missing", "ffmpeg.exe") } });
it("declares render as a confirmed local-write tool and keeps the other tools side-effect free", () => {
const r = manifest.tools.find((t: any) => t.name === "render");
expect(r).toMatchObject({ side_effects: "writes_local_files", requires_confirmation: true });
expect(manifest.tools.filter((t: any) => t.name !== "render").every((t: any) => t.side_effects === "none")).toBe(true);
expect(manifest.permissions).toMatchObject({ filesystem: "read_write", network: [], credentials: [] });
});
it("refuses to run without confirm: true", async () => {
await expect(agent.call("render", { operations: [{ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 }] })).rejects.toMatchObject({ code: "confirmation_required" });
});
it("refuses unsafe or impossible paths before looking for FFmpeg", async () => {
expect(await codeOf(op({ op: "trim", input: "../outside.mp4", output: "b.mp4", duration: 1 }))).toBe("path_outside_root");
expect(await codeOf(op({ op: "trim", input: "a.mp4", output: "../escape.mp4", duration: 1 }))).toBe("path_outside_root");
expect(await codeOf(op({ op: "trim", input: "nope.mp4", output: "b.mp4", duration: 1 }))).toBe("invalid_input");
expect(await codeOf(op({ op: "trim", input: "a.mp4", output: "a.mp4", duration: 1 }, { overwrite: true }))).toBe("would_overwrite_input");
expect(await codeOf(op({ op: "trim", input: "a.mp4", output: "./A.MP4".replace("A.MP4", "a.mp4"), duration: 1 }, { overwrite: true }))).toBe("would_overwrite_input");
expect(await codeOf(op({ op: "trim", input: "a.mp4", output: "exists.mp4", duration: 1 }))).toBe("output_exists");
expect(await codeOf(op({ op: "trim", input: "a.mp4", output: "sub/b.mp4", duration: 1 }))).toBe("invalid_input");
expect(await codeOf(op({ op: "trim", input: "http://example.com/a.mp4", output: "b.mp4", duration: 1 }))).toBe("invalid_input");
expect(await codeOf(op({ op: "trim", input: "a.mp4", output: "sub\\a.mp4:hidden.mp4", duration: 1 }))).toBe("invalid_input");
expect(await codeOf(op({ op: "trim", input: "-i.mp4", output: "b.mp4", duration: 1 }))).toBe("invalid_input");
expect(await codeOf(op({ op: "trim", input: "a.mp4", output: "b.webm", duration: 1 }))).toBe("invalid_input"); // stream copy cannot change container
expect(await codeOf(op({ op: "burn_captions", input: "a.mp4", subtitles_text: "#EXTM3U\nhttp://x/y.ts", output: "b.mp4" }))).toBe("invalid_input");
expect(await codeOf(op({ op: "burn_captions", input: "a.mp4", subtitles: "subs.srt", subtitles_text: "1\n00:00:00,000 --> 00:00:01,000\nHi", output: "b.mp4" }))).toBe("invalid_input");
expect(await codeOf(op({ op: "fit", input: "a.mp4", subtitles_text: "1\n00:00:00,000 --> 00:00:01,000\nHi", output: "b.mp4", width: 100, height: 100 }))).toBe("invalid_input");
// A later operation may not overwrite an earlier operation's original input.
expect(await codeOf(runRender({ operations: [{ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 }, { op: "trim", input: "b.mp4", output: "a.mp4", duration: 1 }], overwrite: true }, { root, env: {} }))).toBe("would_overwrite_input");
// Two operations writing the same file.
expect(await codeOf(runRender({ operations: [{ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 }, { op: "trim", input: "a.mp4", output: "b.mp4", duration: 2 }] }, { root, env: {} }))).toBe("invalid_input");
});
it("reports a clear ffmpeg_not_found error for a bad FFMPEG_PATH or an empty PATH", async () => {
const bad = op({ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 });
await expect(bad).rejects.toMatchObject({ code: "ffmpeg_not_found" });
await expect(bad).rejects.toThrow(/FFMPEG_PATH points to .*does not exist.*ffmpeg\.org\/download/);
await expect(runRender({ operations: [{ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 }] }, { root, env: { PATH: "" } })).rejects.toThrow(/FFmpeg not found: FFMPEG_PATH is not set and no ffmpeg/);
await expect(runRender({ operations: [{ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 }] }, { root, env: { FFMPEG_PATH: "ffmpeg" } })).rejects.toThrow(/must be the absolute path/);
await expect(runRender({ operations: [{ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 }] }, { root, env: { FFMPEG_PATH: join(root, "a.mp4") } })).rejects.toThrow(/must be the absolute path/);
expect(existsSync(join(root, "b.mp4"))).toBe(false);
});
it("reports ffmpeg_not_found through the CLI when FFMPEG_PATH is wrong", () => {
writeFileSync(join(root, "in.json"), JSON.stringify({ confirm: true, operations: [{ op: "trim", input: "a.mp4", output: "b.mp4", duration: 1 }] }));
let err = "";
try {
execFileSync(process.execPath, [join(AGENT_DIR, "bin", "cli.js"), "render", "--input", "in.json"], { cwd: root, env: { ...process.env, FFMPEG_PATH: join(root, "nope", "ffmpeg.exe"), AGENTROVE_MEDIA_ROOT: "" }, stdio: "pipe" });
} catch (e: any) {
err = String(e.stderr);
}
expect(JSON.parse(err)).toMatchObject({ error: "ffmpeg_not_found" });
});
});
// ------------------------------------------------------------------------------------------------
// Real FFmpeg
// ------------------------------------------------------------------------------------------------
const ffprobe = (file: string) =>
JSON.parse(execFileSync(BINS!.ffprobe, ["-v", "error", "-show_entries", "format=format_name,duration:stream=codec_type,codec_name,width,height,display_aspect_ratio", "-of", "json", file], { encoding: "utf8" }));
const codecs = (j: any) => j.streams.map((s: any) => s.codec_name).sort().join(",");
const vstream = (j: any) => j.streams.find((s: any) => s.codec_type === "video");
/** Mean absolute difference of a grayscale crop of the frame at t = 1 s between two videos. */
function regionDiff(a: string, b: string, crop: string) {
const grab = (f: string) => execFileSync(BINS!.ffmpeg, ["-v", "error", "-ss", "1", "-i", f, "-frames:v", "1", "-vf", `${crop},format=gray`, "-f", "rawvideo", "-"], { maxBuffer: 16 * 1024 * 1024 });
const x = grab(a);
const y = grab(b);
let d = 0;
for (let i = 0; i < x.length; i++) d += Math.abs(x[i] - y[i]);
return d / x.length;
}
function makeClip(root: string, name: string, seconds: number, opts: { size?: string; freq?: number; sar?: string; audio?: boolean } = {}) {
const args = ["-v", "error", "-y", "-f", "lavfi", "-i", `testsrc2=size=${opts.size ?? "640x360"}:rate=30:duration=${seconds}`];
if (opts.audio !== false) args.push("-f", "lavfi", "-i", `sine=frequency=${opts.freq ?? 440}:duration=${seconds}`);
if (opts.sar) args.push("-vf", `setsar=${opts.sar}`);
args.push("-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p");
if (opts.audio !== false) args.push("-c:a", "aac", "-shortest");
args.push(join(root, name));
execFileSync(BINS!.ffmpeg, args, { stdio: "pipe" });
}
describe.skipIf(!BINS)(`video-production render: ${REAL} end to end`, () => {
let root: string;
const saved: Record<string, string | undefined> = {};
beforeAll(() => {
root = newRoot();
makeClip(root, "a.mp4", 4, { freq: 440 });
makeClip(root, "b.mp4", 3, { freq: 660 });
makeClip(root, "c.mp4", 2, { freq: 880 });
for (const k of ["FFMPEG_PATH", "AGENTROVE_MEDIA_ROOT"]) saved[k] = process.env[k];
process.env.FFMPEG_PATH = BINS!.ffmpeg;
process.env.AGENTROVE_MEDIA_ROOT = root;
}, 60000);
afterAll(() => {
for (const [k, v] of Object.entries(saved)) {
if (v === undefined) delete process.env[k];
else process.env[k] = v;
}
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
});
it("exports captions, burns them in, trims, concatenates and fits to 9:16 (MP4) and 16:9 (WebM)", async () => {
const script = { title: "Render test", segments: [{ start: 0, end: 3.5, text: "Captions are burned into this test pattern.", kind: "hook" }] };
const caps = await agent.call("export_captions", { script });
writeFileSync(join(root, "captions.srt"), caps.captions_srt); // the user saves the SRT next to the media
const out = await agent.call("render", {
confirm: true,
operations: [
{ op: "burn_captions", input: "a.mp4", subtitles: "captions.srt", output: "captioned.mp4", font_size: 20, preset: "veryfast" },
{ op: "trim", input: "captioned.mp4", start: 0.5, end: 3.5, reencode: true, output: "trimmed.mp4", preset: "veryfast" },
{ op: "concat", method: "filter", inputs: ["trimmed.mp4", "b.mp4"], output: "joined.mp4", preset: "veryfast" },
{ op: "fit", input: "joined.mp4", width: 360, height: 640, output: "vertical.mp4", preset: "veryfast" },
{ op: "fit", input: "joined.mp4", width: 640, height: 360, mode: "crop", output: "wide.webm", preset: "ultrafast" },
],
});
expect(out.executed).toBe(true);
expect(out.ffmpeg.version).toMatch(/^ffmpeg version/);
expect(out.results.map((r: any) => [r.op, r.output, r.exit_code])).toEqual([
["burn_captions", "captioned.mp4", 0],
["trim", "trimmed.mp4", 0],
["concat", "joined.mp4", 0],
["fit", "vertical.mp4", 0],
["fit", "wide.webm", 0],
]);
// Every argv ran without a shell and passed the allowlist; inputs were locked to the file protocol.
for (const r of out.results) {
expect(r.argv[0]).toBe(BINS!.ffmpeg);
expect(r.argv).toContain("-nostdin");
expect(r.argv[r.argv.indexOf("-i") - 2]).toBe("-protocol_whitelist");
expect(r.argv).toContain("-fs");
}
// Independent ffprobe checks of every output.
const cap = ffprobe(join(root, "captioned.mp4"));
expect(codecs(cap)).toBe("aac,h264");
expect(Number(cap.format.duration)).toBeCloseTo(4, 0);
const trim = ffprobe(join(root, "trimmed.mp4"));
expect(Number(trim.format.duration)).toBeGreaterThan(2.9);
expect(Number(trim.format.duration)).toBeLessThan(3.15);
const joined = ffprobe(join(root, "joined.mp4"));
expect(Number(joined.format.duration)).toBeGreaterThan(5.9);
expect(Number(joined.format.duration)).toBeLessThan(6.2);
const vert = ffprobe(join(root, "vertical.mp4"));
expect(codecs(vert)).toBe("aac,h264");
expect(vstream(vert)).toMatchObject({ width: 360, height: 640, display_aspect_ratio: "9:16" });
const wide = ffprobe(join(root, "wide.webm"));
expect(wide.format.format_name).toBe("matroska,webm");
expect(codecs(wide)).toBe("opus,vp9");
expect(vstream(wide)).toMatchObject({ width: 640, height: 360, display_aspect_ratio: "16:9" });
// The tool's own metadata agrees.
expect(out.results[3].output_metadata.streams.find((s: any) => s.codec_type === "video")).toMatchObject({ codec_name: "h264", width: 360, height: 640 });
expect(out.results[4].output_metadata).toMatchObject({ container: "webm", format_name: "matroska,webm" });
// The captions are really in the picture: the bottom band changed, the top band did not.
const bottom = regionDiff(join(root, "a.mp4"), join(root, "captioned.mp4"), "crop=640:100:0:260");
const top = regionDiff(join(root, "a.mp4"), join(root, "captioned.mp4"), "crop=640:100:0:0");
expect(bottom).toBeGreaterThan(2);
expect(bottom).toBeGreaterThan(top * 5);
// Inputs are untouched and no temporary caption/list files were left in the media folder.
expect(readdirSync(root).sort()).toEqual(["a.mp4", "b.mp4", "c.mp4", "captioned.mp4", "captions.srt", "joined.mp4", "trimmed.mp4", "vertical.mp4", "wide.webm"]);
}, 180000);
it("stream-copies with the concat demuxer, transcodes to WebM and trims by stream copy", async () => {
const out = await runRender(
{
operations: [
{ op: "trim", input: "b.mp4", start: 0, duration: 2, output: "b2.mp4" },
{ op: "concat", inputs: ["b2.mp4", "c.mp4"], output: "copy-joined.mp4" },
{ op: "transcode", input: "c.mp4", output: "c.webm", preset: "ultrafast" },
{ op: "transcode", input: "c.webm", output: "c-back.mp4", preset: "veryfast" },
],
},
{ root },
);
expect(out.results[1].argv).toEqual(expect.arrayContaining(["-f", "concat", "-safe", "0", "-c", "copy"]));
const j = ffprobe(join(root, "copy-joined.mp4"));
expect(codecs(j)).toBe("aac,h264");
expect(Number(j.format.duration)).toBeGreaterThan(3.8);
expect(Number(j.format.duration)).toBeLessThan(4.3);
expect(codecs(ffprobe(join(root, "c.webm")))).toBe("opus,vp9");
// WebM (Opus) back to MP4: audio is re-encoded to AAC, not copied.
expect(codecs(ffprobe(join(root, "c-back.mp4")))).toBe("aac,h264");
expect(out.results[3].argv).toEqual(expect.arrayContaining(["-c:a", "aac"]));
}, 180000);
it("accepts caption text inline (CLI, no subtitles file in the media folder) and keeps a video without audio silent", async () => {
makeClip(root, "silent.mp4", 2, { audio: false });
const caps = await agent.call("export_captions", { script: { segments: [{ start: 0, end: 2, text: "Inline captions" }] } });
writeFileSync(join(root, "..", `vp-cli-${process.pid}.json`), JSON.stringify({ confirm: true, operations: [{ op: "burn_captions", input: "silent.mp4", subtitles_text: caps.captions_vtt, output: "silent-captioned.webm", preset: "ultrafast" }] }));
const stdout = execFileSync(process.execPath, [join(AGENT_DIR, "bin", "cli.js"), "render", "--input", join(root, "..", `vp-cli-${process.pid}.json`)], { cwd: root, env: { ...process.env, AGENTROVE_MEDIA_ROOT: "" }, encoding: "utf8" });
rmSync(join(root, "..", `vp-cli-${process.pid}.json`), { force: true });
const res = JSON.parse(stdout);
expect(res.results[0].argv).toContain("-an");
const p = ffprobe(join(root, "silent-captioned.webm"));
expect(codecs(p)).toBe("vp9");
expect(readdirSync(root).some((f) => /\.vtt$/.test(f))).toBe(false);
}, 120000);
it("works over MCP stdio: tools/list includes render and tools/call executes after confirmation", async () => {
const child = spawn(process.execPath, [join(AGENT_DIR, "bin", "mcp.js")], { cwd: root, env: { ...process.env, AGENTROVE_MEDIA_ROOT: "" }, stdio: ["pipe", "pipe", "pipe"] });
const replies: any[] = [];
let buf = "";
child.stdout.on("data", (d) => {
buf += d;
let nl;
while ((nl = buf.indexOf("\n")) >= 0) {
replies.push(JSON.parse(buf.slice(0, nl)));
buf = buf.slice(nl + 1);
}
});
const send = (m: any) => child.stdin.write(JSON.stringify(m) + "\n");
const waitFor = async (id: number) => {
for (let t = 0; t < 600; t++) {
const r = replies.find((x) => x.id === id);
if (r) return r;
await new Promise((res) => setTimeout(res, 100));
}
throw new Error(`no reply ${id}`);
};
send({ jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "test", version: "0" } } });
send({ jsonrpc: "2.0", method: "notifications/initialized" });
send({ jsonrpc: "2.0", id: 2, method: "tools/list" });
send({ jsonrpc: "2.0", id: 3, method: "tools/call", params: { name: "render", arguments: { operations: [{ op: "trim", input: "c.mp4", output: "mcp.mp4", duration: 1, reencode: true, preset: "ultrafast" }] } } });
send({ jsonrpc: "2.0", id: 4, method: "tools/call", params: { name: "render", arguments: { confirm: true, operations: [{ op: "trim", input: "c.mp4", output: "mcp.mp4", duration: 1, reencode: true, preset: "ultrafast" }] } } });
try {
expect((await waitFor(1)).result.serverInfo).toMatchObject({ name: "agentrove.video-production", version: manifest.version });
expect((await waitFor(2)).result.tools.map((t: any) => t.name)).toContain("render");
const refused = await waitFor(3);
expect(refused.result.isError).toBe(true);
expect(refused.result.content[0].text).toMatch(/^confirmation_required/);
const ran = await waitFor(4);
expect(ran.result.isError).toBe(false);
expect(ran.result.structuredContent.results[0].output_metadata.duration_seconds).toBeCloseTo(1, 0);
expect(existsSync(join(root, "mcp.mp4"))).toBe(true);
} finally {
// Wait for the server to exit: Windows cannot delete a folder that a running process uses as cwd.
await new Promise((res) => {
child.once("exit", res);
child.stdin.end();
child.kill();
});
}
}, 120000);
});
describe.skipIf(!BINS)(`video-production render: ${REAL} failures and limits`, () => {
let root: string;
beforeAll(() => {
root = newRoot();
makeClip(root, "a.mp4", 4);
makeClip(root, "small.mp4", 2, { size: "320x180" });
makeClip(root, "wide-pixels.mp4", 2, { sar: "2" }); // same 640x360 size, but 2:1 pixels
writeFileSync(join(root, "fake.mp4"), "this is text, not video\n");
writeFileSync(join(root, "playlist.mp4"), "#EXTM3U\n#EXT-X-TARGETDURATION:1\n#EXTINF:1,\nhttp://127.0.0.1:9/x.ts\n#EXT-X-ENDLIST\n");
writeFileSync(join(root, "notes.srt"), "These are meeting notes, not captions.\n");
mkdirSync(join(root, "out"));
}, 60000);
afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 }));
const one = (o: any, extra: any = {}, opts: any = {}) => runRender({ operations: [o], ...extra }, { root, ...opts });
it("refuses files that are not video (text, disguised playlist) and subtitles that are not captions", async () => {
await expect(one({ op: "transcode", input: "fake.mp4", output: "x.mp4" })).rejects.toMatchObject({ code: "invalid_media" });
await expect(one({ op: "transcode", input: "playlist.mp4", output: "x.mp4" })).rejects.toMatchObject({ code: "invalid_media" });
await expect(one({ op: "burn_captions", input: "a.mp4", subtitles: "notes.srt", output: "x.mp4" })).rejects.toMatchObject({ code: "invalid_media" });
expect(existsSync(join(root, "x.mp4"))).toBe(false);
}, 60000);
it("reports a failing FFmpeg command with its exit code and stderr tail and removes the partial output", async () => {
// The concat filter refuses inputs whose sample aspect ratios differ (render does not pre-check
// SAR), so this is a genuine FFmpeg failure with a non-zero exit code.
const p = one({ op: "concat", method: "filter", inputs: ["a.mp4", "wide-pixels.mp4"], output: "out/sar-mismatch.mp4", preset: "ultrafast" });
await expect(p).rejects.toMatchObject({ code: "ffmpeg_failed" });
await expect(p).rejects.toThrow(/FFmpeg exited with code -?\d+; its partial output was removed\. Last FFmpeg messages:\n[\s\S]*(do not match|Nothing was written)/);
expect(existsSync(join(root, "out", "sar-mismatch.mp4"))).toBe(false);
}, 60000);
it("reports which earlier operations completed when a later one fails", async () => {
const p = runRender({ operations: [{ op: "trim", input: "a.mp4", duration: 1, output: "out/first.mp4" }, { op: "concat", method: "filter", inputs: ["out/first.mp4", "small.mp4"], output: "out/second.mp4" }] }, { root });
await expect(p).rejects.toMatchObject({ code: "incompatible_inputs" });
await expect(p).rejects.toThrow(/same resolution[\s\S]*Completed before the failure: out\/first\.mp4/);
}, 60000);
it("enforces duration, size and time limits", async () => {
await expect(runRender({ operations: [{ op: "concat", method: "filter", inputs: ["a.mp4", "a.mp4"], output: "long.mp4" }], max_output_seconds: 5 }, { root })).rejects.toMatchObject({ code: "limit_exceeded" });
expect(existsSync(join(root, "long.mp4"))).toBe(false);
await expect(one({ op: "transcode", input: "a.mp4", output: "big.mp4", crf: 0, preset: "ultrafast" }, {}, { maxOutputBytes: 20000 })).rejects.toMatchObject({ code: "limit_exceeded" });
expect(existsSync(join(root, "big.mp4"))).toBe(false);
await expect(one({ op: "transcode", input: "a.mp4", output: "slow.webm", preset: "veryslow" }, {}, { timeoutMs: 300 })).rejects.toMatchObject({ code: "timeout" });
expect(existsSync(join(root, "slow.webm"))).toBe(false);
await expect(one({ op: "trim", input: "a.mp4", start: 10, duration: 1, output: "late.mp4" })).rejects.toThrow(/at or after the end/);
}, 120000);
it("keeps an existing output unless overwrite is true, and then replaces only that output", async () => {
await one({ op: "trim", input: "small.mp4", duration: 1, output: "out/keep.mp4" });
const before = statSync(join(root, "out", "keep.mp4")).size;
await expect(one({ op: "trim", input: "small.mp4", duration: 1.5, output: "out/keep.mp4" })).rejects.toMatchObject({ code: "output_exists" });
expect(statSync(join(root, "out", "keep.mp4")).size).toBe(before);
const r = await one({ op: "trim", input: "small.mp4", duration: 1.5, output: "out/keep.mp4", reencode: true, preset: "ultrafast" }, { overwrite: true });
expect(r.results[0].argv).toContain("-y");
expect(r.results[0].notes.join(" ")).toMatch(/Replaced the existing output/);
expect(readFileSync(join(root, "small.mp4")).length).toBeGreaterThan(0);
}, 60000);
});