{
  "name": "audio-extract",
  "summary": "Extracts the audio track from a video (or any container) and returns it in a chosen audio format.",
  "rationale": "Demuxing and re-encoding an audio track 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": 94000,
  "max_timeout_seconds": 115,
  "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 a video or audio file, up to 2048 characters, in a recognised container (MP4/MOV, Matroska/WebM, AVI, Ogg, WAV, FLAC, AIFF or MP3); the selected audio stream must last at most 3600 seconds."
      },
      "stream": {
        "default": 0,
        "description": "Zero-based index among the audio streams only (0 is the first audio track), 0 to 63; an index the file does not have is refused as unprocessable.",
        "type": "integer",
        "minimum": 0,
        "maximum": 63
      },
      "to": {
        "default": "mp3",
        "description": "Output format for the extracted track: wav (16-bit PCM), mp3 (LAME), flac, aac (ADTS stream) or opus (in an Ogg container); defaults to mp3.",
        "type": "string",
        "enum": [
          "wav",
          "mp3",
          "flac",
          "aac",
          "opus"
        ]
      }
    },
    "required": [
      "url"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/av/probe-clip.mov",
    "stream": 0,
    "to": "wav"
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/av/probe-clip.mov",
    "bytes": 33850,
    "container": "mp4",
    "stream_index": 0,
    "format": "wav",
    "audio_bytes": 32044,
    "audio_base64": "UklGRiR9AABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YQB9AAAA4ADo..."
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}