# Video to GIF Converter: MP4 to GIF & Animated WebP (Bulk) (`data-done-right/video-to-gif-converter`) Actor

Convert video file URLs to animated GIF or animated WebP in bulk: set start, duration, fps and width, plus an optional max file size (it re-encodes smaller to fit). Palette-optimised ffmpeg, signed download links. Direct files only, no YouTube.

- **URL**: https://apify.com/data-done-right/video-to-gif-converter.md
- **Developed by:** [Data Done Right](https://apify.com/data-done-right) (community)
- **Categories:** Videos, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $9.60 / 1,000 gif or webp createds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Video to GIF Converter: MP4 to GIF & Animated WebP (Bulk)

This **video to GIF converter** turns direct video file URLs (MP4, MOV, WebM, MKV) into **animated GIFs or animated WebP** files in bulk. You choose the start time, duration, frame rate and width, and optionally a **maximum file size**: if the first result is too big, the Actor re-encodes it smaller until it fits. Every file comes back as a signed download link. It runs ffmpeg in the cloud, so there is nothing to install and no API key.

> **What it does not do.** It reads **direct video files** from a public URL. It **does not download from YouTube, Vimeo, TikTok, Instagram or other streaming sites** and rejects those links without charge; HLS/DASH playlists (.m3u8, .mpd) are not supported. It makes **silent, looping animations of at most 60 seconds** (no audio, no text, captions or editing). It respects the `robots.txt` of the host that serves your video. Use it only on videos you own or have the right to process.

**What you get**

- One dataset row per GIF or WebP: download link, frames, width, height, playing time, file size, settings actually used, and a clear status or error.
- A palette built from your own clip (two-pass `palettegen` / `paletteuse`), so GIFs look much better than a plain conversion.
- A size cap that really holds: the Actor lowers fps, width and colors (GIF) or quality (WebP) in steps and tells you what it changed. Failed outputs are free.

### How to convert a video URL to a GIF

1. Paste one or more **direct video URLs** in `videoUrls`.
2. Set `startSeconds` (for example `"12.5"` or `"00:01:30"`), `durationSeconds` (default 3), `fps` (default 12) and `width` (default 480 px, never upscaled).
3. Run it. Open the dataset: every row has a `url` to the GIF. The `SUMMARY` record lists each video's duration, resolution and any problems.

### How to make an animated WebP instead

Set `"outputFormat": "webp"` (or `"both"` for a GIF and a WebP of each window; that is two outputs and two charges). Animated WebP plays in all current browsers and is usually much smaller: in a local test, the same 3 s, 15 fps, 400 px window of the MDN flower sample was 1.56 MB as a GIF and 311 KB as a WebP (quality 70). Some chat apps, email clients and older tools still show only a still image for WebP, so pick GIF when you need to be sure it animates everywhere. `webpQuality` sets the quality (default 75).

### How to keep a GIF under a file size limit

Set `maxFileSizeKb`, for example `8192` for an 8 MB limit (1 KB = 1,024 bytes). The Actor encodes with your settings first. If the file is over the cap it tries again with fewer frames per second, a smaller width and then fewer colors (GIF) or lower quality (WebP), in up to **7 attempts in total**, and stops at the first result under the cap. The row shows `attempts`, the `fps` and `width` that were finally used, and a note. If even the last attempt is too big, that output is an error row with the smallest size reached, and nothing is charged. The ladder never goes below 64 px wide or 4 fps and never changes which part of the video you picked; shorten `durationSeconds` if you hit the limit.

### How to make several GIFs from one video

Use `videos` with one entry per window: `[{"url": "https://example.com/talk.mp4", "start": "00:05:00", "duration": 4, "name": "intro"}, {"url": "https://example.com/talk.mp4", "start": "00:12:30", "duration": 6}]`. The same URL is downloaded once. Entries without `start` or `duration` use the run-level values.

### Input

| Field | Default | What it does |
|---|---|---|
| `videoUrls` | sample video | Direct video file links (required). |
| `videos` | empty | Per-video windows: `[{"url", "start", "duration", "name"}]`. |
| `outputFormat` | `gif` | `gif`, `webp` or `both` (two outputs per window). |
| `startSeconds` | `"0"` | Start as seconds or HH:MM:SS (a string). |
| `durationSeconds` | 3 | 0.2 to 60. Shortened (with a note) if the video ends sooner. |
| `fps` | 12 | 1 to 30. Duration times fps may not exceed 1,800 frames. |
| `width` | 480 | 16 to 1920 px; never upscales. |
| `maxFileSizeKb` | 0 (off) | Size cap per file, see above. |
| `loop` | true | Loop forever, or play once. |
| `colors` / `dither` | 256 / `bayer` | GIF palette size and dithering. |
| `webpQuality` | 75 | WebP quality, 1 to 100. |
| `maxOutputsPerRun` | 100 | Hard cap on files per run (max 2000). |
| `maxVideoSizeMb` | 500 | Source size cap (max 2048). |
| `maxDurationMinutes` | 120 | Source length cap. |
| `videoTimeoutSecs` | 300 | Per download and per output, including size-cap retries. |
| `outputStoreName` | empty | Save files in a named store that is kept until you delete it. |

Input example:

```json
{
  "videoUrls": ["https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"],
  "outputFormat": "gif",
  "startSeconds": "0",
  "durationSeconds": 3,
  "fps": 12,
  "width": 480
}
```

### Output

From a real local run of the input above:

```json
{
  "sourceUrl": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4",
  "videoIndex": 1, "outputIndex": 1, "name": null, "format": "gif",
  "start": 0.0, "requestedSeconds": 3.0, "durationSeconds": 3.0,
  "frames": 36, "fps": 12, "width": 480, "height": 270, "loops": "forever", "bytes": 1709122,
  "maxFileSizeBytes": null, "withinSizeCap": null, "attempts": 1, "colors": 256, "webpQuality": null,
  "sourceDurationSeconds": 5.055,
  "url": "https://api.apify.com/v2/key-value-stores/<store>/records/v01-001.gif",
  "key": "v01-001.gif", "status": "ok", "error": null, "note": null
}
```

On Apify the `url` is a signed link that downloads without a token. `status` is `ok`, `error` (nothing charged) or `skipped` (spending limit, `maxOutputsPerRun`, or the host's robots.txt). `durationSeconds`, `frames`, `width` and `height` are read back from the finished file.

### Use with the Apify API, MCP, n8n and Make

Python:

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("data-done-right/video-to-gif-converter").call(run_input={
    "videoUrls": ["https://example.com/demo.mp4"], "startSeconds": "5", "durationSeconds": 4,
    "outputFormat": "gif", "maxFileSizeKb": 8192})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["status"], row["url"] or row["error"])
```

JavaScript:

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: '<APIFY_TOKEN>' });
const run = await client.actor('data-done-right/video-to-gif-converter').call({
  videoUrls: ['https://example.com/demo.mp4'], outputFormat: 'webp', durationSeconds: 5 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

In n8n or Make use the Apify node with the actor name and the same JSON. With Apify's MCP server (mcp.apify.com) an AI assistant can call it: "make a 4-second GIF from second 5 of this mp4, under 5 MB". Only a video URL is needed.

### Use cases

- Turn product demos and screen recordings into GIFs for docs, README files and tickets.
- Make small looping previews for a video catalogue or a changelog.
- Fit animations under a chat, email or CMS upload limit with one setting.
- Convert a batch of clips to animated WebP for a faster website.
- Generate GIF thumbnails for a pipeline that already stores video URLs.

### How much does it cost

Pay per event: **$0.012 per GIF or WebP created** (`output-created`, $12 per 1,000). Outputs that fail, are skipped or rejected, and the `SUMMARY` record are free. `outputFormat: both` creates two outputs and so costs two events. Plan discounts apply (Silver about 10%, Gold and higher about 20%).

- 1,000 GIFs: $12.
- 10,000 GIFs: $120.
- 100,000 GIFs: $1,200.

The price is per file delivered, whatever its length, size or number of size-cap attempts; Apify platform usage is included. `maxOutputsPerRun` caps a run, and if you set a maximum spend per run the Actor stops cleanly when it is reached and removes the file it could not charge for.

### FAQ

#### Can it convert YouTube videos to GIF?

No. YouTube, Vimeo, TikTok, Instagram and other streaming-site links are rejected with a message and no charge. Use a direct link to a video file you have the rights to (for example a file on your own server or storage bucket).

#### Does it add sound, text or captions?

No. GIF and animated WebP here are silent animations of a time window of the video, at most 60 seconds. For captions see the subtitle tool under Related tools; for audio use the audio extractor.

#### What if the start time or window does not fit the video?

The Actor reads the real duration first. A start at or past the end gives an error row (free). A window that runs past the end is shortened and the row says so (`note`, and the measured `durationSeconds`).

#### How reliable is the size cap?

It re-encodes up to 7 times in total and stops at the first file under the cap, so a cap is met whenever the content can be compressed that far at 64 px wide and 4 fps. Very noisy or fast-moving footage is the hard case. If it cannot be met you get an error row with the smallest size reached and no charge. GIF is the less efficient format: a cap that a GIF cannot meet is often easy for WebP.

#### Which limits apply?

Source files up to 2 GB (default 500 MB) and 2 hours by default; GIFs and WebPs up to 60 s, 30 fps, 1920 px wide and 1,800 frames; up to 2,000 outputs per run. Links to private or internal addresses are blocked. The whole source file is downloaded once per video, so a very large file takes time even for a short GIF. The Actor honours the host's `robots.txt`: if it disallows your URL (or cannot be read) the video is skipped for free.

#### Which formats can it read?

Common containers (mp4, mov, webm, mkv, avi, flv, mpeg, ts) with codecs ffmpeg can decode. Animated WebP output needs the WebP encoder in the Actor's ffmpeg; if a build ever lacks it, the run stops with a clear message and nothing is charged.

#### How long are the file links kept?

Files live in the run's key-value store, which expires with your plan's retention period. Set `outputStoreName` to keep them in a named store until you delete it.

### Related tools

- **Video Frame Extractor: Keyframes, Scenes & Thumbnails for AI** pulls still images from the same videos.
- **Cut Video: Video Trimmer, Clip Cutter & Video to GIF** cuts clips as MP4, WebM or MP3, or a simple GIF, with start and end times.
- **Batch Image Converter & Resizer: WebP, AVIF, PNG & JPEG** converts and resizes still images.
- **Burn Subtitles into Video: Hardcode SRT & VTT Captions (Bulk)** adds captions to a video before you make the GIF.

# Actor input Schema

## `videoUrls` (type: `array`):

Direct links to video files (mp4, mov, webm, mkv, avi). Example: https://example.com/clip.mp4. Each video becomes one GIF or WebP from the start time and duration below. YouTube, Vimeo, TikTok and other streaming-site page links are rejected with no charge.

## `videos` (type: `array`):

Per-video windows, for example \[{"url": "https://example.com/a.mp4", "start": "00:00:12", "duration": 4, "name": "intro"}]. Times are seconds (12.5) or HH:MM:SS. The same URL may appear several times with different windows and is downloaded once. Entries without start or duration use the values below.

## `outputFormat` (type: `string`):

GIF works everywhere but is larger. Animated WebP is much smaller at the same quality and plays in all current browsers, but some chat and email apps still show only a still image. 'Both' creates and charges two outputs per window.

## `startSeconds` (type: `string`):

Where the animation starts. Examples: 0, 12.5, 00:01:30. If it is past the end of the video that output is an error row (free).

## `durationSeconds` (type: `number`):

Length of the animation in seconds, 0.2 to 60. If the video ends sooner the output is shortened and the row says so.

## `fps` (type: `integer`):

Frame rate of the animation. 10 to 15 is typical for GIFs; lower is smaller. Duration times fps may not exceed 1,800 frames.

## `width` (type: `integer`):

Maximum width in pixels; the height follows the aspect ratio. Never upscales: a 320 px video stays 320 px. Example: 480.

## `maxFileSizeKb` (type: `integer`):

Try to keep each file under this size (1 KB = 1,024 bytes), for example 8192 for 8 MB chat limits. If the first attempt is too big the Actor re-encodes with fewer frames per second, a smaller width and fewer colors or lower quality, up to 7 attempts in total. If it still does not fit, that output is an error row and is free.

## `loop` (type: `boolean`):

On: the animation repeats forever. Off: it plays once.

## `colors` (type: `integer`):

Size of the GIF palette, 16 to 256. Fewer colors give a smaller file. Ignored for WebP.

## `dither` (type: `string`):

How GIF colors are blended. Ignored for WebP.

## `webpQuality` (type: `integer`):

Lossy WebP quality, 1 to 100. 75 is a good balance. Ignored for GIF.

## `maxOutputsPerRun` (type: `integer`):

Hard cap on GIF/WebP files created in one run. Also caps your cost: 100 outputs cost about $1.20.

## `maxVideoSizeMb` (type: `integer`):

Source files larger than this are rejected (free). The whole file is downloaded once per video. Example: 500.

## `maxDurationMinutes` (type: `number`):

Longer source videos are rejected with an error row (free). Example: 120 = 2 hours.

## `videoTimeoutSecs` (type: `integer`):

Time allowed for each download and for each output, including size-cap retries. Example: 300.

## `outputStoreName` (type: `string`):

Optional name of a key-value store that keeps the files until you delete it. Example: my-gifs. Empty = the run's default store, which expires with your plan's retention.

## Actor input object example

```json
{
  "videoUrls": [
    "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
  ],
  "outputFormat": "gif",
  "startSeconds": "0",
  "durationSeconds": 3,
  "fps": 12,
  "width": 480,
  "maxFileSizeKb": 0,
  "loop": true,
  "colors": 256,
  "dither": "bayer",
  "webpQuality": 75,
  "maxOutputsPerRun": 100,
  "maxVideoSizeMb": 500,
  "maxDurationMinutes": 120,
  "videoTimeoutSecs": 300
}
```

# Actor output Schema

## `results` (type: `string`):

One row per output with its download link, size, frames, settings used and status, as JSON, CSV, Excel and more.

## `records` (type: `string`):

Key-value store records: the GIF and WebP files and the run summary.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "videoUrls": [
        "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("data-done-right/video-to-gif-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "videoUrls": ["https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"] }

# Run the Actor and wait for it to finish
run = client.actor("data-done-right/video-to-gif-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "videoUrls": [
    "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
  ]
}' |
apify call data-done-right/video-to-gif-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data-done-right/video-to-gif-converter"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/k9cxbMMQ4eQN5v2yf/builds/qzanLOyDcYg7CKMMH/openapi.json
