# Subtitle Generator — SRT and VTT Captions from Video Files (`ponderable_hydrometer/subtitle-generator`) Actor

Generate subtitles from video or audio file links with Whisper speech recognition: an SRT and a WebVTT file per video, plus every caption line with start and end time. 90+ languages, auto-detected. No API key.

- **URL**: https://apify.com/ponderable_hydrometer/subtitle-generator.md
- **Developed by:** [Ponderable Hydrometer](https://apify.com/ponderable_hydrometer) (community)
- **Categories:** Videos, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

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

## Subtitle Generator — SRT and VTT Captions from Video Files

**Upload-ready subtitles from any video or audio link.** Whisper speech recognition writes the captions; you get a ready `.srt` and `.vtt` file per video, plus every caption line with its timing for your own editor or translation step.

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `mediaUrls` | array | — | Direct links to video or audio files. |
| `language` | string | `auto` | Language code or `auto`. |
| `maxMinutesPerFile` | integer | `60` | Only the first minutes are captioned. |

### What you get

One row per caption line: `mediaUrl`, `index`, `start`, `end` (SRT timestamps), `startSecs`, `endSecs`, `text`, `language`, and links to the full `srtUrl` and `vttUrl` files.

### Output sample

```json
{
  "mediaUrl": "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav",
  "index": 1,
  "start": "00:00:00,000",
  "end": "00:00:10,500",
  "startSecs": 0,
  "endSecs": 10.5,
  "text": "And so my fellow Americans, ask not what your country can do for you, ask what you can do for your country.",
  "language": "en",
  "srtUrl": "https://api.apify.com/v2/key-value-stores/abc/records/subtitles-1.srt",
  "vttUrl": "https://api.apify.com/v2/key-value-stores/abc/records/subtitles-1.vtt"
}
```

### What you can do with it

- **Caption your own videos** for social media, courses and webinars: download the `.srt` or `.vtt` file and upload it next to the video.
- **Make recordings accessible** with a timed caption file instead of a loose transcript.
- **Feed an editor or a translation step**: every caption line also comes as a dataset row with `startSecs`, `endSecs` and `text`.
- **Caption a library in one run**: list as many file links as you need; each file gets its own `.srt` and `.vtt`.

### Input example

```json
{
  "mediaUrls": ["https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav"],
  "language": "auto",
  "maxMinutesPerFile": 60
}
```

Use a language code (`en`, `es`, `de`, ...) instead of `auto` when you know the language; it skips detection and avoids a wrong guess on short or noisy files.

### What you give it and what you get

| You give it | You get back |
|---|---|
| A direct link to a video or audio file (for example MP4, MOV, WEBM, MP3, M4A or WAV) | One `.srt` file and one `.vtt` file, stored in the run's key-value store (`srtUrl`, `vttUrl`) |
| `language: "auto"` | The detected language in every row (`language`) |
| `maxMinutesPerFile` | Captions for the first N minutes of each file |

### Use it from the API or an AI agent

Start a run and read the captions back in one HTTP call:

```bash
curl -X POST "https://api.apify.com/v2/acts/ponderable_hydrometer~subtitle-generator/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"mediaUrls": ["https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav"]}'
```

AI agents can call it through the Apify MCP server: `https://mcp.apify.com?tools=ponderable_hydrometer/subtitle-generator`.

### How it works

Each file is downloaded, its audio is converted to 16 kHz mono, and whisper.cpp (Whisper `tiny`, multilingual) transcribes it on the Actor's own CPU. No audio is sent to any other service. Each Whisper segment becomes one caption.

### Limits and good to know

- **Direct file links only.** Pages of YouTube, TikTok, Instagram and similar sites are not supported.
- **Model size.** The compact `tiny` model is what keeps the price low. Clear speech works well; noisy audio, music, heavy accents, names and rare terms need a quick review.
- **Caption length.** Captions follow Whisper's own segments. The Actor does not re-wrap them to a fixed number of lines or characters.
- **Length cap.** Only the first `maxMinutesPerFile` minutes (default 60, maximum 600) of each file are captioned.
- **No speech, no row.** A file with no speech, or one that cannot be read, produces no rows and no result fee. If every file fails, the run ends as FAILED.
- **No speaker labels and no translation.** Captions are in the language spoken.
- **Billing unit.** One result is one caption line, so a longer, more talkative file produces more rows. Try a short `maxMinutesPerFile` first to see how many captions a typical file produces.

### FAQ

**Can it caption a YouTube link?** No. It needs a link that downloads the media file itself.

**Which languages are supported?** The languages Whisper's multilingual model covers. Set `language` to the code, or leave `auto`.

**Where are the SRT and VTT files?** In the run's key-value store, named `subtitles-1.srt`, `subtitles-1.vtt`, and so on in input order; every row carries the two links.

### Pricing

Pay per result — **$1.00 per 1,000 results** (one caption line = one result), plus Apify's standard per-run start event ($0.00005 per GB of memory, so a fraction of a cent per run). No subscription.

# Actor input Schema

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

Direct links to files such as MP4, MOV, WEBM, MP3, WAV, M4A.

## `language` (type: `string`):

Language code, e.g. en, es, de. "auto" detects it.

## `maxMinutesPerFile` (type: `integer`):

Only the first part of longer files is captioned.

## Actor input object example

```json
{
  "mediaUrls": [
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/interview.mp4",
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/courtroom.mp4",
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav"
  ],
  "language": "auto",
  "maxMinutesPerFile": 60
}
```

# Actor output Schema

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

All rows produced by this run, as JSON.

# 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://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/interview.mp4",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/courtroom.mp4",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ponderable_hydrometer/subtitle-generator").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://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/interview.mp4",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/courtroom.mp4",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ponderable_hydrometer/subtitle-generator").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://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/interview.mp4",
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/courtroom.mp4",
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav"
  ]
}' |
apify call ponderable_hydrometer/subtitle-generator --silent --output-dataset

```

## MCP server setup

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

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/4bqoqx6lYct8jToVC/builds/5BmM4GLHquGlX3ysg/openapi.json
