# Video Compressor & Resizer: Shrink MP4 for Web, Social & AI (`data-done-right/video-compressor`) Actor

Compress videos from direct file URLs to smaller H.264 mp4: 480p, 720p or 1080p presets, CRF quality or a target file size in MB. Any frame rate, audio kept or removed, signed download links, saved MB per video. No YouTube. Billed per output minute, free on failure.

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

## Pricing

from $16.00 / 1,000 video minute (720p)s

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 Compressor & Resizer: Shrink MP4 for Web, Social & AI

This **video compressor** shrinks video files from direct URLs into smaller **H.264 mp4** files: pick a 480p, 720p or 1080p size preset, set the quality with CRF, or ask for a **target file size in MB**. Every video gets a download link, its size before and after and the percent saved. 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** (mp4, mov, webm, mkv, avi) 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 **only outputs H.264/AAC mp4**: no H.265, AV1, WebM or GIF, and nothing above Full HD (4K sources are scaled down; sources above Full HD are limited to 10 minutes). It does not cut, crop, rotate, merge or add anything to the picture. A target size is a goal, not a guarantee: hard-to-encode footage can overshoot, and the row says so. If the result would not be smaller than the source, it is **not delivered and not charged**. It follows the robots.txt of the host that serves your files. Use it only on videos you own or have the right to process.

**What you get**

- One dataset row per video: source and result size in bytes, percent saved, source and result resolution, measured duration, the price tier and minutes billed, a signed download link, and a status or a clear error.
- Size presets by the **short side** of the picture, so portrait video works too (a 1080x1920 phone clip at 720p becomes 720x1280). Videos already smaller than the preset are never enlarged.
- Bad inputs never stop the run, say exactly what is wrong and are free.

### How to compress a video

1. Put one or more **direct video URLs** in `videoUrls`.
2. Choose a `preset` (`480p`, `720p` default, `1080p` or `original`) and, if you like, a quality `crf` (lower = better and bigger; default 26).
3. Run it. Open the dataset: each row has `url` to the compressed mp4 and `savedPercent`. The `SUMMARY` record totals the minutes billed and the bytes saved.

### How to compress a video to a target file size

Set `targetSizeMb`, for example `25` for an upload or email limit. The Actor works out the video bitrate from the duration (after reserving the audio bitrate) and runs a **two-pass encode**, which takes about twice as long. `crf` is ignored in this mode. The row has `targetBytes` and `targetMet`. If the target would leave less than 40 kbps for the picture, the video is rejected with a message that says so, for free. If the source is already under the target, it is skipped for free.

### How to resize a video for social media and the web

Use `preset: "720p"` and `maxFps: 30` for a light upload version, or `480p` for previews and chat. `removeAudio` drops the sound; `audioBitrateKbps` sets the AAC bitrate (default 96). Output is always yuv420p with `+faststart`, so it plays in browsers and starts before it has fully loaded. Metadata (including GPS tags) and chapters are removed.

### How to compress videos for AI and video pipelines

A 480p or 720p file at CRF 28 is usually much smaller than a camera original and still readable for frame sampling, vision models and transcription. Pair it with **Video Frame Extractor: Keyframes, Scenes & Thumbnails for AI** or a transcription step.

### Price tiers

You pay per output minute, in the tier of the **result** (short side of the output frame), not of the source or the preset:

| Result | Event | Per minute |
|---|---|---|
| up to 480 px (854x480, 640x360, 480x854) | `video-minute-sd` | $0.007 |
| 481 to 720 px (1280x720, 960x540, 720x1280) | `video-minute-720p` | $0.020 |
| 721 to 1080 px (1920x1080, 1080x1920) | `video-minute-1080p` | $0.040 |

The duration of the result is rounded **up** to whole minutes, with a minimum of 1 minute per video: a 5-second clip costs one SD minute ($0.007) and a 61-second clip two minutes.

### Input

