catalogue / tools / Audio & video / AVI to JPEG

Convert AVI to JPEG (single frame)

To convert AVI to JPEG (single frame), send one POST to /v1/video-thumbnail with the AVI source and "format": "jpeg" in the body. Left out, "format" falls back to its default "png", so a JPEG 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 200 MB.

Endpoint
POST /v1/video-thumbnail
Price
$0.003 per call

01Limits

LimitValue
Largest source file200 MB (209,715,200 bytes)
Timeout60 s
Source formatsAVI, MKV, MP4, Ogg
Output formatsJPEG, PNG
Option time_secondsdefault 0

02Example

A real AVI to JPEG run of video-thumbnail.

Request
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": "jpeg"
}
Response
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": "jpeg",
  "width": 64,
  "height": 36,
  "image_bytes": 389,
  "image_base64": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgEBAQEBAUFBQUFBQYGBgYGBgYGBgYG..."
}

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 389 bytes of JPEG, 1% 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 JPEG in image_base64 opens with FF D8 FF E0 00 10 4A 46 49 46 00 01 (ASCII JFIF). 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 JPEG: after the start-of-image marker comes a 16-byte JFIF APP0 segment, version 1.02, density 1 by 1 with no unit. The segment after it has marker FF DB.

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.

JPEG as a target

image-convert writes JPEG through sharp with options pinned around the caller's quality value. mozjpeg is off, scans are baseline rather than progressive, chroma subsampling is fixed, coding is optimised, and trellis quantisation and overshoot deringing are both disabled. Fixing these settings means the same image, format and quality produce the same bytes on a given build, instead of drifting with a libvips default. The pixel grid is not resized; only codec and container change, and the response reports the width and height of the result. Because withMetadata is never called, EXIF and similar blocks are dropped. An animated input is opened with animation off, so its first frame is the one encoded. Video frames take another road: video-thumbnail decodes one picture and hands it to ffmpeg's mjpeg encoder, which streams it out through image2pipe.

Note: The answer is one frame of the video, taken at the timestamp you choose, not the whole video.

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/video-thumbnail.

05Questions

What does it cost to convert AVI to JPEG?
$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.

06Related