Convert AVI to PNG (single frame)
To convert AVI to PNG (single frame), send one POST to /v1/video-thumbnail with the AVI source and "format": "png" in the body. "png" is the schema default of "format", so the field may also be left out. 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 200 MB.
- Endpoint
POST /v1/video-thumbnail- Price
- $0.003 per call
- Service
- video-thumbnail
01Limits
| Limit | Value |
|---|---|
| Largest source file | 200 MB (209,715,200 bytes) |
| Timeout | 60 s |
| Source formats | AVI, MKV, MP4, Ogg |
| Output formats | JPEG, PNG |
| Option time_seconds | default 0 |
02Example
A real AVI to PNG run of video-thumbnail.
POST /v1/video-thumbnail
content-type: application/json
payment-signature: <base64 x402 payload>
{
"url": "https://grist.tools/samples/av/pair-clip.avi",
"time_seconds": 1,
"format": "png"
}200 OK
payment-response: <base64 settlement receipt>
{
"source_url": "https://grist.tools/samples/av/pair-clip.avi",
"bytes": 76302,
"container": "avi",
"time_seconds": 1,
"format": "png",
"width": 64,
"height": 36,
"image_bytes": 186,
"image_base64": "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAkCAIAAAC2bqvFAAAACXBIWXMAAAABAAAA..."
}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 request sets time_seconds to 1. The recorded run returned 186 bytes of PNG, 0% of the source size, with the source read as the avi container, an image of 64x36 pixels and the frame taken at 1 s. Decoded, the PNG in image_base64 opens with 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D (ASCII PNG). 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 PNG: its IHDR chunk declares 64 by 36 pixels, 8-bit truecolour RGB and no interlacing. The next chunk is pHYs.
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.
PNG as a target
PNG output is lossless, so image-convert ignores the quality value when PNG is requested. Its encoder options are pinned: the maximum zlib compression level, a fixed effort, adaptive filtering off, palette quantisation off and no interlacing, so identical pixels always deflate to identical bytes. Dimensions are kept and reported in the response, and metadata is stripped. Vector input takes a separate service: svg-to-png renders the document at a caller-set density, which drives the natural raster size, and an optional width or height fits the render inside that box with the lanczos3 kernel, keeping the aspect ratio, before the same pinned PNG options apply. video-thumbnail writes PNG by default through ffmpeg's png encoder; when a width is requested, the height follows the aspect ratio and is rounded to an even number.
Note: The answer is one frame of the video, taken at the timestamp you choose, not the whole video.
04Errors
| Code | HTTP |
|---|---|
invalid_input | 400 |
blocked_target | 403 |
unreachable_target | 424 |
upstream_timeout | 424 |
unsupported_content_type | 415 |
too_large | 413 |
unprocessable | 422 |
internal | 500 |
When each is raised, and what it means for payment: /docs/video-thumbnail.
05Questions
- What does it cost to convert AVI to PNG?
- $0.003 per call, paid in USDC on Base via x402.
- How large can the AVI file be?
- Up to 200 MB (209,715,200 bytes). 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.