Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(cli): refuse --quality and --fps on a GIF export, as exportVideo does

EtienneLescotfd05806fc2d6
diff --git a/electron/cli/args.test.ts b/electron/cli/args.test.ts
index 7796e8114..3e694349b 100644
--- a/electron/cli/args.test.ts
+++ b/electron/cli/args.test.ts
@@ -166,6 +166,12 @@ describe("parseCliArgs", () => {
});
expect(parse(["export", "a.openscreen", "--no-gif-loop"])).toMatchObject({ gifLoop: false });
expect(parse(["export", "a.openscreen", "--gif-loop"])).toMatchObject({ gifLoop: true });
+ expect(parse(["export", "a.openscreen", "-o", "x.gif", "--quality", "good"])).toMatchObject({
+ kind: "error",
+ });
+ expect(parse(["export", "a.openscreen", "--format", "gif", "--fps", "30"])).toMatchObject({
+ kind: "error",
+ });
});
it("parses --auto-zoom", () => {
diff --git a/electron/cli/args.ts b/electron/cli/args.ts
index 6e9a685b2..aaf8d38ef 100644
--- a/electron/cli/args.ts
+++ b/electron/cli/args.ts
@@ -327,6 +327,13 @@ function parseExport(args: string[], cwd: string): CliCommand {
if (request.audioPath && request.format === "gif") {
throw new Error("--audio is only supported for MP4 exports");
}
+ // The MP4 options: a GIF is sized from the source and has its own frame rate.
+ if (request.format === "gif" && request.quality) {
+ throw new Error("--quality is only supported for MP4 exports");
+ }
+ if (request.format === "gif" && args.includes("--fps")) {
+ throw new Error("--fps is only supported for MP4 exports (use --gif-fps)");
+ }
return request;
}
diff --git a/src/cli/CliExportRunner.tsx b/src/cli/CliExportRunner.tsx
index 960b43643..e206e1b83 100644
--- a/src/cli/CliExportRunner.tsx
+++ b/src/cli/CliExportRunner.tsx
@@ -248,6 +248,11 @@ async function runExport(request: CliExportRequest): Promise<CliDoneResult> {
"--audio is only supported for MP4 exports (this project's stored format is gif; pass --format mp4)",
);
}
+ if (request.quality && format === "gif") {
+ throw new Error(
+ "--quality is only supported for MP4 exports (this project's stored format is gif; a GIF is sized with --gif-size)",
+ );
+ }
const quality = request.quality ?? editor.exportQuality;
const gifFrameRate = request.gifFrameRate ?? editor.gifFrameRate;
const gifSizePreset = request.gifSizePreset ?? editor.gifSizePreset;