# YouTube Audio Extractor \[Only $6/1K💰] | MP3/M4A/FLAC (`ahmed_jasarevic/yt-audio-extractor`) Actor

Extract audio from YouTube and YouTube Music — MP3, M4A, WebM, FLAC, WAV, Ogg Vorbis and ALAC — with a public download link per track, optional captions/transcripts and section trimming, via native stream copy (no re-encode) for speed. $0.006 per track, first 50 MB included.

- **URL**: https://apify.com/ahmed_jasarevic/yt-audio-extractor.md
- **Developed by:** [Ahmed Jasarevic](https://apify.com/ahmed_jasarevic) (community)
- **Stats:** 7 total users, 7 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.50 / 1,000 audio tracks

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

## YouTube Audio Extractor

**Extract audio and timed transcripts from YouTube and YouTube Music — MP3, M4A, WebM, FLAC, WAV, Ogg Vorbis or ALAC — as public, no-login download links, at a flat $0.006 per track with the first 50 MB of every track included.** M4A and WebM are copied straight from YouTube's native audio stream (no re-encode, ~5–10x faster than converter actors), every track comes with a permanent public URL, and captions are fetched in the same run.

Built for podcasters, researchers building audio datasets, archivists, music lovers and AI projects that need clean audio files.

### Main Use Cases

- **YouTube to MP3** — 192 kbps default (96–320 selectable) for playback anywhere
- **YouTube Music audio download** — public music tracks in M4A/WebM kept losslessly native, or MP3/FLAC/WAV
- **Audio datasets for AI** — batch-download thousands of tracks with metadata (views, likes, captions, duration, published date) alongside the files
- **Podcast and interview extraction** — pull episode audio from YouTube or YouTube Music with optional section trimming
- **YouTube captions and transcripts** — same run, one language, billed only when that language actually exists
- **Archival in lossless formats** — FLAC, WAV or ALAC for permanent collections, metadata included

### How It Works — Native Stream Copy, Not Re-Encoding

YouTube and YouTube Music serve audio as progressive download streams; the actor fetches that stream over plain HTTP — **no browser, no JavaScript, no login** — and saves it as M4A or WebM without touching a single sample (that is why M4A/WebM is the "fastest" format option). Only when you ask for MP3, FLAC, WAV, Ogg Vorbis or ALAC does the actor re-encode the saved source with FFmpeg (MP3 at 192 kbps by default). Failures are per-track and independent: one bad link never stops the rest of the run, and a failed download is **never charged for the track itself** — only the metered proxy bandwidth it actually consumed, if any, is billed.

### Download YouTube Audio Without a YouTube Audio API

YouTube has no official audio-download API, so converter actors typically run a headless browser and pay per video minute — which is why the segment-downloader competitor bills $0.05/video plus $0.04/min. This actor talks directly to the stream URLs YouTube's own pages use, so a typical 3–5 minute track costs a flat **$0.006 including the file** (50 MB included; extra megabytes $0.001/MB) and finishes in seconds, not minutes. Transcripts ride along at $0.0012 each instead of a separate paid actor, and every output file is a **public link you can hand to anyone — no Apify login or token required**.

### Input

| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
| `urls` | array | Yes | — | YouTube Music tracks, YouTube videos, Shorts, live, embed or `youtu.be` links, or bare 11-character video IDs; each processed independently |
| `format` | enum | No | `m4a` | `m4a`/`webm` = native stream copy (fastest); `mp3` = 192 kbps re-encode; `flac`/`wav`/`vorbis`/`alac` = lossless or open re-encode |
| `country` | string | No | `US` | Two-letter ISO code — fetch public audio offered in that market (region restrictions) |
| `captionLanguage` | string | No | `""` | Captions/timed transcript language, e.g. `en` or `en-US`; empty = skip |
| `proxyConfiguration` | object | No | off | Leave off: direct download works and is cheapest; the actor falls back to metered residential proxy on block |
| `maxConcurrency` | integer | No | `4` | Tracks processed in parallel (1–20; >10 rarely helps) |
| `maxDurationSeconds` | integer | No | `14400` | Safety cap (4 h) — longer tracks rejected before any download |
| `retries` | integer | No | `3` | Failed-track retries, each with rotated proxy + longer backoff (0–8) |
| `mp3Bitrate` | integer | No | `192` | MP3-only target (96–320); other formats ignore it |
| `startTimeSeconds` | integer | No | `0` | Skip this many seconds and save only what follows (0 = whole track) |
| `endTimeSeconds` | integer | No | `0` | Stop saving here (`90` = first 90 seconds); 0 = to the end |

### Output — Audio Tracks With Complete Metadata

One dataset row per input URL (the `overview` view shows the essentials; the KVS `audio` collection holds the binary files, key prefix `audio-`):

| Field | Description |
|---|---|
| `videoId`, `title`, `artistName` | Track identity (artist = channel for videos, artist for music) |
| `submittedUrl`, `sourceUrl` | As-submitted vs resolved canonical URL |
| `audioFormat`, `audioCodec`, `bitrateKbps`, `sampleRateHz` | What you actually got (native stream or re-encode) |
| `durationSeconds`, `audioDurationSeconds` | Source duration vs length of the saved audio (differs when trimmed) |
| `fileSizeBytes`, `sizeMb`, `billedMb`, `sourceFileSizeBytes` | Size; `billedMb` = MB charged above the 50 included |
| `proxyMb` | Metered proxy bandwidth (0 for direct/self-proxy runs) |
| `fileName`, `downloadUrl` | **Public, no-login link to the audio file** |
| `thumbnailUrl`, `publishedDate`, `viewCount`, `likeCount`, `commentCount`, `isLive` | Content metadata |
| `transcoded`, `requestedBitrateKbps`, `section` | Encoding provenance: was it re-encoded, target kbps, requested start/end |
| `accessCountry`, `captions` | Market used; captions object (null when none requested/exist) |
| `error`, `errorMessage` | Per-track failure codes (track itself never charged; `proxyMb` shows any metered bandwidth billed) |

### Example Input

```json
{
  "urls": [
    "https://music.youtube.com/watch?v=jNQXAC9IVRw",
    "https://www.youtube.com/watch?v=aqz-KE-bpKQ",
    "youtu.be/9bZkp7q19f0"
  ],
  "format": "mp3",
  "captionLanguage": "en",
  "maxConcurrency": 4
}
```

Trim a section and keep it lossless: `"format": "flac", "startTimeSeconds": 90, "endTimeSeconds": 300`.

### Example Output — Track Record (trimmed)

```json
{
  "videoId": "aqz-KE-bpKQ",
  "title": "Big Buck Bunny 60fps 4K - Official Blender Foundation Short Film",
  "artistName": "Blender",
  "audioFormat": "mp3",
  "audioCodec": "mp3",
  "bitrateKbps": 192,
  "sampleRateHz": 44100,
  "durationSeconds": 635,
  "audioDurationSeconds": 635,
  "fileSizeBytes": 15420416,
  "sizeMb": 15,
  "billedMb": 0,
  "proxyMb": 0,
  "transcoded": true,
  "requestedBitrateKbps": 192,
  "section": null,
  "fileName": "audio-7f8d1a2b-3c4d-5e6f-9a8b-0c1d2e3f4a5b.mp3",
  "downloadUrl": "https://api.apify.com/v2/key-value-stores/.../records/audio-7f8d1a2b....mp3?disableRedirect=1",
  "thumbnailUrl": "https://i.ytimg.com/vi/aqz-KE-bpKQ/...",
  "publishedDate": "2015-01-14",
  "viewCount": 11762113,
  "likeCount": 158274,
  "commentCount": 10212,
  "isLive": false,
  "accessCountry": "US",
  "captions": { "language": "en", "transcript": "a line of timed caption text" },
  "error": null,
  "errorMessage": null
}
```

### YouTube Audio at $0.006 Per Track

Billing is strictly per completed track (from `.actor/pay-per-event.json`, all real):

| Event | Price | Billed when |
|---|---|---|
| **Audio track** | **$0.006** | Track saved as a downloadable file — **first 50 MB included**; a failed track is never charged for the track itself |
| Extra saved MB | $0.001 | Per MB above the 50 MB included (rounded up) |
| Transcript/subtitle | $0.0012 | Only when the track actually has captions in the requested language |
| Metered proxy MB | $0.02 | Only on a block, when the actor falls back to residential proxy, and includes bandwidth spent on a retry that still failed (never for direct runs) |

A 4-minute 128 kbps M4A ≈ 4 MB ≈ **$0.006 flat**. A 100 MB FLAC ≈ $0.006 + $0.05 = $0.056. A link that fails costs no track fee; the metered proxy bandwidth it spent, if any, still shows up as `proxyMb`. The flat per-track price makes volume predictable: 1,000 regular tracks = **$6.00**.

### Integrations & Automation

- **API** — run and fetch via the Apify REST API, or call it from AI agents through the Apify MCP server
- **Storage** — audio files land in the actor's key-value store (`audio` collection, public links); dataset rows carry metadata + `downloadUrl`
- **Scheduling** — periodic sweeps for channels you track (new uploads → audio + transcript)
- **Webhooks** — notify your pipeline each time a track finishes; export dataset as JSON/CSV/Excel

**Recommended schedule:** on-demand for one-offs; daily/weekly sweeps for archival or dataset builds. The `maxDurationSeconds` safety cap guarantees a mistaken link can never produce a huge bill.

### Related Actors

- [YouTube Audio Segment Downloader](https://apify.com/entertained_rattlesnake/youtube-audio-segment-downloader) — `entertained_rattlesnake/youtube-audio-segment-downloader` — most-used audio actor (114 users, 39 monthly); $0.05/video + $0.04/min
- [YouTube Link](https://apify.com/utils/youtube-link) — `utils/youtube-link` — link extractor with audio option, $0.013/track (104 users, 5.0★)
- [YouTube Video Audio Downloader](https://apify.com/apple_yang/youtube-video-audio-downloader) — `apple_yang/youtube-video-audio-downloader` — $0.0025/result (69 users, 5.0★)
- [YouTube Video Audio Downloader Reliable](https://apify.com/vidkraken/youtube-video-audio-downloader-reliable) — `vidkraken/youtube-video-audio-downloader-reliable` — **per-MB billing** ($0.002/MB; a 50 MB track ≈ $0.10)
- [YouTube Audio Downloader Lite](https://apify.com/alpha-scraper/youtube-audio-downloader-lite) — `alpha-scraper/youtube-audio-downloader-lite` — $0.0025/result

This actor is the only one with **7 formats, bundled transcripts, section trimming, and flat per-track pricing** — the per-MB competitor charges ~$0.10 for a 50 MB track where this costs $0.006 flat.

### FAQ

#### Why use this actor instead of an official YouTube audio API?

There is no official audio-download API. YouTube serves progressive audio streams that any client with the right request shape can consume; this actor reads them directly over HTTP — no browser, no API key, no token.

#### What are alternatives to this actor for YouTube audio?

On the Store: [entertained_rattlesnake/youtube-audio-segment-downloader](https://apify.com/entertained_rattlesnake/youtube-audio-segment-downloader) ($0.05/video + $0.04/min), [utils/youtube-link](https://apify.com/utils/youtube-link) ($0.013/track, link extractor), [vidkraken/youtube-video-audio-downloader-reliable](https://apify.com/vidkraken/youtube-video-audio-downloader-reliable) (per-MB). Ours is the only flat per-track actor with transcripts + trimming + 7 formats.

#### MP3 320 kbps vs 192 — which should I pick?

192 kbps (default) is the widely accepted quality/size balance for MP3. Pick 320 kbps for archival on the MP3 codec, or — better — keep the native stream (`m4a`) or FLAC/WAV/ALAC for true lossless. `mp3Bitrate` only applies when `format: "mp3"`.

#### M4A vs MP3 — why is M4A the fastest?

M4A and WebM are YouTube's native audio formats, so the actor downloads the stream and saves it **as-is** — no re-encoding, no FFmpeg pass. MP3/FLAC/WAV/Vorbis/ALAC require a conversion pass over the saved file. For identical quality, M4A usually beats MP3 at the same bitrate anyway.

#### Why am I being charged proxy MB?

Only when a direct download was blocked and the actor had to retry through Apify residential proxy. Direct runs (the default) never see proxy charges. If you're being blocked often, set `country` to the market where the track is public, or force a proxy — never to avoid the fee, but to get through.

#### How do I get captions/transcripts?

Set `captionLanguage` (e.g. `en`, `en-US`). The dataset row's `captions` object carries the transcript; it is null when no captions exist in that language — and you are **only charged the $0.0012 transcript fee when captions are actually returned**.

#### What about region-blocked or very long tracks?

`country` fetches the public audio offered in that market. `maxDurationSeconds` (default 14 400 = 4 h) rejects anything longer *before* downloading a byte — a mistaken link can never run up a bill. `startTimeSeconds`/`endTimeSeconds` let you save just a section (great for podcasts).

#### Where are the files?

In the run's key-value store, `audio` collection (keys `audio-…`). Each dataset row's `downloadUrl` is a **public link — anyone can download without an Apify account**. The dataset rows themselves are the index, with full metadata.

### For AI Agents & LLM Apps

- **Purpose**: given YouTube/YouTube Music URLs, returns one dataset row per track — format/codec/bitrate/sample rate/size, duration, metadata (views, likes, captions), the public `downloadUrl` — and stores the audio file itself in the `audio` KVS collection.
- **Minimal working input**:

```json
{ "urls": ["https://music.youtube.com/watch?v=jNQXAC9IVRw"] }
```

- **Variant inputs** — MP3 + captions: `{ "urls": ["..."], "format": "mp3", "captionLanguage": "en" }`; trimmed lossless: `{ "urls": ["..."], "format": "flac", "startTimeSeconds": 90, "endTimeSeconds": 300 }`; batch: any number of URLs, `"maxConcurrency": 8`.
- **Output fields**: `videoId, title, artistName, submittedUrl, sourceUrl, durationSeconds, audioFormat, audioCodec, bitrateKbps, sampleRateHz, fileSizeBytes, sizeMb, audioDurationSeconds, requestedBitrateKbps, section, billedMb, sourceFileSizeBytes, proxyMb, fileName, downloadUrl, thumbnailUrl, publishedDate, viewCount, likeCount, commentCount, isLive, transcoded, accessCountry, captions, error, errorMessage`.
- **Behaviors an agent should know**: `urls` is required and accepts full URLs or bare 11-char IDs; each URL is independent — failures land in `error`/`errorMessage` and are never charged for the track itself (any metered proxy bandwidth is billed as `proxyMb`), so keep failed rows out of downstream billing. Audio files live in the run's KVS `audio` collection (key prefix `audio-`); `downloadUrl` needs no auth but is **ephemeral like any Apify key-value record** — persist the bytes (or re-run) for long-term use. M4A/WebM = native stream, `transcoded: false`; MP3/FLAC/WAV/Vorbis/ALAC = re-encoded (`transcoded: true`), `requestedBitrateKbps` applies to MP3 only. The safety cap `maxDurationSeconds` (default 14 400) rejects longer tracks before download — raise it consciously for long podcasts. `billedMb` = MB over the 50 included; `proxyMb` nonzero only when metered Apify residential was used. Never request a caption language you don't need: the $0.0012 transcript fee applies per returned transcript.
- **Billing**: pay-per-event — $0.006 per saved track (first 50 MB included; a failed track is not charged for the track itself) + $0.001 per extra MB + $0.0012 per transcript + $0.02 per metered proxy MB (only when proxy is used, failures included) + standard $0.00005 actor start.

### Legal & Compliance Disclaimer

This actor is an independent tool and is **not affiliated with, endorsed by, or sponsored by Google LLC, YouTube, or YouTube Music**. It accesses only publicly available audio streams served to anonymous visitors of public watch pages — no login, no bypass of paywalls or DRM, and no extraction of private content. Downloading audio may violate YouTube's Terms of Service; the actor is intended for legitimate uses such as archiving content you have rights to, research, and personal use. Users are responsible for their own compliance with [YouTube's Terms of Service](https://www.youtube.com/t/terms), applicable copyright law, and data-protection rules — do not redistribute copyrighted audio without permission.

### SEO Keywords

youtube audio extractor, youtube to mp3, youtube music audio download, youtube audio api alternative, download youtube audio m4a, youtube audio flac, youtube audio wav, youtube video to audio, youtubetranscript api, youtube caption download, youtube audio metadata, audio dataset for ai, youtube shorts audio, podcast audio extraction, youtube audio trimming, youtube lyrics captions, region locked youtube audio, youtube audio archival, public audio download link, youtube mp3 192 kbps

# Actor input Schema

## `urls` (type: `array`):

Public YouTube Music tracks, YouTube videos, Shorts, live, embed or youtu.be links, or bare 11-character video IDs. Every URL is processed independently, so one bad link never stops the rest of the run.

## `format` (type: `string`):

MP3 works almost everywhere and is re-encoded at 192 kbps. M4A and WebM keep the native YouTube stream whenever possible, which is much faster because no re-encoding happens. FLAC, WAV and ALAC are lossless and therefore much larger.

## `country` (type: `string`):

Two-letter ISO country code used to fetch public audio offered in that country. Use it when a track is only available in certain markets.

## `captionLanguage` (type: `string`):

Language code of the captions or timed transcript you want, for example en or en-US. Leave empty to skip captions. A missing track never stops the audio download.

## `proxyConfiguration` (type: `object`):

Optional. Leave it empty for the cheapest downloads: YouTube usually serves audio straight to the Actor. If a track comes back blocked, the Actor retries through Apify residential proxy on its own, billing residential bandwidth as Proxy MB, including bandwidth spent on a retry that still fails. Enable a proxy here to force it for every track, or paste your own proxies into proxyUrls.

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

How many tracks to process at the same time. Higher is faster but needs more proxies and memory. Values above 10 rarely help.

## `maxDurationSeconds` (type: `integer`):

Safety limit in seconds. Anything longer is rejected before a single byte is downloaded, so a mistaken link can never produce a huge bill. 14400 equals 4 hours.

## `retries` (type: `integer`):

How many times a failed track is retried, each time with a rotated proxy and a longer backoff. Retries on the metered residential proxy are capped at 1 to keep proxy costs bounded.

## `mp3Bitrate` (type: `integer`):

Target bitrate when you pick the mp3 format. 128 kbps is small, 192 kbps is the default balance and 320 kbps is the highest quality MP3. Other formats ignore this value.

## `startTimeSeconds` (type: `integer`):

Optional. Skip this many seconds at the beginning of the track and save only what follows. 0 keeps the whole track.

## `endTimeSeconds` (type: `integer`):

Optional. Stop saving at this point, for example 90 to get the first 90 seconds. 0 means keep playing to the end of the track.

## Actor input object example

```json
{
  "urls": [
    "https://music.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "format": "m4a",
  "country": "US",
  "captionLanguage": "",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "maxConcurrency": 4,
  "maxDurationSeconds": 14400,
  "retries": 3,
  "mp3Bitrate": 192,
  "startTimeSeconds": 0,
  "endTimeSeconds": 0
}
```

# Actor output Schema

## `tracks` (type: `string`):

Dataset with one record per input URL, including audio metadata, a public file link and optional transcripts.

## `audioFiles` (type: `string`):

Key-value store holding the saved audio files.

# 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 = {
    "urls": [
        "https://music.youtube.com/watch?v=jNQXAC9IVRw"
    ],
    "format": "m4a",
    "country": "US",
    "captionLanguage": "",
    "proxyConfiguration": {
        "useApifyProxy": false
    },
    "maxConcurrency": 4,
    "maxDurationSeconds": 14400,
    "retries": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("ahmed_jasarevic/yt-audio-extractor").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 = {
    "urls": ["https://music.youtube.com/watch?v=jNQXAC9IVRw"],
    "format": "m4a",
    "country": "US",
    "captionLanguage": "",
    "proxyConfiguration": { "useApifyProxy": False },
    "maxConcurrency": 4,
    "maxDurationSeconds": 14400,
    "retries": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("ahmed_jasarevic/yt-audio-extractor").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 '{
  "urls": [
    "https://music.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "format": "m4a",
  "country": "US",
  "captionLanguage": "",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "maxConcurrency": 4,
  "maxDurationSeconds": 14400,
  "retries": 3
}' |
apify call ahmed_jasarevic/yt-audio-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ahmed_jasarevic/yt-audio-extractor"
        }
    }
}
```

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/RNiOfPiTUDr8ZRrY7/builds/E5UxcZiMeTvvCyg0O/openapi.json
