# Video Compressor & Resizer (`bossless/video-compressor`) Actor

Compress and resize video files.

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

## Pricing

from $35.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

Fast, privacy-focused cloud video compression, resizing, and aspect-ratio reframing powered by FFmpeg. Compress videos to fit strict platform limits (Discord, WhatsApp, Email) or reframe videos for social platforms (TikTok, Instagram Reels, YouTube Shorts) with instant download links.

***

### Key Features

- **Ready-Made Platform Presets:**
  - **Discord 10MB:** Compress video to fit Discord's free upload limit with two-pass bitrate optimization.
  - **WhatsApp 16MB:** Target the WhatsApp document attachment ceiling.
  - **Email 25MB:** Perfect for Gmail, Outlook, and standard mail server attachment limits.
  - **Web 720p:** Fast web delivery with balanced CRF 23 compression and web faststart.
  - **Social Vertical (1080x1920):** 9:16 reframe for Instagram Reels, TikTok, and YouTube Shorts.
  - **Social Square (1080x1080):** 1:1 feed posts.
- **Aspect-Ratio Reframing (Fit Modes):**
  - `contain`: Fit the entire video within target dimensions with neat black padding. Never crops footage.
  - `cover`: Crop edges to fill the target frame completely.
  - `stretch`: Force exact dimensions.
- **Never Upscales:** Small videos are kept at their native resolution when downscaling is requested.
- **Privacy by Default:** Automatically strips EXIF data, GPS location coordinates, camera models, and private device tags (`-map_metadata -1 -map_chapters -1`).
- **Instant Web Playback:** Enables `-movflags +faststart` so output videos stream immediately in browsers without downloading the full file first.
- **Direct Streaming Delivery:** Outputs are stored in the run's default Key-Value Store and returned as direct, public download links.

***

### Pricing (Pay-Per-Event)

You only pay for what you compress, billed by the started output minute according to resolution tier:

| Resolution Tier | Max Dimension | Price per Started Minute | Notes |
|---|---|---|---|
| **<=720p** | <= 720p short side | **$0.035** | Standard HD and SD compression |
| **1080p** | <= 1080p short side | **$0.070** | Full HD high-definition video |
| **4K** | > 1080p short side | **$0.280** | Ultra HD 4K video processing |

#### Fair Billing Rules

1. **Target Size (Two-Pass):** When using `targetSizeMb` or target-size presets (Discord, WhatsApp, Email), encoding performs two analytical passes to accurately hit file size limits, billing **2 minutes per output minute**.
2. **Input Tier Protection:** To account for high decode compute overhead, downscaling high-resolution inputs bills at `max(output_tier, input_tier - 1)`. For example, downscaling a 4K input to 720p bills at the 1080p tier ($0.070/min).
3. **Failed / Broken Inputs:** Invalid URLs, unreachable links, or non-video files write an informative status record to your dataset and are **never charged**.

***

### Example Input

#### Compress for Discord (10 MB target)

```json
{
  "videoUrls": [
    "https://example.com/gameplay-recording.mp4"
  ],
  "preset": "discord-10mb"
}
```

#### Reframe Landscape Video to 9:16 Vertical Reel

```json
{
  "videoUrls": [
    "https://example.com/landscape-clip.mp4"
  ],
  "width": 1080,
  "height": 1920,
  "fit": "contain",
  "maxFps": 30
}
```

#### Advanced Custom Compression

```json
{
  "videoUrls": [
    "https://example.com/raw-footage.mov"
  ],
  "maxResolution": 720,
  "crf": 26,
  "mute": true,
  "stripMetadata": true
}
```

***

### Output Dataset Schema

Each processed video produces a structured dataset record:

```json
{
  "status": "success",
  "url": "https://example.com/gameplay-recording.mp4",
  "downloadUrl": "https://api.apify.com/v2/key-value-stores/.../records/compressed-a1b2c3d4.mp4",
  "inputSizeMb": 48.5,
  "outputSizeMb": 9.8,
  "savedPercent": 79.79,
  "durationSecs": 58.4,
  "inputResolution": "1920x1080",
  "outputResolution": "1280x720",
  "bitrateKbps": 1340,
  "codec": "h264",
  "targetHit": true,
  "billedMinutes": 2,
  "billingTier": "720p",
  "timings": {
    "downloadSecs": 2.4,
    "encodeSecs": 38.1,
    "uploadSecs": 1.2,
    "totalSecs": 41.7
  }
}
```

