# Video Keyframe Extractor: Scene Frames for AI Vision (`open-data-tools/video-keyframe-extractor`) Actor

Extract keyframes and scene-change frames from video files with timestamps, sized for GPT, Claude or Gemini vision. Near-duplicates dropped free, max-frames cap, or frames by interval, count or exact time. JPEG/WebP/PNG links, optional ZIP. $0.0015 per frame, no start or per-minute fee.

- **URL**: https://apify.com/open-data-tools/video-keyframe-extractor.md
- **Developed by:** [Open Data Tools](https://apify.com/open-data-tools) (community)
- **Categories:** AI, Videos, Developer tools
- **Features:** 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 saveds

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 Keyframe Extractor: Scene Frames for AI Vision

Turn video files into a short set of still frames with timestamps, ready to send to GPT-4o, Claude or Gemini vision, to index a video library, or to make thumbnails. You pay only for frames you get: near-duplicates are dropped for free.

### What it does

- **Scene changes (default):** reads the video's keyframe index (no full decode), adds a frame wherever the video runs longer than *Max gap* without one, then drops frames that look like the previous one (perceptual hash). A 4-minute talk gave 9 distinct frames instead of 28 near-identical ones.
- **Every N seconds**, **N frames spread evenly**, or **exact timestamps** (`5, 1:30, 01:02:03.5`).
- **Max frames per video:** if more frames qualify, an evenly spread subset is kept, so the whole video is still covered.
- **Sized for AI:** longest side 1280 px by default (0 = original), JPEG, WebP or PNG, quality setting. Rotation and non-square pixels are corrected.
- **Start / end time** to work on part of a video.
- **Optional ZIP** of all frames per video.
- **Input:** direct video links (MP4, MOV, WEBM, MKV, AVI, M4V, MPEG-TS; H.264, H.265, VP9, AV1 and more), Dropbox and Google Drive share links, or another Actor's dataset (the link field is found automatically).

### Output

One dataset row per frame:

| Field | Example |
|---|---|
| `timestamp` / `timecode` | `13.917` / `00:00:13.917` |
| `imageUrl` | link to the frame image (opens without a token) |
| `width`, `height`, `bytes`, `format` | `1280`, `720`, `31032`, `jpeg` |
| `origin` | `keyframe`, `gap-fill`, `interval`, `count`, `timestamp` |
| `changeFromPrevious` | `0.39` (0 = identical, 1 = completely different) |
| `perceptualHash` | 64-bit dHash, hex, for your own dedupe |
| `videoDuration`, `videoWidth`, `videoHeight`, `videoFps`, `videoCodec` | video metadata |
| `zipUrl` | ZIP of all frames of this video (when on) |

Failed videos get one row with `status: failed` and the reason.

### Pricing

**$0.0015 per frame saved** ($1.50 per 1,000). No start fee, no per-video or per-minute fee. Dropped duplicates, failed videos and refused links are free. Free Apify plan: up to 100 frames per run. The run stops cleanly at your maximum charge.

### Limits

- Direct video files only. YouTube, TikTok, Instagram, Facebook, X, Vimeo and other streaming or social sites are refused: their terms forbid downloading. Use your own files or files you have the right to process.
- Videos up to 3 GB. Up to 1,000 frames per video.
- Scene mode follows the video's keyframes; most encoders place one at each cut, and the gap fill covers long shots. For frame-exact cut detection on every frame, use interval mode with a short interval.

### Tips

- For an LLM summary of a talk or screen recording: scene mode, max 20-30 frames, WebP.
- For thumbnails: count mode with 3-5 frames, dedupe off.
- Chain it after a downloader Actor with the dataset input.

# Actor input Schema

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

Direct links to video files (MP4, MOV, WEBM, MKV, AVI, M4V...). Dropbox and Google Drive share links are converted. YouTube, social media and streaming sites are refused.

## `datasetId` (type: `string`):

Take links from another Actor's dataset (e.g. a downloader or scraper). The link field is found automatically, or set it below.

## `urlField` (type: `string`):

Field name(s) with the video link, comma-separated, dot paths allowed. Empty = auto-detect (videoUrl, url, fileUrl, ...).

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

Scene changes uses the video's keyframes (encoders usually place one at every cut) plus a frame wherever the video goes longer than 'Max gap' without one, then drops near-duplicates.

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

Cap per video. If more frames qualify, an evenly spread subset is kept, so the whole video is still covered.

## `maxGapSec` (type: `number`):

Add a frame wherever the video has no keyframe for this long, so slow talks and screen recordings are covered too.

## `intervalSec` (type: `number`):

For 'one frame every N seconds'.

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

For 'N frames spread evenly'.

## `timestamps` (type: `string`):

For 'exact timestamps': seconds or mm:ss / hh:mm:ss, comma-separated, e.g. 5, 1:30, 01:02:03.5

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

Optional, e.g. 30 or 1:30. Frames before it are ignored.

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

Optional, e.g. 600 or 10:00.

## `dedupe` (type: `string`):

Frames that look like the previous kept frame (perceptual hash) are dropped and not charged. Not used in 'exact timestamps' mode.

## `maxSide` (type: `integer`):

Longest side of each frame. 1280 suits GPT-4o/Claude/Gemini vision input. 0 = original size.

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

JPEG works everywhere; WebP files are about 30% smaller; PNG is lossless and large.

## `quality` (type: `integer`):

Image quality for JPEG and WebP (80 is a good balance for AI vision).

## `zip` (type: `boolean`):

One ZIP with all frames of each video, linked in every row.

## Actor input object example

```json
{
  "videoUrls": [
    "https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4"
  ],
  "mode": "scenes",
  "maxFramesPerVideo": 30,
  "maxGapSec": 10,
  "intervalSec": 10,
  "frameCount": 10,
  "dedupe": "normal",
  "maxSide": 1280,
  "imageFormat": "jpeg",
  "quality": 80,
  "zip": false
}
```

# Actor output Schema

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

One row per frame with timestamp and image link.

## `files` (type: `string`):

Images and ZIP files in the key-value store.

# 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://download.blender.org/durian/trailer/sintel_trailer-480p.mp4"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("open-data-tools/video-keyframe-extractor").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://download.blender.org/durian/trailer/sintel_trailer-480p.mp4"] }

# Run the Actor and wait for it to finish
run = client.actor("open-data-tools/video-keyframe-extractor").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://download.blender.org/durian/trailer/sintel_trailer-480p.mp4"
  ]
}' |
apify call open-data-tools/video-keyframe-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,open-data-tools/video-keyframe-extractor"
        }
    }
}
```

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/ph4czolRk02cx5Fqv/builds/2UNBBBQ5RRhObnljb/openapi.json
