# Video Converter & Compressor (FFmpeg) — MP4, WebM, MP3, GIF (`northbell/video-audio-converter`) Actor

Convert and compress media file links in bulk: MP4 (H.264/AAC), WebM, MP3, M4A, WAV, GIF. Resize, change bitrate or quality, trim, extract audio. Results are files in the run's key-value store with public links.

- **URL**: https://apify.com/northbell/video-audio-converter.md
- **Developed by:** [Northbell](https://apify.com/northbell) (community)
- **Categories:** 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

from $8.00 / 1,000 minutes

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 Converter & Compressor (FFmpeg) — MP4, WebM, MP3, GIF

**Convert and compress video and audio file links in bulk.** Give it direct links to media files (or a dataset from another Actor) and get MP4 (H.264/AAC), WebM, MP3, M4A, WAV or GIF back as files with public links. You can resize, change quality or bitrate, trim, and extract the audio.

**Try it now — the input is already filled in.** Press **Start**. It converts a 5-second, 1080p sample MP4 (2.8 MB, from samplelib.com, free to use without restrictions) to MP4 at a maximum height of 480 px. In our own local run with this input: **2,848,208 bytes in, 841,803 bytes out (70.4% smaller), about 7 seconds** including the download. That output is 854 x 480, so it is billed as 1 video minute: **$0.01** (plus $0.00005 for the run start).

### What you pay

| Event | Price | When |
| --- | --- | --- |
| `video-minute` | $0.01 | per started minute of output, mp4 or webm, output height up to 720 px |
| `hd-video-minute` | $0.03 | per started minute of output, mp4 or webm, output height above 720 px |
| `audio-minute` | $0.003 | per started minute of output, mp3, m4a or wav |
| `gif` | $0.015 | per GIF (30 seconds at most) |
| `apify-actor-start` | $0.00005 | once per run |

- You are charged for a file only after the result is saved. Errors, rejected links and files that could not be converted are free.
- "Started minute" means 0 to 60 seconds is one minute, 61 to 120 is two, and so on (a result that is 0.5 seconds over a full minute because of encoder padding still counts as that minute). Length is the length of the output, after trimming.
- Set "Maximum total charge" on the run as your cap. The Actor checks that the next file fits under it before it starts converting, and stops cleanly when it does not.

### Run it after your scraper or downloader

If another Actor collects direct links to media files, this Actor can convert them automatically after every run of it:

1. In Apify Console, open that Actor and go to **Integrations**.
2. Add **Run Actor** (on "Run succeeded") and pick this Actor.
3. Use an input like this, with the name of the field that holds the file link:

```json
{
  "datasetId": "{{resource.defaultDatasetId}}",
  "urlField": "videoMeta.downloadAddr",
  "outputFormat": "mp4",
  "maxHeight": 720,
  "videoQuality": "balanced"
}
```

Each run of the first Actor then hands over its dataset, and every link in it is converted. A dotted path such as `videoMeta.downloadAddr` reaches into nested fields. A dataset row's link may also be an array; the first string in it is used. The same input works with a fixed `datasetId` on a schedule: turn on **Only links not converted before** (`onlyNewLinks`) and each scheduled run converts and charges only the links that are new since the last run. A link converted before with the same settings is skipped, free; a different format or size counts as new. If the dataset is empty, nothing runs and nothing is charged. Each output row keeps a small `sourceItem` (the link and the row's `id` if it has one) so you can match results to the original rows.

### Formats and options

| Output | What you get | Notes |
| --- | --- | --- |
| `mp4` | H.264 video + AAC audio, `faststart` | plays almost everywhere |
| `webm` | VP9 video + Opus audio | slower to encode, smaller files |
| `mp3` | audio only | uses `audioBitrateKbps` |
| `m4a` | AAC audio only | uses `audioBitrateKbps` |
| `wav` | uncompressed 16-bit PCM audio only | large files |
| `gif` | silent animation, 30 seconds at most | uses `gifFps` and `gifWidth` |

| Input | Default | What it does |
| --- | --- | --- |
| `mediaUrls` | sample link | direct links to media files |
| `datasetId`, `urlField` | - , `url` | read links from another Actor's dataset; dotted paths allowed |
| `outputFormat` | `mp4` | one of the formats above |
| `maxHeight` | none | mp4 and webm: scale down to this height, keep the aspect ratio, even dimensions; never scales up |
| `videoQuality` | `balanced` | mp4 and webm: `high`, `balanced` or `small`. H.264 CRF 20 / 26 / 32; VP9 CRF 28 / 33 / 38 |
| `audioBitrateKbps` | 128 | audio track of mp4 and webm, and mp3 and m4a (32 to 320) |
| `startSeconds`, `endSeconds` | none | cut the file; `endSeconds` must be larger than `startSeconds` |
| `gifFps`, `gifWidth` | 10, 480 | GIF frame rate and width |
| `maxItems` | 50 | files per run (links and dataset together) |
| `maxFileMb` | 1024 | largest input, and largest result, in MB (hard cap 2048) |
| `onlyNewLinks` | off | skip links already converted with the same settings in an earlier run, free |

If a file has no video track, converting it to mp4, webm or gif is an error; if it has no audio track, mp3, m4a and wav are an error. If an mp4 or webm source has no audio, the result simply has none.

### Output

One dataset row per input, in the order processed. The converted file is stored in the run's key-value store, and `outputUrl` is its public link.