***

### Ready-made Video Compressor Tasks

To streamline common workflows, you can run or schedule ready-made task configurations:

- [Compress for Discord (10MB)](https://apify.com/bossless/video-compressor/examples/compress-for-discord) — Downscales to 720p and hits <=10MB.
- [Compress for WhatsApp (16MB)](https://apify.com/bossless/video-compressor/examples/compress-for-whatsapp) — Optimizes bitrate to fit WhatsApp's 16MB document limit.
- [Web-Ready 720p Faststart](https://apify.com/bossless/video-compressor/examples/web-ready-720p) — Balanced CRF 23 encoding with faststart streaming.
- [Reframe to Vertical 9:16](https://apify.com/bossless/video-compressor/examples/social-vertical-reframe) — Converts landscape video into 1080x1920 vertical format for Instagram Reels and TikTok.

***

### FAQ

##### Where are my compressed videos stored?

Videos are streamed into the run's default Key-Value Store and returned as direct `downloadUrl` links in your dataset. Under standard Apify retention policies, records in unnamed run stores are preserved for 7 days. If you require permanent hosting, download the files or archive them to your cloud storage.

##### What sources are supported?

Direct HTTP/HTTPS video links, Google Drive file sharing links ("Anyone with the link"), and Dropbox share links.

##### What video formats are accepted?

MP4, MOV, MKV, WebM, AVI, FLV, and TS containers using standard H.264, H.265 (HEVC), VP8, VP9, or AV1 codecs. All compressed outputs are standardized to universally compatible H.264 video with AAC audio in an MP4 container.

##### Is this actor affiliated with Discord, WhatsApp, or FFmpeg?

No. This actor is an independent utility created by `bossless` and is not affiliated with, endorsed by, or sponsored by Discord Inc., Meta Platforms Inc. (WhatsApp), or the FFmpeg project. FFmpeg is used under the GNU General Public License (GPLv3).

# Actor input Schema

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

Direct links to video files, Google Drive links, or Dropbox links.

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

Ready-made compression & dimension presets for common platforms.

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

Target file size in megabytes using two-pass encoding. Bills 2x minutes.

## `maxResolution` (type: `string`):

Downscale video so its short side does not exceed this value (e.g. 720, 1080). Never upscales.

## `fit` (type: `string`):

How to fit video into exact target dimensions when Width and Height are specified.

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

Exact target width in pixels (e.g. 1080 for vertical reels).

## `height` (type: `integer`):

Exact target height in pixels (e.g. 1920 for vertical reels).

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

Constant Rate Factor. 18 = visually lossless, 23 = balanced default, 28 = high compression.

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

Cap output frame rate. Drops surplus frames, never duplicates.

## `mute` (type: `boolean`):

Completely strip audio streams from the output video to save space.

## `stripMetadata` (type: `boolean`):

Strip camera details, GPS coordinates, and personal device tags.

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

Safety cap: reject videos longer than this duration.

## `maxCostUsd` (type: `number`):

Stop processing if cumulative run charges reach this budget.

## Actor input object example

```json
{
  "videoUrls": [
    "https://api.apify.com/v2/key-value-stores/T5HtoeQYut1ufwkKC/records/short-cuts.mp4"
  ],
  "preset": "web-720p",
  "maxResolution": "720",
  "fit": "contain",
  "crf": 23,
  "maxFps": 30,
  "mute": false,
  "stripMetadata": true,
  "maxDurationMinutes": 60,
  "maxCostUsd": 10
}
```

# Actor output Schema

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

No description

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

No description

# 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://api.apify.com/v2/key-value-stores/T5HtoeQYut1ufwkKC/records/short-cuts.mp4"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("bossless/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://api.apify.com/v2/key-value-stores/T5HtoeQYut1ufwkKC/records/short-cuts.mp4"] }

# Run the Actor and wait for it to finish
run = client.actor("bossless/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://api.apify.com/v2/key-value-stores/T5HtoeQYut1ufwkKC/records/short-cuts.mp4"
  ]
}' |
apify call bossless/video-compressor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bossless/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/v69PtCh5SX1XssINL/builds/KoqBfe9QUzrmHLbHr/openapi.json
