base-node (.bn)

SRT subtitles

A subtitle file read by Geometry Nodes: give the group the path of an .srt, play the scene, and the cue of the moment is drawn as text. One file, three small graphs. This page shows how to use it and the few ideas it rests on, not every node.

On a dark background, two lines of light text: From an .srt file, one cue at a time.
The second cue of sample.srt at 4 s. Its <i> tags are gone.

Use it

  1. Get it into Blender. Drag the card below onto empty space in the 3D Viewport and keep Instantiate the Example, or paste the code in a Geometry Node editor with Ctrl+Shift+V. You need Blender 5 and the Base Node add-on.
  2. Give it a file. On the modifier, file takes the path of the subtitles, an .srt, not of srt_subtitles.bn: the group reads any text it is given, and a .bn draws its own code. sample.srt holds three cues to start with.
  3. Play. The text changes with the scene time. offset moves every subtitle later, in seconds, size scales the text, and fill gives a mesh, or curves when it is off. material paints the text and font draws it in another font, Blender's own by default.

The group also outputs the cue's text as a string. Plug it into your own String to Curves, or into anything else that takes a string.

What an .srt is

Blocks parted by a blank line. Each block holds a number, a timing line and one or more lines of text:

1
00:00:00,500 --> 00:00:03,000
Subtitles read by Geometry Nodes.

2
00:00:03,200 --> 00:00:06,000
<i>From an .srt file,</i>
one cue at a time.

The format has no nesting, so string nodes can read it. A Repeat zone stands in for a loop.

srt_subtitles.bn: srt_cue, srt_seconds

The key points

Three traps of the string nodes

TrapWhat the file does
FindInString answers 0 when it finds nothing, the same as a match at the first character.It tests count > 0 before it trusts first_found.
Import Text keeps the \r of Windows line ends, so blocks are parted by \r\n\r\n.It looks at the character before the first line break. When that character is blank, every break preceded by it becomes a plain line break.
One output linked twice into Join Strings counts once, so JoinStrings(…, line_break, line_break) gives a single break.It makes the blank line with ReplaceString(string: "||", find: "|", replace: line_break).

Limits

The file, sample.srt and the script that renders this page's picture are in examples/tutorials/srt_subtitles/. make srt-check builds the file in Blender and checks its cues against an .srt written with Unix line ends and one written with Windows line ends, then that the text takes its material and its font.