extract_vtt
Extract text and metadata from a WebVTT subtitle file.
Parameters
- pathstringone of
pathorsource_key - File path to the
.vttfile; supports${ctx.key}interpolation. - source_keystringone of
pathorsource_key - Context key containing a
.vttfile path (must be a string). - formatstringdefault "text"
- Output format:
"text"or"markdown". - output_keystringdefault "transcript"
- Optional alias for the main transcript output key.
- cues_keystringdefault "cues"
- Context key for the parsed cue list array.
- metadata_keystring
- If set, metadata is stored under this key.
Providing both
pathandsource_keyis an error. Theformatparameter only accepts"text"or"markdown".
Context Output
transcript— concatenated cue text in plain text.<output_key>(defaulttranscript) — backward-compatible alias for transcript output, also plain text or Markdown based onformat.<cues_key>(defaultcues) — array of cue objects:start_ms— start timestamp in millisecondsend_ms— end timestamp in millisecondsstart— formatted start timestampend— formatted end timestamptext— cue text
<metadata_key>(when set) — object with:type—"vtt"cue_count— number of parsed subtitle cuesfirst_start_ms— first cue start timestamp in milliseconds (optional)last_end_ms— last cue end timestamp in milliseconds (optional)duration_ms— total subtitle span in milliseconds (optional)
Example
local flow = Flow.new("extract_vtt_demo")
flow:step("extract", nodes.extract_vtt({
path = "examples/fixtures/ironflow-transcript.vtt",
format = "markdown",
output_key = "subtitles_md",
metadata_key = "subtitles_meta"
}))
flow:step("print", nodes.log({
message = "VTT cues: ${ctx.subtitles_meta.cue_count}, sample: ${ctx.subtitles_md}"
})):depends_on("extract")
return flow