> ## Documentation Index
> Fetch the complete documentation index at: https://rendi.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Burn SRT subtitles into a video

> Render an SRT subtitle file permanently onto a video using Rendi's FFmpeg API. Node.js, Python, and cURL examples.

Render an SRT subtitle file permanently onto a video (burned-in captions). Useful when the target player doesn't support subtitle tracks or you need guaranteed rendering.

## Code

<Tabs>
  <Tab title="Node.js">
    ```js theme={null}
    const API_KEY = process.env.RENDI_API_KEY;

    const submit = await fetch("https://api.rendi.dev/v1/run-ffmpeg-command", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": API_KEY,
      },
      body: JSON.stringify({
        input_files: {
          in_video: "https://storage.rendi.dev/sample/sample.avi",
          in_srt: "https://storage.rendi.dev/sample/subtitles.srt",
        },
        output_files: {
          out_1: "subtitled.mp4",
        },
        ffmpeg_command:
          "-i {{in_video}} -ss 00:00 -to 01:00 -vf subtitles={{in_srt}} -c:v libx264 -crf 20 -c:a aac -b:a 192k {{out_1}}",
      }),
    });
    const { command_id } = await submit.json();

    while (true) {
      const res = await fetch(`https://api.rendi.dev/v1/commands/${command_id}`, {
        headers: { "X-API-KEY": API_KEY },
      });
      const data = await res.json();
      if (data.status === "SUCCESS") {
        console.log("Subtitled URL:", data.output_files.out_1.storage_url);
        break;
      }
      if (data.status === "FAILED") throw new Error("Command failed");
      await new Promise((r) => setTimeout(r, 2000));
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import os
    import time
    import requests

    API_KEY = os.environ["RENDI_API_KEY"]
    BASE = "https://api.rendi.dev/v1"
    headers = {"X-API-KEY": API_KEY}

    submit = requests.post(
        f"{BASE}/run-ffmpeg-command",
        headers=headers,
        json={
            "input_files": {
                "in_video": "https://storage.rendi.dev/sample/sample.avi",
                "in_srt": "https://storage.rendi.dev/sample/subtitles.srt",
            },
            "output_files": {"out_1": "subtitled.mp4"},
            "ffmpeg_command": "-i {{in_video}} -ss 00:00 -to 01:00 -vf subtitles={{in_srt}} -c:v libx264 -crf 20 -c:a aac -b:a 192k {{out_1}}",
        },
    )
    command_id = submit.json()["command_id"]

    while True:
        res = requests.get(f"{BASE}/commands/{command_id}", headers=headers).json()
        if res["status"] == "SUCCESS":
            print("Subtitled URL:", res["output_files"]["out_1"]["storage_url"])
            break
        if res["status"] == "FAILED":
            raise RuntimeError("Command failed")
        time.sleep(2)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl --request POST \
      --url https://api.rendi.dev/v1/run-ffmpeg-command \
      --header 'Content-Type: application/json' \
      --header 'X-API-KEY: <api-key>' \
      --data '{
        "input_files": {
          "in_video": "https://storage.rendi.dev/sample/sample.avi",
          "in_srt": "https://storage.rendi.dev/sample/subtitles.srt"
        },
        "output_files": {"out_1": "subtitled.mp4"},
        "ffmpeg_command": "-i {{in_video}} -ss 00:00 -to 01:00 -vf subtitles={{in_srt}} -c:v libx264 -crf 20 -c:a aac -b:a 192k {{out_1}}"
      }'

    curl --request GET \
      --url https://api.rendi.dev/v1/commands/<command_id> \
      --header 'X-API-KEY: <api-key>'
    ```
  </Tab>
</Tabs>

## How the FFmpeg command works

* `-i {{in_video}}` — input video
* `-ss 00:00 -to 01:00` — only burn subtitles into the first minute (drop this to process the full video)
* `-vf subtitles={{in_srt}}` — subtitles video filter reads the SRT file
* `-c:v libx264 -crf 20` — re-encode video (required, since the filter modifies frames)
* `-c:a aac -b:a 192k` — re-encode audio
* `{{out_1}}` — output file

For soft subtitles (a separate subtitle track that can be toggled off), use `-c:s mov_text` with an MP4 container and skip the `-vf` filter.

## Response

```json theme={null}
{
  "output_files": {
    "out_1": {
      "file_id": "cb5b9186-...",
      "size_mbytes": 13.95,
      "duration": 60.0,
      "file_type": "video",
      "file_format": "mp4",
      "storage_url": "https://storage.rendi.dev/temp_files/.../subtitled.mp4",
      "width": 854,
      "height": 480,
      "codec": "h264"
    }
  },
  "status": "SUCCESS",
  "command_type": "FFMPEG_COMMAND"
}
```

## Related

* [Overlay watermark](/examples/overlay-watermark)
* [Transcode](/examples/transcode)
* [Cheatsheet — Add subtitles to a video](https://github.com/rendi-api/ffmpeg-cheatsheet#-add-subtitles-to-a-video)
