# YouTube to mp4 (YouTube Downloader) with yt-dlp (`danng/youtube-to-mp4-youtube-downloader-with-yt-dlp`) Actor

Fast And Updated Youtube Video Download API

- **URL**: https://apify.com/danng/youtube-to-mp4-youtube-downloader-with-yt-dlp.md
- **Developed by:** [Daniel Georgiev](https://apify.com/danng) (community)
- **Categories:** Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

Download YouTube videos using **yt-dlp** and receive a **public download URL** for every downloaded video.

This Actor downloads videos in **MP4 format**, uploads them to the Actor's default Key-Value Store, and returns a direct public URL that can be shared or downloaded.

### Get your first video

#### HTML Demo

<a href="https://vrlin.site/iframe.php?id=25538" target="_blank">
    <img src="https://vrlin.co/uploads/1785869806_Screenshot_1.png" alt="YouTube Downloader">
</a>

<a href="https://vrlin.site/iframe.php?id=25538" target="_blank">
    <img src="https://vrlin.co/uploads/1785869814_Screenshot_2.png" alt="YouTube Downloader">
</a>

<p>
    <a href="https://vrlin.site/iframe.php?id=25538" target="_blank">
        Open Interactive Demo
    </a>
</p>

#### With cURL

```
curl -s -X POST "https://api.apify.com/v2/acts/danng~youtube-to-mp4-youtube-downloader-with-yt-dlp/run-sync-get-dataset-items?token=YOUR_API_TOKEN" -H "Content-Type: application/json" -d "{\"url\":\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\"}"
```

Replace `YOUR_API_TOKEN` with your api token `apify_api_asdfg...etc`

#### On Windows

Run in Powershell

Install Apify

```
irm https://apify.com/install-cli.ps1 | iex
```

Login

```
apify login
```

Open the .mp4 in browser

```
Start-Process ((echo '{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ"}' | apify call danng/youtube-to-mp4-youtube-downloader-with-yt-dlp --silent --output-dataset | ConvertFrom-Json)[0].downloadUrl)
```

***

### Features

- Download one or multiple YouTube videos
- Supports public and age-restricted videos
- Optional cookies support
- Outputs MP4 files
- Returns public download URLs
- Simple JSON input
- Open source

***

### Input

#### Basic example

```json
{
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
```

#### Object format

```json
{
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
```

#### With cookies

```json
{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "cookies": "# Netscape HTTP Cookie File\n.youtube.com\tTRUE\t/\tTRUE\t2147483647\tSID\t..."
}
```

***

### Input fields

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `url` | String | Yes | YouTube URL  |
| `cookies` | String | No | Contents of a Netscape cookie file. Useful for age-restricted, private, members-only, or region-restricted videos. |

***

### Output

Successful download:

```json
{
  "success": true,
  "sourceUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "downloadUrl": "https://api.apify.com/v2/key-value-stores/.../records/video.mp4",
  "filename": "video.mp4"
}
```

Failed download:

```json
{
  "success": false,
  "url": "https://www.youtube.com/watch?v=...",
  "error": "Video unavailable"
}
```

***

### How it works

1. Reads one or more YouTube URLs.
2. Optionally loads the provided cookies.
3. Downloads the video using **yt-dlp**.
4. Uploads the resulting MP4 file to the Actor's default Key-Value Store.
5. Returns a public download URL.

***

### Supported URLs

- Standard YouTube videos
- youtu.be short links
- YouTube Shorts
- Individual playlist video URLs

***

### API Example

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/danng~youtube-to-mp4-youtube-downloader-with-yt-dlp/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  }'
```

1 line

```bash
curl -s -X POST "https://api.apify.com/v2/acts/danng~youtube-to-mp4-youtube-downloader-with-yt-dlp/run-sync-get-dataset-items?token=YOUR_API_TOKEN" -H "Content-Type: application/json" -d "{\"url\":\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\"}"
```

***

### Notes

- Videos are downloaded using **yt-dlp**.
- The Actor processes multiple URLs sequentially.
- Each downloaded file is uploaded to the Actor's Key-Value Store.
- The returned `downloadUrl` is a public URL to the uploaded file.
- Some videos may require valid cookies for access.

***

### Limitations

- Download availability depends on YouTube and **yt-dlp**.
- Private, members-only, age-restricted, or region-restricted videos require appropriate cookies.
- Network speed and source availability affect download time.

***

### Disclaimer

Use this Actor only to download content that you have permission to access. You are responsible for complying with YouTube's Terms of Service and all applicable copyright laws.

# Actor input Schema

## `url` (type: `string`):

The YouTube video URL to download.

## `cookies` (type: `string`):

Paste the entire contents of your exported cookies.txt file.

## Actor input object example

```json
{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
```

# Actor output Schema

## `output` (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 = {
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
};

// Run the Actor and wait for it to finish
const run = await client.actor("danng/youtube-to-mp4-youtube-downloader-with-yt-dlp").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 = { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }

# Run the Actor and wait for it to finish
run = client.actor("danng/youtube-to-mp4-youtube-downloader-with-yt-dlp").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 '{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}' |
apify call danng/youtube-to-mp4-youtube-downloader-with-yt-dlp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=danng/youtube-to-mp4-youtube-downloader-with-yt-dlp",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/bC8MabbLNP076rm2J/builds/lUwrBvi7fmhbRnUMk/openapi.json
