extract_srt
Extract text and metadata from an SRT subtitle file.
Parameters
- pathstringone of
pathorsource_key - File path to the
.srtfile; supports${ctx.key}interpolation. - source_keystringone of
pathorsource_key - Context key containing a
.srtfile path, artifact URI, or artifact descriptor. - formatstringdefault "text"
- Optional secondary-output format:
"text"or"markdown". The canonicaltranscriptoutput is always plain text. - output_keystringdefault "transcript"
- Secondary formatted output key. Set it to a key other than
transcriptto emit a separate text or Markdown rendering. - 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. Artifact inputs are opened and SHA-256 verified inside the tracked blocking worker; extraction reads that same handle rather than a resolved store pathname. Theformatparameter only accepts"text"or"markdown". Presentformat,output_key,cues_key, andmetadata_keyvalues must be strings; a value of the wrong type is rejected instead of being treated as absent.format = "markdown"requires anoutput_keyother thantranscript. The canonicaltranscript,cues_key, distinctoutput_key, andmetadata_keynames must all differ; collisions are rejected before extraction begins.
Context Output
transcript— concatenated cue text in plain text.<output_key>— emitted only whenoutput_keyis different fromtranscript; it contains a second rendering selected byformat. A Markdown rendering therefore requires bothformat = "markdown"and a distinct customoutput_key. With the defaultformatand key, no duplicate output is emitted andtranscriptstays plain text.<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—"srt"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)
Resource and cancellation contract
- The input must be a regular UTF-8 file.
IRONFLOW_MAX_FILE_BYTES(default52428800, 50 MiB) bounds both its declared size and actual bytes read. On Unix, IronFlow also refuses to follow a final path-component symlink; other platforms enforce the opened-handle regular-file check. IRONFLOW_MAX_EXTRACT_ITEMS(default250000) is cumulative across input lines inspected and parsed cues, bounding both sparse/adversarial files and ordinary subtitle structure.IRONFLOW_MAX_EXTRACT_OUTPUT_BYTES(default52428800, 50 MiB) bounds the complete serializedNodeOutput, including the canonical plain transcript, a distinct formatted output when requested, cue objects, and metadata. All retained copies therefore share one result ceiling. This is a logical result limit, not a process-RSS limit and not the laterIRONFLOW_MAX_TASK_OUTPUT_BYTESpersistence limit.- Reading, parsing, annotation removal, output construction, and serialization run on a tracked blocking worker and check cancellation and the step/run deadline between input chunks, subtitle lines, long annotation strings, and cues. Task and run admission remain occupied until the physical worker stops.
Example
local flow = Flow.new("extract_srt_demo")
flow:step("extract", nodes.extract_srt({
path = "examples/fixtures/ironflow-transcript.srt",
metadata_key = "subtitles_meta"
}))
flow:step("print", nodes.log({
message = "SRT cues: ${ctx.subtitles_meta.cue_count}"
})):depends_on("extract")
return flow