# Video Frame Extractor: Frames, Keyframes & Scenes for AI Vision (`terracotta_hauyne/video-frame-extractor-for-ai-vision`) Actor

Extract frames from video files for AI vision (GPT-4o, Claude, Gemini): every N seconds, N evenly spaced, scene-change keyframes or exact timestamps. JPG/PNG/WebP, base64 or URLs, contact sheet, timecodes. Video to images, $1.50 per 1,000 frames.

- **URL**: https://apify.com/terracotta_hauyne/video-frame-extractor-for-ai-vision.md
- **Developed by:** [Kevin](https://apify.com/terracotta_hauyne) (community)
- **Categories:** AI, Videos, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 1,000 frame extracteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 Frame Extractor: Frames, Keyframes & Scenes for AI Vision

**Extract frames from video** and turn video into images for GPT-4o, Claude, Gemini or any vision model. Turn a video file into the few images an AI vision model (GPT-4o, Claude, Gemini, a local VLM) needs:
a frame **every N seconds**, **N evenly spaced** frames, a frame at each **scene change**, or the frames at
**exact timestamps**. You get JPG, PNG or WebP files with links (or base64), a **contact sheet** (one grid image
with timecodes), and metadata for every frame and video.

### Who is it for

- **AI / LLM developers** who need to send a video to a vision model that accepts images only (video to images for GPT-4o, Claude vision, Gemini).
- **Content and QA teams** who want a storyboard, thumbnails or a contact sheet of a video.
- **Data teams** building image datasets or video search indexes from their own footage.
- **No-code users** (Make, Zapier, n8n) who need frames without running ffmpeg themselves.

### Quick answers

- **How do I extract frames from a video?** Give the actor a direct video file link, choose a mode (every N seconds, N frames, scene changes, or exact timestamps) and run. You get images plus timecodes.

- **How do I give GPT-4o or Claude a video?** Use `count` mode with 8-20 frames and switch on **Include base64**: each item then carries the image ready for a vision API call. The actor does not call any AI model itself.

- **Price:** $1.50 per 1,000 frames ($0.0015 per frame). Contact sheets, metadata, base64 and scene detection are included. Videos that fail (bad link, too big, not a video) are not charged. Apify also charges a tiny Actor-start fee.

- **What can I give it?** Direct links to video files (.mp4, .webm, .mov, .mkv, .avi, .m4v, .ts), a video you upload in the Apify console, or video files stored in an Apify key-value store.

- **YouTube, TikTok, Instagram, Facebook, X, Vimeo?** **No.** Their terms forbid downloading, so this Actor reads **direct file links only** and rejects those pages with a clear message. Use your own files, your own storage (S3, R2, a CDN), or videos you have the right to process.

- **Which modes?** `interval` (every N seconds), `count` (N evenly spaced frames), `scenes` (shot changes, with the ffmpeg scene score on each frame), `timestamps` (exact times: `90`, `1:30`, `00:01:30.250`, `1m30s`).

- **How accurate are timestamps?** You get the frame that is on screen at that time (the last frame at or before it). Tested against videos where each second has its own colour.

- **Limits (change them in the input):** 30 min per video, 500 MB per video, 100 frames per video, 1,000 frames per run. Over a limit the video fails with a message that names the setting; nothing is charged.

- **Typical speed:** a 60-frame run on a 1-minute 720p video takes about 3 s; 20 frames from a 10-minute video about 2 s (on a fast desktop, see TESTING.md). Scene detection reads the whole video once (about 12 s for 10 minutes of 720p).

- **Max cost control:** set Apify's maximum cost per run; the Actor stops at that many frames and says so in the summary.

### What you get

One dataset item per frame:

```json
{
  "videoIndex": 1,
  "source": "https://example.com/clip.mp4",
  "frameIndex": 2,
  "timestampSeconds": 2.085,
  "timecode": "00:00:02.085",
  "mode": "count",
  "sceneScore": null,
  "width": 960,
  "height": 540,
  "format": "jpg",
  "mimeType": "image/jpeg",
  "sizeBytes": 26109,
  "imageKey": "video-001-frame-0003-t00002085.jpg",
  "imageUrl": "https://api.apify.com/v2/key-value-stores/<id>/records/video-001-frame-0003-t00002085.jpg",
  "contactSheetUrl": "https://api.apify.com/v2/key-value-stores/<id>/records/video-001-contact-sheet.jpg",
  "video": {"durationSeconds": 5.005, "fps": 29.97, "width": 960, "height": 540, "codec": "h264", "bitrate": 1785756, "container": "mov", "hasAudio": true, "sizeBytes": 1128375}
}
```

- `imageUrl` points to the file in the run's key-value store (it is also listed in the run's **Output** tab). Turn on **Include base64** to get `imageBase64` plus `mimeType` in the item, ready for a vision API call.
- `sceneScore` is the ffmpeg scene-change score (0-1) in scenes mode; the opening frame has `null`.
- The **run summary** (`OUTPUT` record) lists every video with status, errors and warnings, metadata, the contact sheet link, and timings.