```json
{
  "inputUrl": "https://download.samplelib.com/mp4/sample-5s.mp4",
  "status": "ok",
  "error": null,
  "outputUrl": "https://api.apify.com/v2/key-value-stores/bd972cdb-73b3-4a14-995f-1b0021cf597b/records/0a9ed12a87af.mp4",
  "outputKey": "0a9ed12a87af.mp4",
  "format": "mp4",
  "durationSeconds": 5.8,
  "width": 854,
  "height": 480,
  "inputBytes": 2848208,
  "outputBytes": 841803,
  "savedPercent": 70.4,
  "charged": { "eventName": "video-minute", "count": 1 }
}
```

This row is from our local run of the prefilled input; the store id in the link is the one that run used on our machine. On Apify it is your run's store. For a failed input, `status` is `error`, `error` says why in plain words, `outputUrl` is `null` and `charged` is `null`. The result files stay as long as your Apify storage retention keeps the run.

### Limits

- **Direct file links only.** Links to video platform pages (YouTube, TikTok, Instagram, Facebook, X/Twitter, Vimeo) are rejected with an error and are free; this Actor does not download from those sites. Give the direct file link, for example from a downloader Actor's dataset. Links to private or local network addresses are also rejected.
- The link must be reachable without a login and must not return a web page.
- Size cap: `maxFileMb`, 1024 MB by default and 2048 MB at most. It applies to the input and to the result.
- A GIF is at most 30 seconds; for longer files set `startSeconds` and `endSeconds`.
- One file at a time per run (encoding uses all the CPU). Long HD videos take a while: the Actor allows the encoder time in proportion to the length, and stops 30 seconds before the run's time limit, keeping what is already saved. For many long files, raise the run's timeout and memory.
- Your files are processed only inside this Actor's run on Apify; nothing is sent to other services.
- You are responsible for having the right to convert the media you give it.

### 日本語

動画・音声ファイルへの直リンク(または他の Actor のデータセット)を、MP4・WebM・MP3・M4A・WAV・GIF に変換・圧縮します。サイズ変更、画質・ビットレート指定、切り出し、音声の取り出しに対応。結果は実行のキー・バリューストアに保存され、公開リンクが返ります。料金は出力1分あたり $0.003(音声)/ $0.01(720p 以下の動画)/ $0.03(720p 超の動画)、GIF は1つ $0.015。保存できた分だけ課金され、失敗・対応外リンクは無料です。YouTube などの動画サイトのページのリンクは対応しません(直リンクを指定してください)。変換するメディアの権利はご自身でご確認ください。

# Actor input Schema

## `mediaUrls` (type: `array`):

Direct links to video or audio files. Or leave empty and give a Dataset ID. Links to video sites (YouTube, TikTok, Instagram, Facebook, X, Vimeo) are web pages, not files: they come back as errors, free.

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

Read file links from this Apify dataset (e.g. the dataset of a downloader or scraper run). Use {{resource.defaultDatasetId}} when you connect this Actor as an integration after another Actor.

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

Name of the field that holds the file link. A dotted path works, for example videoMeta.downloadAddr.

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

mp3, m4a and wav keep only the audio. gif is a silent animation.

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

mp4 and webm only. Scales the picture down to this height (the width follows, the aspect ratio is kept). Never scales up. Empty keeps the original size.

## `videoQuality` (type: `string`):

mp4 and webm only. Sets the constant-quality level: H.264 CRF 20 / 26 / 32, VP9 CRF 28 / 33 / 38.

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

For the audio track of mp4 and webm and for mp3 and m4a. Not used for wav.

## `startSeconds` (type: `number`):

Cut: drop everything before this second.

## `endSeconds` (type: `number`):

Cut: drop everything after this second. Must be larger than the start. Required for gif when the file is longer than 30 seconds.

## `gifFps` (type: `integer`):

gif only.

## `gifWidth` (type: `integer`):

gif only. The height follows. Never scales up.

## `maxItems` (type: `integer`):

Cap on files per run, counting the links above and the dataset together.

## `maxFileMb` (type: `integer`):

Larger inputs, and results larger than this, come back as errors, free. Hard cap 2048.

## `onlyNewLinks` (type: `boolean`):

For a scheduled run on the same dataset: a link already converted with the same settings in an earlier run is skipped, free. Every run remembers what it converted (in the saved store video-audio-converter-seen), also with this off.

## Actor input object example

```json
{
  "mediaUrls": [
    "https://download.samplelib.com/mp4/sample-5s.mp4"
  ],
  "urlField": "url",
  "outputFormat": "mp4",
  "maxHeight": 480,
  "videoQuality": "balanced",
  "audioBitrateKbps": 128,
  "gifFps": 10,
  "gifWidth": 480,
  "maxItems": 50,
  "maxFileMb": 1024,
  "onlyNewLinks": false
}
```

# Actor output Schema

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

Status, result link, sizes and charge per input.

# 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 = {
    "mediaUrls": [
        "https://download.samplelib.com/mp4/sample-5s.mp4"
    ],
    "outputFormat": "mp4",
    "maxHeight": 480
};

// Run the Actor and wait for it to finish
const run = await client.actor("northbell/video-audio-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 = {
    "mediaUrls": ["https://download.samplelib.com/mp4/sample-5s.mp4"],
    "outputFormat": "mp4",
    "maxHeight": 480,
}

# Run the Actor and wait for it to finish
run = client.actor("northbell/video-audio-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 '{
  "mediaUrls": [
    "https://download.samplelib.com/mp4/sample-5s.mp4"
  ],
  "outputFormat": "mp4",
  "maxHeight": 480
}' |
apify call northbell/video-audio-converter --silent --output-dataset

```

## MCP server setup

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