{
  "name": "waveform-data",
  "summary": "Reduces an audio file to a fixed number of normalised waveform peaks for drawing, without shipping samples.",
  "rationale": "Decoding audio to peaks needs ffmpeg AND a hardened fetch: an agent that pulls the URL itself walks past every SSRF control, and carrying an ffmpeg per call is not something an agent does inline.",
  "family": "av",
  "price_usd": "0.003",
  "free": false,
  "timeout_ms": 90000,
  "max_timeout_seconds": 111,
  "input_schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "maxLength": 2048,
        "format": "uri",
        "description": "Absolute http(s) URL of an audio or video file, up to 2048 characters, in a recognised container (MP4/MOV, Matroska/WebM, AVI, Ogg, WAV, FLAC, AIFF or MP3); its first audio stream is decoded to mono."
      },
      "peaks": {
        "default": 200,
        "description": "Number of buckets to return, 1 to 4000, default 200; each is the largest absolute sample in an equal slice of the track, scaled to 0..1 against 16-bit full scale.",
        "type": "integer",
        "minimum": 1,
        "maximum": 4000
      },
      "sample_rate": {
        "default": 8000,
        "description": "Decode rate in Hz, one of 4000, 8000, 11025, 16000, 22050 or 44100, default 8000; it sets sample_count and how finely each bucket is scanned.",
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      }
    },
    "required": [
      "url"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/av/waveform-beeps.wav",
    "peaks": 20,
    "sample_rate": 8000
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/av/waveform-beeps.wav",
    "bytes": 32044,
    "container": "wav",
    "sample_rate": 8000,
    "sample_count": 16000,
    "duration_seconds": 2,
    "peak_count": 20,
    "peaks": [
      0.25,
      0.25,
      0.25,
      0.25,
      0,
      0,
      0,
      0.5,
      0.5,
      0.5,
      0.5,
      0,
      0,
      0,
      0.8999,
      0.8999,
      0.8999,
      0.8999,
      0,
      0
    ]
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}