# Video Downloader: Direct Media URL, MP4 & Audio Extraction (`andrew_babo/video-downloader`) Actor

Resolve a page URL to direct media links and download the video or audio as a file. Multi-threaded download, audio-only extraction and time-window clipping, returned as an Apify artifact.

- **URL**: https://apify.com/andrew\_babo/video-downloader.md
- **Developed by:** [Andrew Babo](https://apify.com/andrew_babo) (community)
- **Stats:** 481 total users, 152 monthly users, 92.5% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Downloader — Direct Media URL, MP4 Download & Audio Extraction

Give it a page URL (YouTube and any other site supported by yt-dlp) and get back
either the **direct media URLs**, a ready **MP4 file**, an **audio-only track**,
or just the **time windows** you need. Downloads run over many parallel range
requests, so a full video arrives in a fraction of the usual time.

**Use it for:** content archiving, repurposing long videos into clips, building
transcription and analysis pipelines, media research, dataset collection.

> Only download content you own or have the right to use, and follow each
> site's terms of service.

### Quick start

```json
{
  "op": "full",
  "source": "https://www.youtube.com/watch?v=XXXXXXXXXXX"
}
```

Feature-detect the build (free, a few seconds, needs no source):

```json
{ "op": "capabilities" }
```

### Operations

| `op` | What it does |
| --- | --- |
| `resolve` | report the selected video/audio formats and their direct URLs — no download |
| `full` | parallel-range download of video + audio, stream-copy mux into a faststart MP4 |
| `full_multi` | download one byte-range part, for fan-out across several runs |
| `audio` | audio track only, at maximum speed |
| `window` | download, then cut one or many time windows with stream copy |
| `capabilities` | report ops, features and vCPUs; needs no `source` |

### Options

| Option | Default | Notes |
| --- | --- | --- |
| `min_height` | `720` | lowest acceptable video height |
| `max_height` | `1080` | highest acceptable video height |
| `prefer_codec` | `h264` | `h264` avoids any transcode later; `any` allows VP9/AV1 |
| `lanes` | `8` | parallel chunk requests (max 64) |
| `chunk_mb` | `4` | size of each range request |
| `segments` | — | `[{ start_sec, end_sec, name }]` for `op: "window"` |
| `part` | — | `{ start, end }` byte offsets for `op: "full_multi"` |
| `audio` | `false` | also fetch the full audio track in the same run |
| `cookies` / `cookies_url` | — | Netscape cookie file content or URL, for age/region gated pages |
| `apify_proxy` | — | `{ groups: ["RESIDENTIAL"], country: "US" }` |

Plus `output.signed_upload_url`, `cleanup` and `callback`, as in the other
actors in this suite.

### Examples

**Resolve direct URLs only (no download, cheapest)**

```json
{ "op": "resolve", "source": "https://www.youtube.com/watch?v=XXXXXXXXXXX" }
```

**Audio only, for transcription**

```json
{ "op": "audio", "source": "https://www.youtube.com/watch?v=XXXXXXXXXXX" }
```

**Cut two windows out of a long video**

```json
{
  "op": "window",
  "source": "https://www.youtube.com/watch?v=XXXXXXXXXXX",
  "options": {
    "segments": [
      { "start_sec": 65,   "end_sec": 118,  "name": "intro" },
      { "start_sec": 1490, "end_sec": 1552, "name": "demo" }
    ]
  }
}
```

**720p H.264, 32 parallel lanes**

```json
{
  "op": "full",
  "source": "https://www.youtube.com/watch?v=XXXXXXXXXXX",
  "options": { "min_height": 720, "max_height": 720, "prefer_codec": "h264", "lanes": 32 }
}
```

### Output

```json
{
  "status": "success",
  "op": "full",
  "artifacts": [
    { "name": "video", "kv_key": "video.mp4", "url": "https://api.apify.com/v2/key-value-stores/.../video.mp4", "bytes": 84213344 }
  ],
  "meta": {
    "title": "…",
    "duration_sec": 1820.5,
    "width": 1920, "height": 1080, "fps": 30,
    "video_format_id": "137", "audio_format_id": "140",
    "direct_urls": { "video": "https://…", "audio": "https://…" },
    "download_sec": 41.2
  }
}
```

`op: "resolve"` returns `meta.direct_urls` and format details with no artifact.

### Error handling

```json
{ "ok": false, "reason": "UPSTREAM_BLOCKED", "message": "..." }
```

| `reason` | Meaning | What to do |
| --- | --- | --- |
| `BAD_INPUT` | not a supported page URL | check the link opens in a browser |
| `UPSTREAM_BLOCKED` | bot check, age or region gate | pass `cookies` and/or `apify_proxy` |
| `TIMEOUT` | download exceeded the run timeout | lower the height, or use `full_multi` fan-out |
| `OOM_LIMIT` | file too large for the memory setting | run with 16 GB, or use `window` |
| `INTERNAL` | unexpected failure | retry; report the run ID |

### Performance

16 GB run (≈4 vCPU):

| Job | Typical time |
| --- | --- |
| `resolve` | 3–10 s |
| `audio` (1 h source) | 15–40 s |
| `full` 720p (1 h source) | 1–3 min |
| `full` 1080p (1 h source) | 2–5 min |

More `lanes` help until the host starts throttling; 8–32 is the useful range.

### FAQ

**Which sites work?** Anything yt-dlp supports — the actor uses it for
resolution and format selection.

**Can I skip downloading entirely?** Yes: `op: "resolve"` gives you the direct
URLs, and range-capable consumers can read them straight away.

**Why `prefer_codec: "h264"`?** H.264 + AAC muxes into MP4 with a stream copy,
so there is no transcode step and no quality loss.

**Private or age-restricted videos?** Provide `cookies` (Netscape format) or a
`cookies_url`, and consider `apify_proxy` with a residential group.

**What next in the pipeline?** Feed the resulting URL to the **Speech to Text**,
**Speaker Diarization** or **Face Detection & Auto Reframe** actors.

# Actor input Schema

## `op` (type: `string`):

resolve = report the selected video/audio formats and their direct URLs, no download. full = parallel-range download of the selected video + audio and stream-copy mux into a faststart mp4. window = same acquisition, then cut one or many time windows (options.segments) with stream copy. capabilities = report ops/features/vcpus, needs no source.

## `source` (type: `string`):

YouTube (or other yt-dlp supported) PAGE url. Required for every op except capabilities.

## `options` (type: `object`):

min\_height (default 720), max\_height (default 1080), prefer\_codec (h264|any, default h264 so no transcode is needed), lanes (parallel chunk requests, default 8, max 64), chunk\_mb (default 4), segments \[{start\_sec,end\_sec,name}] for op=window, part {start,end} byte offsets for op=full\_multi, audio (bool, fetch full audio in same run) for op=full\_multi, format ("raw" default = hand over the source m4a untouched | "mp3" = transcode) for op=audio, player\_client (default "default,android"), extractor\_args (default "formats=missing\_pot"), cookies / cookies\_url, proxy (explicit proxy url), apify\_proxy {groups,country}, proxy\_ladder (default \["RESIDENTIAL","RESIDENTIAL","RESIDENTIAL"]), allow\_ytdlp\_fallback (default true).

## `output` (type: `object`):

{ signed\_upload\_url } to PUT a single artifact straight to your own storage.

## `cleanup` (type: `string`):

on\_success = keep only the result artifacts in the run's key-value store. always = also drop the artifact after it was pushed to signed\_upload\_url. off = keep everything for debugging.

## `callback` (type: `object`):

{ url, secret\_header: { name, value } } — POSTed with the result JSON when the run finishes.

## Actor input object example

```json
{
  "op": "capabilities",
  "cleanup": "on_success"
}
```

# Actor output Schema

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

Full run result JSON: status, op, artifacts \[{name, kv\_key, url, bytes}], meta (selected formats, real probed height, lane, per-stream MB/s), timings, errors.

## `resultRecord` (type: `string`):

The same result JSON stored as the RESULT record of the default key-value store.

# 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 = {
    "op": "capabilities"
};

// Run the Actor and wait for it to finish
const run = await client.actor("andrew_babo/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 = { "op": "capabilities" }

# Run the Actor and wait for it to finish
run = client.actor("andrew_babo/video-downloader").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 '{
  "op": "capabilities"
}' |
apify call andrew_babo/video-downloader --silent --output-dataset

```

## MCP server setup

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

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/ZbLCmUQ2D7rtRNp7C/builds/uWd5XnlnBi4EEvrcf/openapi.json
