# Video & Audio Converter: MP3, Compress, GIF, Trim (`dojito/video-audio-converter`) Actor

Convert direct video and audio file URLs: extract audio to MP3 / M4A / WAV, compress or resize to H.264 MP4, trim a part, or make a GIF. Direct download link per file. From $0.004 per audio minute. Refused or failed files are free. No YouTube links.

- **URL**: https://apify.com/dojito/video-audio-converter.md
- **Developed by:** [Dongjin Kim](https://apify.com/dojito) (community)
- **Categories:** Videos, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.20 / 1,000 audio 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 & Audio Converter: MP3, Compress, GIF, Trim

Convert direct video and audio file URLs in bulk. Pick one operation per run:

| Operation | What you get |
|---|---|
| `extract-audio` | the sound track as **MP3**, **M4A (AAC)** or **WAV** — from a video or from another audio file |
| `compress` | a smaller **H.264 MP4** (quality set by CRF, scaled down to a max width) |
| `resize` | an H.264 MP4 at the **width you choose** (up or down, aspect ratio kept) |
| `trim` | only the part between **Start** and **End** (MP4 for video, your audio format for audio files) |
| `gif` | an **animated GIF** of up to 15 seconds (width and frame rate you choose) |

Start / End work with every operation (e.g. the audio of minutes 2–5, or a GIF from 0:42). Each converted file is saved in the run's key-value store with a direct download link, and each URL gets one dataset row with the input and output format, length, size, processing time and what was charged.

### What it does

1. Downloads each URL you give it (MP4, MOV, WebM, MKV, AVI, MPEG-TS, FLV, 3GP, WMV, MP3, M4A, WAV, FLAC, OGG, AAC, AIFF …), up to 2 GB.
2. Reads the file with ffprobe: length, video size (rotation and non-square pixels applied), frame rate, codecs.
3. Converts it with FFmpeg (one file at a time) and saves the result. **Metadata is removed** from every output (phone videos carry GPS location tags), chapters too.
4. Writes the row and **deletes the downloaded file** before moving to the next one.

Video outputs: H.264 (libx264, preset veryfast) + AAC 128 kb/s stereo in MP4 with fast start (plays while downloading), square pixels, even sizes, and never larger than **1920 px** on either side (no 4K output). GIF: a 256-colour palette tuned to the clip (from a sample of its frames), ordered dithering, loops forever.

### Input example

```json
{
  "mediaUrls": [
    { "url": "https://images-assets.nasa.gov/video/jsc2018m000903-STEMonstrations_Solar_Energy_MP4/jsc2018m000903-STEMonstrations_Solar_Energy_MP4~mobile.mp4" }
  ],
  "operation": "extract-audio",
  "audioFormat": "mp3",
  "audioBitrateKbps": 192
}
```

Add `"startTime": "0:30", "endTime": "2:00"` to convert only that part (times are strings, also through the API: `"30"`, not `30`). Other settings: `crf` (18 near-original … 40 smallest, default 28), `maxWidth` (compress, default 1280, 0 = keep), `width` (resize, default 1280), `gifWidth` (default 480, up to 800), `gifFps` (default 10, up to 25), `gifMaxSecs` (default 10, up to 15), `maxInputMB` (default 500), `maxDurationMin` (default 30, up to 180), `maxItems` (default 100).

### Output

One dataset row per URL (export as JSON, CSV or Excel):

```json
{ "mediaUrl": "https://…/STEMonstrations_Solar_Energy_MP4~mobile.mp4", "status": "ok", "operation": "extract-audio",
  "inputFormat": "mp4", "inputBytes": 6156160, "inputDurationSec": 150.6, "inputWidth": 320, "inputHeight": 180,
  "inputFps": 15, "inputVideoCodec": "h264", "inputAudioCodec": "aac", "startSec": null,
  "outputFormat": "mp3", "outputDurationSec": 150.57, "outputWidth": null, "outputHeight": null, "outputBytes": 3011962,
  "kvKey": "out-0001-jsc2018m000903-STEMonstrations_Solar_Energy_MP4-mobile.mp3",
  "kvUrl": "https://api.apify.com/v2/key-value-stores/…/records/out-0001-…mp3?signature=…",
  "processingSecs": 2.57, "chargedEvent": "audio-minute", "chargedCount": 3, "error": null, "note": null }
```

- **Files**: key `out-<number>-<input file name>.<mp3|m4a|wav|mp4|gif>` (number = position in your list).
- **ZIP link**: the `RUN_REPORT` record has a `zipUrl` with every output of the run. Apify builds the ZIP when the link is opened (no extra charge).
- Links carry a signature, so they open without an API token while the run's storage exists (Apify keeps unnamed storages for your plan's retention period). Anyone who has a link can download the file — don't share links to private files, and delete the run's storage when you are done.
- `RUN_REPORT` (JSON): files converted, output minutes, events charged, failed or refused files by reason, whether a limit stopped the run.
- Failed or refused URLs get a row too, with `status` = the reason (`platform_link`, `not_media`, `not_video`, `no_audio`, `too_large`, `too_long`, `robots_txt`, `http_error`, `nothing_to_convert`, `run_too_short` …) and `error` = the details.

