MiniMax-AI/skills · warning · SystemExit

ERROR: -o/--output only works with a single input file

Error message

ERROR: -o/--output only works with a single input file

What it means

Argument-validation guard in main(): the user passed -o/--output (a single destination path) together with more than one input file. The script derives per-input output names when batching, so an explicit -o is only meaningful for exactly one input; it refuses rather than silently overwriting one file for all inputs.

Source

Thrown at skills/gif-sticker-maker/scripts/convert_mp4_to_gif.py:69

    finally:
        if os.path.exists(palette):
            os.remove(palette)

    size = os.path.getsize(output_path)
    print(f"OK: {size:,} bytes -> {output_path}")
    return True


def main():
    p = argparse.ArgumentParser(description="Batch MP4 → GIF converter (ffmpeg two-pass palette)")
    p.add_argument("inputs", nargs="+", help="MP4 file(s) to convert")
    p.add_argument("-o", "--output", default=None, help="Output path (only for single file input)")
    p.add_argument("--fps", type=int, default=15, help="GIF frame rate (default: 15)")
    p.add_argument("--width", type=int, default=360, help="GIF width in pixels, height auto-scaled (default: 360)")
    args = p.parse_args()

    if args.output and len(args.inputs) > 1:
        raise SystemExit("ERROR: -o/--output only works with a single input file")

    check_ffmpeg()

    ok, fail = 0, 0
    for mp4 in args.inputs:
        if args.output:
            gif_path = args.output
        else:
            gif_path = os.path.splitext(mp4)[0] + ".gif"

        if mp4_to_gif(mp4, gif_path, fps=args.fps, width=args.width):
            ok += 1
        else:
            fail += 1

    print(f"\nDone: {ok} converted, {fail} failed")

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. Drop -o for batch runs so each input gets a sibling .gif (input.mp4 -> input.gif): `convert_mp4_to_gif.py a.mp4 b.mp4`.
  2. If you need custom names for many files, loop and call the converter once per file with its own -o.
  3. If you truly want one output, pass exactly one input with -o: `convert_mp4_to_gif.py single.mp4 -o out.gif`.

Example fix

// before
$ python convert_mp4_to_gif.py *.mp4 -o out.gif
ERROR: -o/--output only works with a single input file

// after (batch, auto-named)
$ python convert_mp4_to_gif.py *.mp4
// after (single, custom name)
$ python convert_mp4_to_gif.py single.mp4 -o out.gif
Defensive patterns

Strategy: validation

Validate before calling

def plan_outputs(inputs, output=None):
    """Return a list of (input, output) pairs, enforcing the single-output rule."""
    if output and len(inputs) > 1:
        raise ValueError("-o/--output is only valid with exactly one input file")
    return [(i, output if output else os.path.splitext(i)[0] + ".gif") for i in inputs]

Type guard

def is_single_output_safe(inputs: list, output) -> bool:
    """True when -o may be used: exactly one input, or no -o at all."""
    return output is None or len(inputs) == 1

Try / catch

import subprocess, sys
r = subprocess.run([sys.executable, "convert_mp4_to_gif.py", *inputs, "-o", out], capture_output=True, text=True)
if r.returncode != 0 and "only works with a single input file" in (r.stderr or r.stdout or ""):
    # drop -o and let each input get an auto-named .gif
    subprocess.run([sys.executable, "convert_mp4_to_gif.py", *inputs], check=True)
else:
    r.check_returncode()

Prevention

When it happens

Trigger: Invoking the converter with multiple inputs and -o, e.g. `convert_mp4_to_gif.py a.mp4 b.mp4 -o out.gif` — there is no unambiguous single output for two inputs.

Common situations: Glob expansion (`*.mp4 -o out.gif`) producing multiple files while a single -o was intended; copy-pasting a single-file example then adding more inputs; scripting a batch but leaving a stale -o flag.

Related errors


AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13). Data as JSON: /api/errors/27e1f375f1a22c4e. Report an issue: GitHub.