# Add Subtitles

## 1. Inline subtitle example

```json
{
  "type": "subtitle",
  "start": 0,
  "duration": 6,
  "words": [
    { "word": "hello", "punctuated_word": "Hello", "start": 0, "end": 0.4 },
    { "word": "world", "punctuated_word": "world!", "start": 0.4, "end": 0.9 }
  ],
  "config": {
    "position": "bottom",
    "fontSize": 58,
    "textColor": "#ffffff",
    "highlightColor": "#22d3ee",
    "backgroundColor": "rgba(0,0,0,0.45)"
  }
}
```

## 2. Asset-based subtitle example

```json
{
  "assets": {
    "subtitles": [
      {
        "id": "sub-main",
        "words": [
          { "word": "hello", "punctuated_word": "Hello", "start": 0, "end": 0.4 },
          { "word": "world", "punctuated_word": "world!", "start": 0.4, "end": 0.9 }
        ]
      }
    ]
  }
}
```

Use it like this:

```json
{
  "type": "subtitle",
  "start": 0,
  "duration": 6,
  "words": { "$ref": "sub-main" },
  "config": {
    "position": "bottom",
    "fontSize": 58,
    "highlightColor": "#22d3ee"
  }
}
```

## 3. Remote subtitle JSON

```json
{
  "type": "subtitle",
  "start": 0,
  "duration": 6,
  "words": {
    "src": "https://example.com/subtitle.json"
  }
}
```

## 4. Practical tips

- Align subtitle duration with the spoken segment
- Keep bottom padding high enough for mobile-safe areas
- Prefer `$ref` when the same subtitles are reused in multiple templates or examples

## 5. Related docs

- Subtitle element: [Subtitle Element](https://renderingvideo.com/docs/elements/subtitle.md)
- Example collection: [Examples](https://renderingvideo.com/docs/examples.md)