### Pricing (pay per event)

You pay per **started minute of output** (a 2:30 output = 3 minutes), so trimming first costs less than converting everything.

| Event | Price | When |
|---|---|---|
| `audio-minute` | $0.004 (Bronze $0.0036, Silver and up $0.0032) | each started minute of audio output (extract-audio; trim of an audio file) |
| `video-minute` | $0.06 | each started minute of MP4 output up to 1280×720 pixels (compress, resize, trim) |
| `video-minute-hd` | $0.15 | each started minute of MP4 output larger than 1280×720 (up to 1920 px) |
| `gif` | $0.015 | each GIF up to 480×270 px, 10 fps and 15 s; bigger ones count in proportion (pixels × frames) |

Video prices are for input up to 1080p and 30 fps. Bigger or faster input takes longer to decode, so one output minute then counts as **size factor × frame-rate factor** minutes: input pixels ÷ 1080p pixels, rounded up (up to 1080p = 1, 1440p = 2, 4K = 4); frame rate ÷ 30, rounded up (up to 30 fps = 1, 60 fps = 2, 120 fps = 4). A 4K30 phone video compressed to 720p is 4 × $0.06 = $0.24 per minute. GIFs count the same input factor, and a GIF larger than 480×270 at 10 fps for 15 s counts in proportion to its pixels × frames (a 480×270 GIF at 10 fps of 1–15 s = 1, 640×360 at 15 fps for 10 s = 2, 800×450 at 25 fps for 15 s = 7). The row shows `chargedEvent` and `chargedCount`.

Examples (free plan prices): MP3 from 100 podcast videos of 20 minutes = 2,000 × $0.004 = **$8**. Compress a 3-minute 1080p30 video to 720p = 3 × $0.06 = **$0.18**. A 5-second 480 px GIF from each of 50 landscape (16:9) videos = 50 × $0.015 = **$0.75** (a portrait 480×854 GIF counts 2 for 5 s, 3 for 10 s).

Why video costs more than audio: re-encoding video is CPU-heavy (measured on Apify: about 0.7–0.75 CPU-seconds per second of 1080p→720p output and 1.4–1.9 for 1080p→1080p, CRF 28–18), and so is dithering every pixel of every GIF frame. Audio extraction needs almost no CPU.

Apify also charges its standard Actor start event ($0.00005 per GB of memory, so $0.0001 at the default 2 GB) once per run.

**Not charged**: refused links (platforms, web pages, playlists, robots.txt, private addresses), downloads that fail, files that are not audio / video, too big or too long, operations that don't fit the file (e.g. compress on an audio file, extract-audio on a silent video), Start past the end, conversions that would not finish before the run's timeout, outputs that could not be stored. You can set a maximum cost per run: the actor checks it before each file, so you never pay for work beyond it.

### Limits — read before you run