### How to use

1. Click **Start** with the prefilled example (a 5-second CC0 clip, 6 frames in about a second), or paste your own direct video links.
2. Pick **What to extract**, set size and format, run.
3. Read the images from the Output tab, export the dataset, or call the API.

**Example 1: 12 frames to summarise a video with a vision model**

```json
{ "videoUrls": ["https://example.com/demo.mp4"], "mode": "count", "frameCount": 12, "maxWidth": 1024, "includeBase64": true }
```

**Example 2: a storyboard from scene changes, WebP, one contact sheet**

```json
{ "videoUrls": ["https://example.com/ad.mp4"], "mode": "scenes", "sceneThreshold": 0.3, "imageFormat": "webp", "maxFramesPerVideo": 40 }
```

**Example 3: one frame per second between 1:00 and 2:00**

```json
{ "videoUrls": ["https://example.com/lecture.mp4"], "mode": "interval", "intervalSeconds": 1, "startTime": "1:00", "endTime": "2:00" }
```

**Example 4: exact timestamps from a file in your key-value store**

```json
{ "sourceKeyValueStoreId": "my-videos", "sourceKeys": ["meeting.mp4"], "mode": "timestamps", "timestamps": ["0:30", "12:05.5", "1h2m3s"] }
```

### Use cases

- **Video to images for AI vision:** 8-20 evenly spaced frames summarise most videos for a vision model.
- **Scene-change keyframes:** one frame per shot, with the scene score, for storyboards and video indexing.
- **Extract a frame every second:** `interval` mode with `intervalSeconds: 1` for OCR, slide capture or lecture frames.
- **Frame at an exact timestamp:** `timestamps` mode, e.g. `1:30` or `1m30s`, to grab the moment a user reported.
- **Video contact sheet:** one grid image with timecodes per video for a quick visual overview.

### Input options

| Field | What it does |
|---|---|
| `videoUrls`, `uploadedVideo`, `sourceKeys` (+ `sourceKeyValueStoreId`) | Where the videos are. Direct file links only. |
| `mode` | `interval`, `count`, `scenes` or `timestamps`. |
| `intervalSeconds`, `frameCount`, `timestamps` | Settings for those modes. |
| `sceneThreshold`, `minSceneGapSeconds`, `includeFirstFrame`, `fastSceneScan` | Scene mode: sensitivity (0.2 sensitive, 0.4 hard cuts only), minimum gap between cuts, keep the opening frame, keyframe-only scan (faster, may miss cuts between keyframes). |
| `startTime`, `endTime` | Work on part of the video (interval, count, scenes). |
| `imageFormat`, `imageQuality`, `maxWidth`, `maxHeight` | jpg/png/webp, quality 1-100, shrink to fit (never enlarges). Default 1280 px wide. |
| `skipBlankFrames` | Step past black or pure-white frames (fade-ins, black intros). |
| `contactSheet`, `contactSheetColumns` | One grid image per video (up to 100 frames). |
| `includeBase64` | Add the image as base64 to each item. |
| `maxFramesPerVideo`, `maxTotalFrames`, `maxDurationMinutes`, `maxVideoSizeMb`, `downloadTimeoutSecs` | Safety limits. |

### Good to know

- **The whole file is downloaded first** (up to your size limit), then frames are decoded locally. Rotation metadata and non-square pixels are handled, so frames come out upright and undistorted.
- **Scenes mode** reads every frame once. If a video has fewer cuts than the frame cap you get all of them; with more, the strongest cuts are kept.
- **Links must be public.** Pre-signed URLs work. Pages that need a login, and private or local network addresses, are rejected.
- **Not affiliated** with ffmpeg, YouTube or any video platform. Only process videos you have the right to use.

### Pricing

Pay per event: **$0.0015 per frame** returned (one dataset item), about $1.50 per 1,000. Nothing is charged for videos that fail. You can cap spend with the maximum cost per run.

# Actor input Schema

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

Direct links to video files (.mp4, .webm, .mov, .mkv, .avi, .m4v, .ts). The link must open the file itself, without login. Page URLs of YouTube, TikTok, Instagram, Facebook, X, Vimeo and similar platforms are not supported: their terms forbid downloading.

## `uploadedVideo` (type: `string`):

Optional. Upload one video file here (it is stored in Apify and read like a URL). For several private files use the key-value store fields below.

## `sourceKeyValueStoreId` (type: `string`):

Optional. Key-value store that holds your video files, used with "Record keys". Leave empty to read the keys from this run's default store.

## `sourceKeys` (type: `array`):

Keys of binary video records in the key-value store above. Each record is one video.

## `mode` (type: `string`):

interval: one frame every "Seconds between frames". count: "Number of frames" spread evenly (the middle of equal slices). scenes: the first frame plus a frame at each detected shot change (strongest first when over the cap). timestamps: the times listed in "Timestamps".

## `intervalSeconds` (type: `number`):

