catalogue / tools / Audio & video / MP4 to PNG

Convert MP4 to PNG (single frame)

To convert MP4 to PNG (single frame), send one POST to /v1/video-thumbnail with the MP4 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

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 MP4 to PNG 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.mp4",
  "time_seconds": 1,
  "format": "png"
}
Response
200 OK
payment-response: <base64 settlement receipt>

{
  "source_url": "https://grist.tools/samples/av/pair-clip.mp4",
  "bytes": 11315,
  "container": "mp4",
  "time_seconds": 1,
  "format": "png",
  "width": 64,
  "height": 36,
  "image_bytes": 186,
  "image_base64": "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAkCAIAAAC2bqvFAAAACXBIWXMAAAABAAAA..."
}

Source file: av/pair-clip.mp4, 11 KB (11,315 bytes). 4 s MP4 made by ffmpeg: a 64x36 PNG video stream at 1 fps (a slate field with a small amber square moving right), a mono 8 kHz FLAC audio track of two 500 Hz triangle beeps, and an English mov_text subtitle stream with two cues. The request sets time_seconds to 1. The recorded run returned 186 bytes of PNG, 2% of the source size, with the source read as the mp4 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 ftyp box names major brand isom, minor version 512 and compatible brands isom, iso2 and mp41; the top-level boxes run ftyp, free, mdat and moov, so the moov index comes after the media data; mvhd counts 4,000 ticks at 1,000 per second, 4 s; the 3 tracks are vide with sample entry mp4v, soun with sample entry fLaC and sbtl with sample entry tx3g. 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

MP4 as a source

MP4 belongs to the ISO base-media family, and Grist recognises it by the ftyp box type at bytes four to eight rather than by a file extension. QuickTime MOV and other files carrying the same box are sniffed as this one container, and the response names it mp4. The container can hold video, audio and text subtitle streams side by side, and each service takes one kind. audio-convert maps the first audio stream and drops the picture. video-thumbnail puts the seek before the input, so it happens at the demuxer and stays cheap in a large file, then decodes exactly one frame from the first video stream. subtitle-extract selects a text track by its zero-based position among subtitle streams. Each ffmpeg run strips container metadata and sets bit-exact flags, so outputs do not carry creation timestamps.

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

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 MP4 to PNG?
$0.003 per call, paid in USDC on Base via x402.
How large can the MP4 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