# Extract Audio from Video – MP4 to MP3, WAV, FLAC in Bulk (`gazidev/extract-audio-from-video`) Actor

Extract the audio track from your video files: MP4, MOV, WebM, MKV or AVI to MP3, M4A, WAV, FLAC or Opus. Choose bitrate, mono or stereo and sample rate, normalise loudness, and split long audio into chunks that fit the Whisper API's 25 MB limit. Bulk from URLs or a dataset. $3 per 1,000 minutes.

- **URL**: https://apify.com/gazidev/extract-audio-from-video.md
- **Developed by:** [Cemal Atakli](https://apify.com/gazidev) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 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.

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

## Extract Audio from Video – MP4 to MP3, WAV, FLAC in Bulk

**Extract the audio track from your video files** and get download links for MP3, M4A (AAC), WAV, FLAC, Opus or OGG files. Paste one link or thousands, or read them from another Actor's dataset. There is a **speech preset** for transcription (16 kHz mono), **two-pass loudness normalisation** (EBU R128), and **chunking** by minutes or by file size, so every piece fits the **OpenAI Whisper API's 25 MB upload limit**.

> **Your own files only.** This Actor processes direct links to media files that you own or are allowed to process: your CDN, S3/R2/GCS bucket, Dropbox or Google Cloud direct links, or files you upload in the Console. It is **not a YouTube, Facebook, TikTok or Instagram downloader**. Links to those platforms (and Vimeo, SoundCloud, Spotify and similar) are refused with a free error row.

### What it does

- **Video to MP3 and more:** MP4, MOV, MKV, WebM, AVI, M4V, MPEG-TS and HLS `.m3u8` playlists in; MP3, M4A, WAV, FLAC, Opus or OGG out. Audio files (MP3, WAV, M4A...) work as input too.
- **Lossless stream copy:** with the `original` preset, the audio is copied without re-encoding when it fits the output format (for example AAC from an MP4 into M4A, or Opus from a WebM/MKV into Opus/OGG). This is fast and keeps the exact quality. `streamCopied: true` tells you it happened.
- **Speech / transcription preset:** 16 kHz mono at 64 kbps (MP3, M4A, Opus) or 16-bit (WAV, FLAC). A 64 kbps MP3 is about 0.48 MB per minute, so about 50 minutes fit in one Whisper upload.
- **Split into chunks:** `splitMinutes` (for example 10) or `splitMaxMb` (for example 24 for Whisper). Every chunk is its own file and dataset row, with `chunkStart` and `chunkEnd` in seconds of the **source** video, so you can stitch transcripts back together.
- **Loudness normalisation:** two-pass `loudnorm` to -16 LUFS / -1.5 dBTP. Each row reports the source loudness (`sourceLufs`) and the result (`integratedLufs`, `truePeakDb`).
- **Pick the audio track:** for files with several tracks (languages, commentary), set `audioStreamIndex`. Each row shows how many tracks the file has (`audioStreams`) and the track language.
- **Trim:** `startTime` / `endTime` (`90` or `00:01:30`).
- **Custom output:** bitrate (32–320 kbps), mono or stereo, sample rate.

### Use cases

- **Transcription pipelines:** turn recorded meetings, lectures, interviews and webinars into small, Whisper-ready MP3 chunks for OpenAI Whisper, Deepgram, AssemblyAI or a local model. Then pass the dataset to a speech-to-text Actor.
- **Podcasters:** turn video episodes into MP3 or M4A files for the audio feed, with consistent loudness.
- **Dataset builders:** extract 16 kHz mono WAV or FLAC from many videos for speech or audio ML datasets.
- **Video teams:** pull the original AAC track out of MP4 masters without re-encoding.

### Input example

```json
{
  "mediaUrls": ["https://download.samplelib.com/mp4/sample-10s.mp4"],
  "audioFormat": "mp3",
  "preset": "speech",
  "splitMaxMb": 24,
  "normalizeAudio": false
}
```

Other ways to give files: `bulkText` (one URL per line, or a CSV with a `url` column), `datasetId` + `datasetField` (chain after another Actor), or `uploadedFiles` + `uploadStore` (files uploaded in the Console).

### Output example

One row per output file (one per chunk when you split). The files are in the run's key-value store; `audioUrl` is the download link.

```json
{
  "sourceUrl": "https://download.samplelib.com/mp4/sample-10s.mp4",
  "status": "ok",
  "audioUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/000-sample-10s.mp3",
  "fileKey": "000-sample-10s.mp3",
  "format": "mp3",
  "bitrateKbps": 192,
  "sampleRate": 44100,
  "channels": 2,
  "durationSec": 10.216,
  "bytes": 247056,
  "chunkIndex": 0,
  "chunkCount": 1,
  "chunkStart": 0.0,
  "chunkEnd": 10.216,
  "streamCopied": false,
  "sourceCodec": "aac",
  "sourceDurationSec": 10.216,
  "audioStreams": 1,
  "billedEvents": {"audio-minute": 1}
}
```

Failed files get a row with `status: "error"`, an `errorCode` (`UNSUPPORTED_PLATFORM`, `NOT_MEDIA`, `NO_AUDIO_STREAM`, `FILE_TOO_LARGE`, `TOO_LONG`, `HTTP_404`, ...) and a readable `error`. They are **not charged**. The `OUTPUT` record in the key-value store has a run summary.

### Pricing

Pay per event, **$3 per 1,000 audio minutes**:

| Event | Price | When |
|---|---|---|
| `audio-minute` | $0.003 | Per started minute of extracted audio, per file (a 10 s clip = 1 minute; a 61-minute video split into 3 chunks = 62 minutes, chunks are not rounded one by one) |
| `normalized-minute` | $0.003 | Only with `normalizeAudio`, per started audio minute |
| Actor start | $0.00005 | Once per run |

Free: invalid or platform URLs, web pages, files without audio, files over your limits, download and conversion errors, and files skipped at your maximum charge. When your **maximum total charge** for the run would be exceeded, the next file is skipped (free) and the run stops gracefully.

Comparison (Apify Store, November 2026, file-based audio extractors):

| Actor | Price |
|---|---|
| **This Actor** | $0.003 per minute; speech preset, chunking by MB, loudness, track picking |
| data-done-right/extract-audio-from-video | $0.003 per minute |
| adorable_partial/audio-extractor | $0.003 per minute |
| ataism/whisper-audio-splitter | $0.002 per minute |
| ponderable_hydrometer/video-to-audio | $0.01 per file |

Need video compression, GIFs, speed changes or audio conversion as well? See [Video Converter & Compressor](https://apify.com/gazidev/media-converter).

### Limits (honest)

- Direct file links only: the server must return the file itself, not a web page. Private links need a signed URL or an upload.
- The whole video is downloaded once (audio is interleaved with video), so a 2 GB file takes some seconds to download. Default limits: 2,000 MB per input file and 300 minutes per file; you can raise both. Above about 1,000 MB, give the run 2,048 MB or more memory.
- Each output file is held in memory once while it is saved. A very long uncompressed WAV can be too large for the run's memory; the Actor then returns a free `OUTPUT_TOO_LARGE` error. Use `splitMinutes`, a lossy format or more memory.
- `splitMaxMb` computes the chunk length from the bitrate. Opus and OGG are variable bitrate and get a 10% safety margin; any chunk above the limit gets a `warning`.
- Lossy formats are capped at stereo; WAV and FLAC keep all channels unless you use `speech` or `custom`.
- Files are kept in the run's key-value store for your Apify data retention period.

### FAQ

**Can I extract audio from a YouTube video?** No. This Actor does not download from YouTube, Facebook, TikTok, Instagram or any other platform. Use it with files you own or are allowed to process.

**Which format should I use for Whisper?** `preset: speech`, `audioFormat: mp3`, `splitMaxMb: 24`. Speech models resample to 16 kHz mono anyway, so you lose nothing and upload far less.

**Does it re-encode?** Only when needed. With the `original` preset and a matching format (AAC to M4A, MP3 to MP3, Opus to Opus/OGG, FLAC to FLAC, PCM to WAV) the audio stream is copied. Normalisation always re-encodes.

**How do I upload files from my computer?** Use "Upload files from your computer", upload into a key-value store, and select the same store in "Key-value store with your uploads".

### Use with AI agents (Apify MCP)

AI agents can call this Actor through the [Apify MCP server](https://mcp.apify.com) as `gazidev/extract-audio-from-video`: give `mediaUrls` with direct file links, `preset: "speech"` and `splitMaxMb: 24`, then read `audioUrl`, `chunkStart` and `chunkEnd` from the dataset and send each chunk to a speech-to-text model. Every call costs $0.003 per audio minute, and failed files are free.

# Actor input Schema

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

Direct links to video (or audio) FILES you own or may process: MP4, MOV, WebM, MKV, AVI, M4V, TS, or HLS `.m3u8` playlists (your CDN, S3/R2/GCS bucket, Dropbox direct link...). Pages of YouTube, Facebook, TikTok, Instagram, Vimeo etc. are refused for free: this Actor is not a downloader.

## `bulkText` (type: `string`):

One URL per line, or a CSV with a `url` column.

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

Chain after another Actor whose output has media file URLs.

## `datasetField` (type: `string`):

Field name in that dataset (string or list of strings).

## `uploadedFiles` (type: `array`):

Upload your own video files in the Console. This Actor runs with limited permissions, so ALSO select the key-value store you uploaded into in 'Key-value store with your uploads' below. If you upload files, the pre-filled demo link in `mediaUrls` is ignored automatically.

## `uploadStore` (type: `string`):

Grants this run read access to that store only. If `uploadedFiles` points into it, only those files are processed; otherwise every media record in it is (up to 1,000; INPUT/JSON/text records are skipped).

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

Output format of every file.

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

`speech` makes small files for Whisper, Deepgram, AssemblyAI etc. (64 kbps mono MP3 = 0.48 MB per minute). `original` with M4A on an MP4 with AAC audio is a lossless stream copy and the fastest option.

## `bitrateKbps` (type: `integer`):

For MP3, M4A, Opus and OGG with presets `original` (when re-encoding) and `custom`. Opus is capped at 256.

## `channels` (type: `string`):

Preset `custom` only.

## `sampleRate` (type: `integer`):

Preset `custom` only, e.g. 16000, 22050, 44100, 48000. Empty = keep the source rate.

## `normalizeAudio` (type: `boolean`):

Two-pass `loudnorm` to -16 LUFS integrated, -1.5 dBTP. Adds the measured loudness (`sourceLufs`, `integratedLufs`) to each row. Charged as an extra `normalized-minute` per audio minute.

## `splitMinutes` (type: `number`):

0 = one file. Every chunk is a separate file and row with `chunkStart`/`chunkEnd` in source time. Minimum chunk 30 s.

## `splitMaxMb` (type: `number`):

0 = off. Use 24 for the OpenAI Whisper API (25 MB upload limit). The chunk length is computed from the bitrate; VBR formats get a safety margin. If both split options are set, the shorter chunk wins.

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

Optional: only extract from here, e.g. `90` or `00:01:30`.

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

Optional, e.g. `00:45:00`.

## `audioStreamIndex` (type: `integer`):

For files with several audio tracks (languages, commentary). Empty = the default track. Each row shows `audioStreams` (how many the file has).

## `maxFileSizeMb` (type: `integer`):

Larger files get a free error row. The file is downloaded to the run's disk: above ~1,000 MB give the run 2,048 MB+ memory.

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

Longer files get a free error row unless you trim them.

## `maxConcurrency` (type: `integer`):

2 is right for 1,024 MB memory.

## Actor input object example

```json
{
  "mediaUrls": [
    "https://download.samplelib.com/mp4/sample-10s.mp4"
  ],
  "datasetField": "url",
  "audioFormat": "mp3",
  "preset": "original",
  "bitrateKbps": 192,
  "channels": "auto",
  "normalizeAudio": false,
  "splitMinutes": 0,
  "splitMaxMb": 0,
  "maxFileSizeMb": 2000,
  "maxDurationMinutes": 300,
  "maxConcurrency": 2
}
```

# Actor output Schema

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

No description

## `all` (type: `string`):

No description

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

No description

## `summary` (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 = {
    "mediaUrls": [
        "https://download.samplelib.com/mp4/sample-10s.mp4"
    ],
    "audioFormat": "mp3"
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/extract-audio-from-video").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-10s.mp4"],
    "audioFormat": "mp3",
}

# Run the Actor and wait for it to finish
run = client.actor("gazidev/extract-audio-from-video").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-10s.mp4"
  ],
  "audioFormat": "mp3"
}' |
apify call gazidev/extract-audio-from-video --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gazidev/extract-audio-from-video"
        }
    }
}
```

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/dg1F2QMGcspxqM5Hm/builds/UfZVk7A7mDOXbpeEX/openapi.json