- **Direct files only.** Links to **YouTube, TikTok, Instagram, Facebook, X / Twitter, Vimeo, Twitch, Dailymotion, Reddit, LinkedIn, Loom, Wistia, SoundCloud, Spotify, Bandcamp, Deezer, Apple Music, Amazon Music, Mixcloud** and similar platforms (their CDNs and short links such as `spoti.fi`, `dai.ly`, `t.co` too) are refused before any request, by this actor's policy: platform terms generally restrict downloading media outside their players. Stock video sites (Shutterstock, Pond5, Storyblocks, Envato, Adobe Stock …) are refused too. This is **not** a downloader for streaming or video platforms. Use a file you have the right to process — your own server, a public S3 / R2 / CDN URL, a podcast's own MP3 file, or an Apify key-value store record.
- **No HLS / DASH** (`.m3u8`, `.mpd`) streams, no web pages with an embedded player, no login, cookies or paywalls.
- **robots.txt is obeyed** for every host on the way (first URL and redirects); one request at a time per host, with a pause. Large retailers' and stock-photo sites' hosts are never fetched.
- **Size and length**: `maxInputMB` default 500 (up to 2,000); `maxDurationMin` (the part to convert) default 30 (up to 180). Big files need more memory (Apify gives disk in proportion to memory): a file that would not fit the run's free disk is refused rather than failing half way.
- **Speed** (measured on Apify at the default 2 GB = half a CPU core, 150 s 1080p30 H.264, 87 MB): MP3 in 6 s; compress to 720p in 206 s (≈ 1.4× the video's length); compress at 1080p in 422 s (≈ 2.8×; 568 s at CRF 18); a default 10 s GIF in 7 s, an 800 px 25 fps 15 s GIF in 63 s. Give the run more memory (8 GB = 2 cores) to go faster — the price does not depend on memory. Before each video conversion the actor estimates the time and refuses (free) one that cannot finish before the run's timeout.
- **Trim accuracy**: cuts are frame-accurate (the video is re-encoded, not cut at key frames).
- One file at a time per run (FFmpeg uses the run's CPU); up to 1,000 URLs per run, `maxItems` (default 100) processed.
- Encrypted (DRM) files cannot be decoded and fail free of charge.

### Privacy and rights

The actor stores only the converted files and the rows above; the downloaded file is deleted as soon as its output is saved, and nothing is kept after the run beyond your run's own storage. Outputs carry no GPS location, device, title or artist tags from the input. It does not identify people or transcribe speech. You are responsible for having the right to convert the files you submit. Title, artist and copyright tags are not copied; re-tag the outputs if you must keep rights information. Removing metadata is a privacy default: GPS, device, title, artist, album and copyright tags (such as ID3) are dropped, and there is no option to keep them. Do not use this actor to remove someone else's copyright or rights-management information. If the files show or record identifiable people (face or voice, especially children), you are the controller of that personal data and need a lawful basis to process it.

### FAQ

**Why not YouTube or SoundCloud links?** Their terms generally restrict downloading media outside their players, and we only build tools that stay within site rules. If the video is yours, download it from YouTube Studio and host the file.

**Can I use a file from my Google Drive or Dropbox?** Google Drive links are refused (Google's terms of service prohibit automated access), and a Dropbox share link is a web page, not the file itself. Upload the file to an S3 / R2 bucket or an Apify key-value store and use its direct link instead.

**Which CRF should I use?** 23 looks like the original for most videos; 28 (default) is clearly smaller with a small loss of detail; 32+ for previews only.

**What is the user agent?** `DojitoMediaBot/1.0 (+https://apify.com/dojito/video-audio-converter; contact djkim@dojito.com)`.

**The run stopped early.** Check the status message and `RUN_REPORT`: it says whether your maximum cost per run or the run's timeout stopped it, and how many files were not started.

Sample video above: NASA, public domain (US federal government work). NASA does not endorse this actor. Not affiliated with or endorsed by any platform or brand named on this page (YouTube, SoundCloud, Spotify, Bandcamp, Apple, Amazon, Google, Dropbox …). General information, not legal advice.

# Actor input Schema

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

Direct links to media files (up to 1,000 per run): your own server, a public S3 / R2 / CDN URL or an Apify key-value store record. Links to YouTube, TikTok, Instagram, Facebook, X, Vimeo, SoundCloud, Spotify and other platforms are refused (platform terms generally restrict downloading), as are web pages, HLS / DASH playlists (.m3u8, .mpd) and sites whose robots.txt disallows the file. Refused URLs are not charged. Paste the URLs (Bulk edit: one per line).

## `operation` (type: `string`):

extract-audio = the sound track as MP3 / M4A / WAV. compress = smaller H.264 MP4 (CRF, max width). resize = H.264 MP4 at a given width. trim = only the part between Start and End (MP4 for video, the audio format for audio files). gif = animated GIF (up to 15 s).

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

Optional, every operation: where to start, in seconds (12.5) or m:ss / h:mm:ss (1:05). Empty = from the beginning. Trim needs Start and / or End.

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

Optional, every operation: where to stop (same format). Empty = to the end (GIF: at most 'GIF max length' from Start).

## `audioFormat` (type: `string`):

extract-audio, and trim of audio files: mp3 (LAME), m4a (AAC) or wav (16-bit PCM, about 10 MB per minute).

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

MP3 / M4A bitrate, 32 to 320 (WAV ignores it). Video outputs always get AAC 128 kb/s stereo.

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

compress, resize, trim: H.264 constant rate factor, 18 (near-original, large) to 40 (small, blurry). 23 = good quality, 28 = clearly smaller files.

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

compress: videos wider than this are scaled down, keeping the aspect ratio (never up). 0 = original size. Every output fits in 1920 x 1920 (no 4K output).

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

resize: output width, 16 to 1920, height follows the aspect ratio (up or down; a portrait video is also kept within 1920 px high).

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

gif: 64 to 800 (never wider than the video). A GIF counts as one charged GIF up to 480x270 px at 10 fps and 15 s; bigger ones (also portrait videos at this width) count in proportion to pixels x frames.

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

gif: 1 to 25. 10 is smooth enough for most clips and keeps the file small.

## `gifMaxSecs` (type: `number`):

gif: at most this many seconds from Start (0.5 to 15).

## `maxInputMB` (type: `integer`):

Larger files are refused before or while downloading (free). Up to 2,000; big files also need more memory (more disk).

## `maxDurationMin` (type: `integer`):

Files whose part to convert is longer are refused after a quick look at the file (free). Up to 180.

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

Process at most this many URLs from the list (the run report counts the rest as skippedByMaxItems).

## Actor input object example

```json
{
  "mediaUrls": [
    {
      "url": "https://images-assets.nasa.gov/video/jsc2018m000903-STEMonstrations_Solar_Energy_MP4/jsc2018m000903-STEMonstrations_Solar_Energy_MP4~mobile.mp4"
    }
  ],
  "operation": "extract-audio",
  "audioFormat": "mp3",
  "audioBitrateKbps": 192,
  "crf": 28,
  "maxWidth": 1280,
  "width": 1280,
  "gifWidth": 480,
  "gifFps": 10,
  "gifMaxSecs": 10,
  "maxInputMB": 500,
  "maxDurationMin": 30,
  "maxItems": 100
}
```

# Actor output Schema

## `overview` (type: `string`):

Input and output format, length, size, link, processing time, charge and error per URL.

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

The key-value store records of every converted file (keys starting with out-).

## `runReport` (type: `string`):

JSON: files converted, events charged, failures by reason, ZIP link of all outputs. Free.

# 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": [
        {
            "url": "https://images-assets.nasa.gov/video/jsc2018m000903-STEMonstrations_Solar_Energy_MP4/jsc2018m000903-STEMonstrations_Solar_Energy_MP4~mobile.mp4"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dojito/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": [{ "url": "https://images-assets.nasa.gov/video/jsc2018m000903-STEMonstrations_Solar_Energy_MP4/jsc2018m000903-STEMonstrations_Solar_Energy_MP4~mobile.mp4" }] }

# Run the Actor and wait for it to finish
run = client.actor("dojito/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": [
    {
      "url": "https://images-assets.nasa.gov/video/jsc2018m000903-STEMonstrations_Solar_Energy_MP4/jsc2018m000903-STEMonstrations_Solar_Energy_MP4~mobile.mp4"
    }
  ]
}' |
apify call dojito/video-audio-converter --silent --output-dataset

```

## MCP server setup

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