Interval mode: 1 = one frame per second, 0.5 = two per second. Frames start at the start time.

## `frameCount` (type: `integer`):

Count mode: how many frames, evenly spaced. 8-20 is usually enough for an AI model to follow a video.

## `timestamps` (type: `array`):

Timestamps mode: seconds (90.5), clock time (1:30, 00:01:30.250) or 1m30s. You get the frame on screen at that time. Times beyond the video are skipped with a warning.

## `sceneThreshold` (type: `number`):

Scenes mode: ffmpeg scene score (0-1) that counts as a cut. Lower finds more, subtler changes (0.2 sensitive, 0.4 only hard cuts). Each frame reports its score as "sceneScore".

## `minSceneGapSeconds` (type: `number`):

Scenes mode: ignore cuts closer than this to a stronger cut (stops flashes and fast edits from flooding the result).

## `includeFirstFrame` (type: `boolean`):

Scenes mode: also return the opening frame (sceneScore 0), so a video without any cut still gives one image.

## `fastSceneScan` (type: `boolean`):

Scenes mode: look only at keyframes (I-frames). Several times faster on long or high-resolution videos, but cuts that do not fall on a keyframe are missed. Off = frame-exact detection.

## `startTime` (type: `string`):

Optional. Ignore everything before this time (seconds, 1:30 or 1m30s). Applies to interval, count and scenes modes.

## `endTime` (type: `string`):

Optional. Ignore everything after this time. Empty = to the end of the video.

## `imageFormat` (type: `string`):

File format of the saved frames.

## `imageQuality` (type: `integer`):

JPG and WebP quality, 1-100. 80-90 is a good balance for AI vision. Ignored for PNG.

## `maxWidth` (type: `integer`):

Frames wider than this are scaled down, aspect ratio kept, never enlarged. 0 = keep the original size. 1280 is enough for vision models and keeps tokens and file sizes low.

## `maxHeight` (type: `integer`):

Frames taller than this are scaled down. 0 = no limit.

## `skipBlankFrames` (type: `boolean`):

If a chosen frame is black (fade, black intro) or pure white, step forward up to 2 x 0.5 s to a real picture. The reported timestamp is the frame you got.

## `contactSheet` (type: `boolean`):

Also save one grid image per video with all frames and their timecodes (up to 100). Free. Its link is in every frame item and in the run summary.

## `contactSheetColumns` (type: `integer`):

Thumbnails per row on the contact sheet.

## `includeBase64` (type: `boolean`):

Add the image as base64 text ("imageBase64", with "mimeType") to each item, ready to send to a vision API. Makes items large; for big batches use "imageUrl" instead.

## `maxFramesPerVideo` (type: `integer`):

Hard cap per video in every mode. For scenes the strongest cuts are kept; for interval and timestamps the earliest frames are kept and a warning is added.

## `maxTotalFrames` (type: `integer`):

Stop when this many frames have been returned in total. You can also set a maximum cost per run in Apify.

## `maxDurationMinutes` (type: `integer`):

Videos (or the start/end range) longer than this fail with a clear message and are not charged. Use start and end time to process a part of a long video.

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

Larger videos are rejected (free). Frames are decoded locally, so the whole file is downloaded first.

## `downloadTimeoutSecs` (type: `integer`):

Give up on a video that has not downloaded in this time.

## Actor input object example

```json
{
  "videoUrls": [
    "https://example.com/clip.mp4"
  ],
  "mode": "interval",
  "intervalSeconds": 10,
  "frameCount": 10,
  "timestamps": [
    "0",
    "12.5",
    "1:30"
  ],
  "sceneThreshold": 0.3,
  "minSceneGapSeconds": 1,
  "includeFirstFrame": true,
  "fastSceneScan": false,
  "imageFormat": "jpg",
  "imageQuality": 85,
  "maxWidth": 1280,
  "maxHeight": 0,
  "skipBlankFrames": true,
  "contactSheet": true,
  "contactSheetColumns": 5,
  "includeBase64": false,
  "maxFramesPerVideo": 100,
  "maxTotalFrames": 1000,
  "maxDurationMinutes": 30,
  "maxVideoSizeMb": 500,
  "downloadTimeoutSecs": 300
}
```

# Actor output Schema

## `frames` (type: `string`):

One item per extracted frame (default dataset): image URL, timestamp, size, scene score, contact sheet URL and video metadata.

## `images` (type: `string`):

The frame images and contact sheets in the run's key-value store.

## `summary` (type: `string`):

Per-video status, errors and warnings, video metadata, contact sheet link, timings.

# 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("terracotta_hauyne/video-frame-extractor-for-ai-vision").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("terracotta_hauyne/video-frame-extractor-for-ai-vision").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 terracotta_hauyne/video-frame-extractor-for-ai-vision --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,terracotta_hauyne/video-frame-extractor-for-ai-vision"
        }
    }
}
```

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/sxQgmbOXfP52h1MtI/builds/0E0z4WRYD0lao0O0S/openapi.json
