{
  "clide": 1,
  "name": "Sharp GIF",
  "description": "Turn a video clip into a crisp animated GIF, with an optional trim.",
  "input": [
    { "id": "video", "type": "file", "label": "Video", "required": true, "extensions": ["mp4", "mov", "webm", "mkv"] },
    { "id": "width", "type": "select", "label": "Width", "options": ["320", "480", "640", "800"], "default": "480" },
    { "id": "fps", "type": "number", "label": "Frames per second", "default": 12, "min": 1, "max": 30 },
    { "id": "start", "type": "number", "label": "Start at (seconds)", "min": 0, "help": "Leave empty to start at the beginning." },
    { "id": "seconds", "type": "number", "label": "Length (seconds)", "min": 0.1, "help": "Leave empty for the whole clip." },
    { "id": "saveIn", "type": "folder", "label": "Save in", "required": true },
    { "id": "fileName", "type": "text", "label": "File name", "placeholder": "Same as the video", "help": "Without .gif. Leave empty to name it after the video." }
  ],
  "run": {
    "command": "bun",
    "args": [
      "./sharp-gif.ts",
      "--fps", "{{fps}}",
      "--width", "{{width}}",
      { "when": "start", "args": ["--start", "{{start}}"] },
      { "when": "seconds", "args": ["--seconds", "{{seconds}}"] },
      "--dest", "{{saveIn}}",
      { "when": "fileName", "args": ["--name", "{{fileName}}"] },
      "{{video}}"
    ]
  },
  "requires": [
    {
      "command": "ffmpeg",
      "why": "Reads the video, builds a palette and writes the GIF.",
      "install": {
        "macos": "brew install ffmpeg",
        "windows": "winget install --id Gyan.FFmpeg",
        "linux": "sudo apt install ffmpeg"
      },
      "url": "https://ffmpeg.org/download.html"
    }
  ],
  "output": [
    { "id": "gif", "type": "file", "label": "GIF", "from": "match", "pattern": "Saved to (.+)" },
    { "id": "size", "type": "text", "label": "Size", "from": "match", "pattern": "Size: (.+)" }
  ]
}
