catalogue / tools / Audio & video / AVI to FLAC

Convert AVI to FLAC

To convert AVI to FLAC, send one POST to /v1/audio-convert with the AVI source and "to": "flac" in the body. Left out, "to" falls back to its default "mp3", so a FLAC request has to send it. Each call costs $0.003 in USDC on Base via x402, with no account and no API key. The source file can be up to 100 MB and 60 min (3,600 s) long.

Endpoint
POST /v1/audio-convert
Price
$0.003 per call

01Limits

LimitValue
Largest source file100 MB (104,857,600 bytes)
Longest input60 min (3,600 s)
Timeout94 s
Source formatsAIFF, AVI, FLAC, MKV, MP3, MP4, Ogg, WAV
Output formatsAAC, FLAC, MP3, Opus, WAV

02Example

A real AVI to FLAC run of audio-convert.

Request
POST /v1/audio-convert
content-type: application/json
payment-signature: <base64 x402 payload>

{
  "url": "https://grist.tools/samples/av/pair-clip.avi",
  "to": "flac"
}
Response
200 OK
payment-response: <base64 settlement receipt>

{
  "source_url": "https://grist.tools/samples/av/pair-clip.avi",
  "bytes": 76302,
  "source_container": "avi",
  "format": "flac",
  "bitrate_kbps": null,
  "sample_rate": null,
  "audio_bytes": 16585,
  "audio_base64": "ZkxhQwAAACICQAJAAAAAAASVAfQA8AAAAAAAAAAAAAAAAAAAAAAAAAAABAAADgYA..."
}

Source file: av/pair-clip.avi, 74.5 KB (76,302 bytes). 4 s AVI file made by ffmpeg: a 64x36 PNG video stream at 1 fps (a slate field with a small amber square moving right) and a mono 8 kHz 16-bit PCM audio track of two 500 Hz triangle beeps; no subtitle stream. The recorded run returned 16.2 KB (16,585 bytes) of FLAC, 22% of the source size, with the source read as the avi container. Decoded, the FLAC in audio_base64 opens with 66 4C 61 43 00 00 00 22 02 40 02 40 (ASCII fLaC). Recorded with ffmpeg 8.1.2.

In the sample itself, the avih main header sets 1,000,000 microseconds per frame, 4 frames, 2 streams and a 64 by 36 frame; the stream headers are vids with handler MPNG, rate 1 over scale 1 and auds, rate 8,000 over scale 1, format tag 0x0001 at 8,000 Hz and 16 bits; an idx1 chunk indexes the frames at the end of the file. In the returned FLAC: its 34-byte STREAMINFO block, in its own field order, declares blocks of 576 samples, a largest frame of 1,173 bytes, 8,000 Hz, 1 channel, 16 bits per sample and a total sample count of 0, which the format reserves for a length the encoder did not write back. Its MD5 signature of the decoded audio is all zeros, the value for a signature that was not computed. The next metadata block is VORBIS_COMMENT, 14 bytes long.

03Format notes

AVI as a source

AVI is a RIFF container whose form type at byte eight is the four characters AVI followed by a space. Grist checks that form type, not the extension, before ffmpeg sees the file. Three of the conversion services on these pages accept it. audio-convert reads the first audio stream and ignores video; video-thumbnail seeks at the demuxer and decodes exactly one frame with audio disabled; subtitle-extract maps a subtitle stream by its zero-based index. That last route has a practical gap: ffmpeg's AVI muxer writes no text subtitle stream, only DivX XSUB bitmaps, so no real AVI with text captions could be produced for an example, and the AVI subtitle pages carry none. An AVI whose subtitle index matches nothing is refused rather than answered with an empty result. Each response reports the sniffed container as avi alongside the size of the fetched file.

FLAC as a target

FLAC output is produced by ffmpeg's flac codec and flac muxer, streamed to a pipe rather than a temporary file. This destination is lossless, so a bitrate_kbps value is rejected instead of silently ignored. The caller may pin a sample_rate from the closed set; otherwise ffmpeg picks, normally the rate of the input. Before encoding starts the duration is checked, then only the first audio stream is mapped, video is discarded, and metadata and chapters are removed. Bit-exact flags make the output reproducible with the pinned ffmpeg. From a PCM source the result is normally smaller, and at the source rate the samples are preserved. From a lossy source it grows instead, because the lossless encoder stores every decoded sample, artefacts included, and cannot recover what the earlier compression removed.

04Errors

CodeHTTP
invalid_input400
blocked_target403
unreachable_target424
upstream_timeout424
unsupported_content_type415
too_large413
unprocessable422
internal500

When each is raised, and what it means for payment: /docs/audio-convert.

05Questions

What does it cost to convert AVI to FLAC?
$0.003 per call, paid in USDC on Base via x402.
How large can the AVI file be?
Up to 100 MB (104,857,600 bytes), and at most 60 min (3,600 s) of media. Past a limit the call answers too_large (413).
What happens if the conversion fails?
The tool answers with a typed JSON error from the errors table. Payment is settled only after the tool has produced its result; a call that fails inside the tool is never settled.

06Related