# `PhxDemo.Captions`
[🔗](https://github.com/thenatespack/phoenix_demo/blob/main/lib/phx_demo/captions.ex#L1)

Builds captions (SRT / WebVTT) and chapter metadata from a demo timeline.

Captions come from `say` events: each starts at `at_ms` and lasts
`duration_ms`. Chapters come from `scene` events.

# `chapters`

Chapters as `{start_ms, end_ms, title}` from scene events and the intro
and outro cards. Each runs until the next one, and the last one runs until
`duration_ms`.

# `cues`

Caption cues as `{start_ms, end_ms, text}`.

    iex> PhxDemo.Captions.cues(%{"events" => [%{"type" => "say", "at_ms" => 100, "duration_ms" => 2000, "text" => "Hi"}]})
    [{100, 2100, "Hi"}]

# `ffmetadata`

ffmpeg FFMETADATA text with one [CHAPTER] per chapter.

# `srt`

SubRip text.

    iex> PhxDemo.Captions.srt([{100, 2100, "Hi"}])
    "1\n00:00:00,100 --> 00:00:02,100\nHi\n"

# `vtt`

WebVTT text.

    iex> PhxDemo.Captions.vtt([{100, 2100, "Hi"}])
    "WEBVTT\n\n00:00:00.100 --> 00:00:02.100\nHi\n"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
