# YouTube Video Downloader — MP4 & MP3 (`s-r/youtube-video-downloader`) Actor

- **URL**: https://apify.com/s-r/youtube-video-downloader.md
- **Developed by:** [SR](https://apify.com/s-r) (community)
- **Categories:** Social media, Developer tools
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## YouTube Video Downloader: YouTube to MP4 and MP3

Hosted **youtube video downloader** that turns any public YouTube link into a downloadable file. Give it a list of video URLs, pick **youtube to mp4** (up to 1080p) or MP3 audio, and the Actor downloads each one with yt-dlp routed through a rotating proxy. Every file lands in the run's key-value store, and each output row carries a direct download URL plus full metadata. Run it from the Apify Store with one click, or call it from your own service via the Apify API. Pay per downloaded megabyte, not per month.

If you have been looking for a **youtube to mp4 converter** that works at scale, a way to grab **youtube mp3** audio without ad-riddled websites, or a programmatic downloader you can wire into a pipeline, this Actor is the hosted alternative.

### What you get

- **MP4 video up to 1080p, or MP3 audio**, choose the format per run. MP4 quality is selectable at 360, 480, 720, 1080, or best available.
- **A direct download URL per file**, every output row includes `download_url`, a direct link to the file stored in the run's key-value store. Click it, curl it, or hand it to a downstream job.
- **Full metadata on every row**, title, channel, channel ID, duration, resolution, fps, file size in both MB and bytes, view count, and upload date.
- **Bulk input**, pass an array of URLs and the Actor works through all of them in one run.
- **Flexible URL parsing**, standard `watch?v=` links, `youtu.be/` short links, `/shorts/` URLs, and bare 11-character video IDs all resolve.
- **Pay only for what you download**, billing scales per megabyte, so short clips cost pennies.

### Why use a YouTube downloader actor

Browser-based **youtube converter** sites are unreliable. They wrap downloads in pop-ups, cap quality, throttle you after a few files, and break the moment YouTube ships a change. For anything past a one-off download they do not hold up.

Running a downloader actor on Apify fixes that. You get bulk and programmatic downloads: hand it fifty URLs and get fifty files back in one run, or trigger it from your own code via the API whenever a new video appears. No local software to install, no yt-dlp to keep patched, no proxy to source yourself. The heavy lifting runs on Apify's cloud infrastructure and the finished files sit in the run's key-value store, ready to pull down or pipe onward.

You also get real format choice. Need archival-quality 1080p MP4 for a media library? Set the quality and format. Only want the audio for a podcast feed or a transcription job? Switch to MP3 and skip the video bytes entirely. Because the Actor bills per downloaded megabyte, picking a lower resolution or audio-only directly lowers your cost, so the format decision is also a budget decision.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `urls` | array | **required** | YouTube video URLs to download. Accepts `watch?v=…`, `youtu.be/…`, `/shorts/…`, or bare 11-character video IDs. |
| `format` | string | `mp4` | Output format. `mp4` for video, `mp3` for extracted audio. |
| `quality` | string | `720` | Video quality for MP4: `360`, `480`, `720`, `1080`, or `best`. Ignored when `format` is `mp3`. |

### Output

Every run pushes one record per download to the Apify dataset. Each record points at the actual file in the run's key-value store:

```json
{
  "video_id": "dQw4w9WgXcQ",
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "title": "Rick Astley - Never Gonna Give You Up",
  "channel": "Rick Astley",
  "channel_id": "UCuAXFkgsw1L7xaCfnd5JJOw",
  "duration_seconds": 213,
  "format": "mp4",
  "ext": "mp4",
  "resolution": "1280x720",
  "fps": 25,
  "filesize_mb": 48.7,
  "filesize_bytes": 51065242,
  "download_url": "https://api.apify.com/v2/key-value-stores/AbC123/records/dQw4w9WgXcQ_720p.mp4",
  "storage_key": "dQw4w9WgXcQ_720p.mp4",
  "view_count": 1600000000,
  "upload_date": "20091025"
}
````

The `download_url` is a direct link to the file in this run's key-value store, and `filesize_mb` tells you exactly what the download cost. You can:

- **Download** each file straight from its `download_url`
- **Export** the dataset as JSON, CSV, or Excel to get a manifest of every download
- **Stream** results via the Apify API and fetch files programmatically in your own app
- **Pipe** the download URLs to webhooks, S3, or any of Apify's integrations

### Use cases

#### Archiving and media libraries

Keep a permanent copy of videos that matter to you: your own channel's back catalogue, conference talks, tutorials, or anything at risk of being taken down. Feed the Actor a list of URLs, choose 1080p MP4, and collect a clean archive with title, channel, and upload date attached to every file.

#### Dataset building for machine learning

Video and audio corpora start with bulk downloads. Pull hundreds of clips as MP4 for computer-vision training, or extract MP3 audio for speech-to-text and audio-classification datasets. Because each row records duration, resolution, and file size, you can filter and balance your dataset before a single byte hits your training pipeline.

#### Content repurposing

Grab a long-form video once, then cut it into shorts, quote cards, or audiograms. Download the source in the quality you need, and use the metadata to keep attribution straight. For audio-first repurposing (podcast clips, quote reels), MP3 mode gives you just the track without hauling the video.

#### Offline analysis

Researchers, journalists, and analysts often need the raw file, not a streaming URL that can vanish. Download the videos or audio you are studying so your analysis does not depend on the clip staying live, and so you can run local tools over the actual media.

### How it compares

| | This Actor | streamers/youtube-video-downloader |
|---|---|---|
| Per-MB rate | **$0.0048 / MB** | $0.006 / MB (free tier) |
| Formats | MP4 (360–1080p) + MP3 | MP4 + MP3 |
| Direct download URL | Yes, from run key-value store | Yes |
| Full metadata row | Yes | Yes |
| Transcript add-on | Not in v1 (use a dedicated transcript actor) | Included |

We undercut the streamers downloader by 20% on the per-megabyte rate, which is the number that actually drives your bill. The transcript add-on is intentionally left out of v1 because a separate transcript actor covers that job better.

### Pricing

This Actor uses Apify's pay-per-event pricing, billed per downloaded megabyte at **$0.0048 per MB**, plus a **$0.002 per-run actor-start fee**. Your bill scales linearly with the bytes you actually pull, which is exactly the model buyers expect from a downloader.

A typical 50MB video costs about **$0.24** (50 × $0.0048, plus the small start fee). Audio-only MP3 downloads are far smaller, so they cost a fraction of that. There is no monthly subscription and no minimum.

### Limits and gotchas

- **Billed per megabyte, so quality is a budget lever.** A 360p MP4 or an MP3 costs a fraction of a 1080p download. Pick the lowest quality that meets your need and your bill drops with it.
- **Files live in the run's key-value store.** The download is stored under the run, so retrieve it while the run's data is retained. Copy files you need to keep to your own storage.
- **The download URL points at the run store.** `download_url` is a direct link into this run's key-value store, not a permanent CDN URL. Treat it as run-scoped.
- **MP3 extraction uses ffmpeg.** ffmpeg ships inside the Actor image, so audio extraction works out of the box with no setup on your side.
- **Large or long videos take longer.** A multi-gigabyte 1080p download is more bytes to move than a three-minute clip, so runtime and cost both rise with file size.
- **Free-tier users are capped at 10 downloads per run.** Paid Apify users have no per-run cap.
- **Private, age-restricted, or region-blocked videos may fail.** The Actor downloads public content; videos behind login or hard geo-blocks can return an error row.

### FAQ

#### How do I download a YouTube video to MP4?

Paste one or more video URLs into the `urls` field, set `format` to `mp4`, pick a `quality` (720 is a solid default, 1080 for full HD), and run the Actor. Each finished file appears in the run's key-value store, and its output row gives you a direct `download_url` to fetch it.

#### Can I extract MP3 audio from a YouTube video?

Yes. Set `format` to `mp3` and the Actor pulls the audio track and converts it with ffmpeg, which is built into the image. The `quality` field is ignored for MP3. Audio files are much smaller than video, so they are the cheapest option per download.

#### Where is the downloaded file stored?

In the key-value store attached to the run. Every output row includes a `storage_key` (the file's name in that store) and a `download_url` (a direct link to it). Pull the files you want to keep into your own storage, since the run store is scoped to the run's data retention.

#### How much does it cost to download a video?

Billing is $0.0048 per downloaded megabyte plus a $0.002 per-run start fee. A 50MB video runs about $0.24. Lower quality settings and MP3 audio download fewer megabytes, so they cost less.

#### Can I download many videos at once?

Yes. The `urls` field takes an array, so a single run can process a whole batch. Free-tier Apify accounts are limited to 10 downloads per run; paid accounts have no per-run cap. You can also schedule the Actor to run automatically.

### Related Actors

- [Youtube Scraper](https://apify.com/s-r/youtube-scraper) - Scrape YouTube videos by search term, channel, or video URL.
- [Free Youtube Transcript](https://apify.com/s-r/free-youtube-transcript) - Get the full transcript of any YouTube video.
- [Youtube Comments](https://apify.com/s-r/youtube-comments) - Scrape all comments from any YouTube video.

# Actor input Schema

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

YouTube video URLs, youtu.be links, /shorts/ URLs or 11-character video IDs. One per line, up to 50 per run.

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

mp4 (video) or mp3 (audio only).

## `quality` (type: `string`):

Highest resolution to download for mp4 (ignored for mp3). Lower = smaller files = cheaper.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=aqz-KE-bpKQ"
  ],
  "format": "mp4",
  "quality": "720"
}
```

# 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://www.youtube.com/watch?v=aqz-KE-bpKQ"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("s-r/youtube-video-downloader").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://www.youtube.com/watch?v=aqz-KE-bpKQ"] }

# Run the Actor and wait for it to finish
run = client.actor("s-r/youtube-video-downloader").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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://www.youtube.com/watch?v=aqz-KE-bpKQ"
  ]
}' |
apify call s-r/youtube-video-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=s-r/youtube-video-downloader",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Video Downloader — MP4 & MP3",
        "description": "",
        "version": "0.1",
        "x-build-id": "ZdJLJZe9fQFtgQzNq"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/s-r~youtube-video-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-s-r-youtube-video-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/s-r~youtube-video-downloader/runs": {
            "post": {
                "operationId": "runs-sync-s-r-youtube-video-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/s-r~youtube-video-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-s-r-youtube-video-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "urls"
                ],
                "properties": {
                    "urls": {
                        "title": "YouTube URLs",
                        "type": "array",
                        "description": "YouTube video URLs, youtu.be links, /shorts/ URLs or 11-character video IDs. One per line, up to 50 per run.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "format": {
                        "title": "Format",
                        "enum": [
                            "mp4",
                            "mp3"
                        ],
                        "type": "string",
                        "description": "mp4 (video) or mp3 (audio only).",
                        "default": "mp4"
                    },
                    "quality": {
                        "title": "Max video quality",
                        "enum": [
                            "360",
                            "480",
                            "720",
                            "1080",
                            "best"
                        ],
                        "type": "string",
                        "description": "Highest resolution to download for mp4 (ignored for mp3). Lower = smaller files = cheaper.",
                        "default": "720"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
