MP4 to GIF API — Free Tier + Pay-As-You-Go
Convert MP4 video to animated GIF programmatically. Per-job width, fps, palette mode, and start/end trim controls.
What it does
The MP4 to GIF API converts MP4, MOV, MKV, and WebM video into animated GIFs with explicit control over width, frame rate, palette mode, and per-clip trim windows. The pipeline always uses FFmpeg's two-pass `palettegen` + `paletteuse` filter chain — a palette is built from the input first, then the GIF is encoded against it — because the naive single-pass path produces visibly worse colour. The palette size and dithering strategy are driven by `quality` rather than by a separate dithering parameter.
Output GIFs are typically several times larger than the source MP4 at equivalent visual quality; that is a fundamental limit of per-frame palettes and indexed colour, and there is no size-targeting parameter that will iterate its way under a ceiling for you. Per-job parameters are `width` (height is computed to preserve the aspect ratio), `fps`, `startTime` / `endTime` to cut the clip, `colors` for the palette size, and `loop` (0 for infinite, or a specific count). The API does NOT recommend converting more than ~10 seconds of video to GIF — for longer clips, ship WebP or MP4 instead and get 10× better quality at 10× smaller size.
Supported formats
Source formats (6)
- mp4
- mov
- mkv
- webm
- avi
- m4v
Target formats (1)
- gif
Quick start
Every sample posts the job, then polls /v1/status/{jobId} until it finishes, with your API key in the X-Api-Key header. The parameter names below are the ones the endpoint actually accepts — anything else is dropped rather than rejected.
curl -X POST https://api.convertintomp4.com/v1/convert \
-H "X-Api-Key: ck_your_api_key" \
-F "file=@input.mp4" \
-F "targetFormat=gif"
-F "width=480" \
-F "fps=15" \
-F "startTime=00:00:02" \
-F "endTime=00:00:08"import { readFileSync } from "node:fs";
import { ConvertIntoMP4Client } from "convertintomp4";
const apiKey = process.env.CIM4_API_KEY;
const client = new ConvertIntoMP4Client({ apiKey });
// Presigned direct-to-R2 upload, then queue the conversion.
const { jobId } = await client.uploadDirect(
readFileSync("input.mp4"),
"input.mp4",
"application/octet-stream",
{ targetFormat: "gif" },
);
// Poll until the job reaches a terminal state.
let job;
do {
await new Promise((r) => setTimeout(r, 2000));
job = await fetch(`https://api.convertintomp4.com/v1/status/${jobId}`, {
headers: { "X-Api-Key": apiKey },
}).then((r) => r.json());
} while (job.status !== "completed" && job.status !== "failed");
console.log("Download URL:", job.result?.downloadUrl);import time, requests
from convertintomp4 import Client
api_key = "ck_your_api_key"
client = Client(api_key=api_key)
# Presigned direct-to-R2 upload, then queue the conversion.
with open("input.mp4", "rb") as f:
job = client.upload_direct(
f, "input.mp4", "application/octet-stream", "gif"
)
# Poll until the job reaches a terminal state.
while True:
status = requests.get(
f"https://api.convertintomp4.com/v1/status/{job['jobId']}",
headers={"X-Api-Key": api_key},
).json()
if status["status"] in ("completed", "failed"):
break
time.sleep(2)
print("Download URL:", status.get("result", {}).get("downloadUrl"))Features
- Two-pass palette generation for clean output
- Configurable width, fps, dither algorithm
- Start / end trim with millisecond precision
- Boomerang playback (forward + reverse)
- Iterative size-targeting via maxFileSize
- Loop count: infinite or specific
- Auto-recommends WebP for clips longer than 10s
Pricing
From $9.99/mo (Pro) or $24.99/mo (Business) — or pay-as-you-go on the API plan.
Free tier: 5 conversions/day, 100 MB file size, no API key required (IP-gated). Pro $9.99/mo: 100/day (2,000/month), 2 GB files. Business $24.99/mo: 1,000/day (20,000/month), 10 GB files, GPU encoding, dedicated support.
See full pricing breakdown →Built for production
99.9% uptime SLA
Multi-region failover, transparent status page, 60-second response-time guarantee on Business.
Encryption + auto-delete
TLS 1.2+ in transit, AES-256 at rest. Files deleted after 1h / 24h / 7d depending on plan, or instantly via DELETE endpoint. See the security page.
~7s median latency
Most sub-100 MB jobs complete in 6-9 seconds. Webhook-driven async for heavier workloads; waitForJob for synchronous flows.
Frequently Asked Questions
Why is the GIF so much larger than the MP4?
GIF stores each frame as an indexed-color (max 256 colors per frame) image with no inter-frame compression beyond LZW. MP4 uses H.264 inter-frame prediction — only changes between frames are stored. A 10-second 720p GIF is typically 5-15 MB; the same clip as MP4 is 500 KB to 2 MB.
What FPS should I pick?
15 fps is the sweet spot for animated GIFs — looks smooth, keeps file size manageable. 24-30 fps doubles file size for marginal perceptual improvement. 10 fps is the lowest before motion becomes visibly choppy.
Should I use GIF or WebP for short video loops?
Animated WebP — supported by 96%+ of browsers as of 2026. Animated WebP is 5-10× smaller than equivalent GIF at the same quality. We support GIF for legacy compatibility but recommend animated WebP for any new project where you control the consumer.
How do I trim to just a portion of the video?
Pass `startTime=00:00:02` and `endTime=00:00:08` to extract that six-second window — the field names are `startTime` and `endTime`, not `start` and `end`, and a plain seconds value works too. The cut happens in the same FFmpeg invocation as the palette work, so there is no separate trim job.
What does palette=optimized do?
Generates a custom 256-color palette per clip based on the actual pixel data, producing visibly cleaner output than the default GIF web-safe palette. Adds ~20% to encoding time. Required for any video with skin tones, sunsets, or gradients.
Related APIs
- MP4 to MP3 APIExtract MP3 audio from MP4 video programmatically. Per-job bitrate and sample rate, ID3 tag injection, fast remux mode.
- PDF to JPG APIRender PDF pages to JPG images programmatically. Per-page DPI, page-range selection, batch ZIP output, ImageMagick + pdftoppm pipeline.
- JPG to PNG APIConvert JPG to PNG with optional transparency, lossless compression, and EXIF preservation via API. Sharp-backed.
- PDF to DOCX APIConvert PDF to editable Word DOCX via API. pdf2docx layout reconstruction, automatic OCR pre-pass on scans, LibreOffice fallback.
- DOCX to PDF APIConvert Word DOCX to PDF programmatically. LibreOffice-rendered with font fallback, headers/footers, and PDF/A archival output.
- HEIC to JPG APIConvert iPhone HEIC and HEIF photos to JPG via API. EXIF rotation, ICC profile, Live Photo frame selection.
Or browse the full catalogue of 23 API products →
Get an API key
Start integrating the MP4 to GIF API in five minutes. Read the docs, grab a key, and ship your first conversion before the trial coffee cools.