| Field | Default | What it does |
|---|---|---|
| `videoUrls` | sample video | Direct video file links (required). |
| `preset` | `720p` | Short-side limit: `480p`, `720p`, `1080p` or `original` (capped at 1080). |
| `crf` | 26 | Quality, 18 (best) to 35 (smallest). Ignored with `targetSizeMb`. |
| `targetSizeMb` | empty | Aim for about this size (two-pass). |
| `maxFps` | 0 | Lower the frame rate to this value (0 = keep). |
| `removeAudio` | false | Drop the sound track. |
| `audioBitrateKbps` | 96 | AAC bitrate of the kept audio (first track, stereo). |
| `encoderPreset` | `veryfast` | `veryfast`, `faster`, `fast` or `medium`: slower = a bit smaller. |
| `deliverIfLarger` | false | Deliver and charge even if the result is not smaller. |
| `videos` | empty | Per-video overrides: `[{"url", "preset", "targetSizeMb", "name"}]`. |
| `maxDurationMinutes` | 30 | Source duration cap (above Full HD: 10 min). |
| `maxVideoSizeMb` | 500 | Source size cap (max 2048). |
| `maxVideosPerRun` | 50 | Hard cap on videos per run (max 1000). |
| `videoTimeoutSecs` | 1800 | Per download and per encode. |
| `outputStoreName` | empty | Save the 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"],
  "preset": "480p"
}
```

### Output

One row per video, from a real local run of the input above:

```json
{
  "sourceUrl": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4",
  "videoIndex": 1,
  "name": null,
  "preset": "480p",
  "mode": "crf",
  "sourceBytes": 1128375,
  "bytes": 180154,
  "savedBytes": 948221,
  "savedPercent": 84.0,
  "sourceWidth": 960,
  "sourceHeight": 540,
  "width": 854,
  "height": 480,
  "durationSeconds": 5.055,
  "tier": "video-minute-sd",
  "billedMinutes": 1,
  "targetBytes": null,
  "targetMet": null,
  "url": "https://api.apify.com/v2/key-value-stores/<store>/records/v01-compressed.mp4",
  "key": "v01-compressed.mp4",
  "status": "ok",
  "error": null,
  "note": null
}
```

A failure row has `status: "error"` and an `error` naming the problem. `status: "skipped"` means a free skip: the result would not be smaller, the source is already under your target, the spending limit was reached or `maxVideosPerRun` was hit. On Apify the `url` is a signed link that downloads without a token.

### 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-compressor").call(run_input={
    "videoUrls": ["https://example.com/demo.mp4"], "preset": "720p", "maxFps": 30})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["status"], row.get("savedPercent"), 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-compressor').call({
  videoUrls: ['https://example.com/demo.mp4'], targetSizeMb: 25 });
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: "compress this mp4 to under 25 MB". It needs only a video URL.

### Use cases

- Get product demos, screen recordings and UGC under an upload, email or chat size limit with `targetSizeMb`.
- Make light 720p copies of camera originals for a CMS, a web page or a review tool.
- Shrink a video library before storing it or feeding it to a vision or transcription pipeline.
- Cap frame rate and size of user-submitted video in a content workflow.
- Re-wrap odd formats (mov, mkv, avi, webm) as a standard H.264 mp4 that plays everywhere (set `deliverIfLarger` if the result may be bigger).

### How much does it cost

Pay per event, per output minute: **$0.007 SD, $0.02 720p, $0.04 Full HD** (see the table above). Failed videos, skipped videos, rejected links and the `SUMMARY` record are free. Plan discounts apply (Silver about 10%, Gold and higher about 20%).

- 1,000 minutes at 720p: $20 (for example 1,000 one-minute clips).
- 10,000 minutes at 480p: $70.
- 1,000 videos of 5 minutes at 1080p: 5,000 minutes, $200.

Apify platform usage is included. `maxVideosPerRun` 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. Speed: in a local single-thread test a generated 1080p clip encoded at about 3.5x real time at 1080p and 8x at 720p; cloud machines are slower than a desktop, and real footage is slower than test patterns, so budget a few minutes for each 10-minute video.

### FAQ

#### Will it make my file smaller every time?

Not always. A video that is already heavily compressed can come out bigger. In that case the row says `skipped` with the sizes, and you are not charged. Choose a smaller preset or a higher `crf`, or set `deliverIfLarger` if you want the re-encode anyway.

#### Does the target size hit the number exactly?

No. It sets a bitrate from the duration and runs two passes, which usually lands close to the target, but complex footage can overshoot. Each row has `targetMet`. If it is false, lower `targetSizeMb` a little or use a smaller preset.

#### Which size does the price depend on?

On the short side of the file we produce. A 640x360 source at the 720p preset stays 640x360 (it is not enlarged) and is billed at the SD rate.

#### What about portrait video and audio?

Portrait and landscape both work, because presets limit the short side. The first audio track is kept as AAC stereo; other audio tracks, subtitle tracks, data tracks, chapters and metadata are dropped.

#### Which limits apply?

Source files up to 2 GB (default 500 MB) and 30 minutes by default (set `maxDurationMinutes` for more; above Full HD the limit is 10 minutes and frames larger than 4K are rejected), up to 1,000 videos per run. Links to private or internal addresses are blocked, and the hosts of your files must allow automated fetching in their robots.txt. The whole source file is downloaded once per video.

#### How long are the files kept?

They 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 them.

### 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 and makes GIFs.
- **Merge Videos: Concatenate, Join & Combine Video Clips** joins clips into one file.
- **Add Watermark to Video: Logo, Text & Image Overlay (Bulk)** puts a logo or text on the same files.
- **Extract Audio from Video: MP3, WAV & FLAC in Bulk** keeps only the sound.

# Actor input Schema

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

Direct links to video files (mp4, mov, webm, mkv, avi). Example: https://example.com/clip.mp4. YouTube, Vimeo, TikTok and other streaming-site page links are rejected, with no charge.

## `preset` (type: `string`):

Longest allowed length of the SHORT side of the picture, so it works for landscape and vertical video alike: 720p turns 1920x1080 into 1280x720 and 1080x1920 into 720x1280. Videos already smaller are never enlarged. 'Original' keeps the size, but anything above Full HD is reduced to 1080. The price tier follows the size of the result.

## `crf` (type: `integer`):

Lower is better quality and bigger files: 20 is near the source, 26 is a good web default, 30 is small. Ignored when 'Target size' is set.

## `targetSizeMb` (type: `number`):

Optional. Aim for a file of about this many MB, for example 25 for an email or chat limit. Uses a two-pass bitrate encode (about twice the encoding time). The result can overshoot on hard-to-encode footage; each row says whether the target was met. 0 or empty = use CRF.

## `maxFps` (type: `integer`):

Lower higher frame rates to this value, for example 30 turns 60 fps into 30 fps for smaller files. 0 = keep the source frame rate.

## `removeAudio` (type: `boolean`):

Drop the sound track. Saves a little space. Default: audio is kept (first audio track, AAC stereo).

## `audioBitrateKbps` (type: `integer`):

AAC bitrate for the kept audio track. 96 is fine for speech, 128 to 192 for music.

## `encoderPreset` (type: `string`):

Slower settings give a somewhat smaller file at the same quality and take longer. The price per minute does not change.

## `deliverIfLarger` (type: `boolean`):

By default a result that is not smaller than the source is not delivered and not charged (the row says why). Turn on to receive and pay for it anyway, for example to get a uniform H.264 mp4.

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

Per-video settings: \[{"url": "https://example.com/a.mp4", "preset": "480p", "targetSizeMb": 10, "name": "promo"}]. Added to 'Video URLs'; an entry overrides the run-level preset and target size for its URL.

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

Longer source videos are rejected without charge. Example: 30. Sources above Full HD (up to 4K) are limited to 10 minutes.

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

Source files above this size are rejected before the download finishes.

## `maxVideosPerRun` (type: `integer`):

Hard cap on videos processed in one run (and so on what you can be charged). Videos past the cap are listed as skipped.

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

Applies separately to each download and to the encoding of each video.

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

Optional key-value store name. Named stores are kept until you delete them, while a run's own store expires after your plan's retention period. Example: compressed-videos.

## Actor input object example

```json
{
  "videoUrls": [
    "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
  ],
  "preset": "480p",
  "crf": 26,
  "maxFps": 0,
  "removeAudio": false,
  "audioBitrateKbps": 96,
  "encoderPreset": "veryfast",
  "deliverIfLarger": false,
  "maxDurationMinutes": 30,
  "maxVideoSizeMb": 500,
  "maxVideosPerRun": 50,
  "videoTimeoutSecs": 1800
}
```

# Actor output Schema

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

One row per video with its download link, size before and after, saved percent, price tier and status, as JSON, CSV, Excel and more.

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

Key-value store records: the compressed mp4 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"
    ],
    "preset": "480p"
};

// Run the Actor and wait for it to finish
const run = await client.actor("data-done-right/video-compressor").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"],
    "preset": "480p",
}

# Run the Actor and wait for it to finish
run = client.actor("data-done-right/video-compressor").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"
  ],
  "preset": "480p"
}' |
apify call data-done-right/video-compressor --silent --output-dataset

```

## MCP server setup

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

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/nC77x9F7l1A5gOW8m/builds/8abqVDfznimRWeryx/openapi.json
