Skip to content

Highlight Videos with Blender: A Text Object Generator?

var TextFactoryInstance = new TextFactoryGeneratorInstantiator

I want to speed up making text-that-follows-speakers videos in Blender, as it’s a bit tedious and repetitive to add all the required text objects.

Sketching Out Variables

Since I have previously done something similar for making image-based captions in Shotcut, I have only very briefly listed the main things I need from this script and where I want them defined- ie either in the script itself as (say) constants, or in the input file. I also have sketched out a potential input format for the items:

  • speaker: speech for who is doing the talking and what they are saying
  • gap in seconds for delays between speech

Figuring Out Blender API

Up to here we can write most of the guts of the script — looping over the items in the input file and parsing them — without touching Blender. I am completely unfamiliar with Blender’s API, and its full index is quite extensive; searching for ‘text’ isn’t much help because of overlaps with other words “texture” and “context”.

Thankfully the quickstart guide has a very helpful tip: “Enable Developer Extra and Python Tooltips.” The former enables a few useful things, most notably “copy python command”; the latter shows the property’s python information in a tooltip on hover. Perfect!

For adding a ‘text object’, which is in fact an effect strip:

we can see that the python equivalent is bpy.ops.sequencer.effect_strip_add(type='TEXT'), for which we can look up the definition:

bpy.ops.sequencer.effect_strip_add(type=’CROSS’frame_start=0frame_end=0channel=1replace_sel=Trueoverlap=Falsecolor=(0.0, 0.0, 0.0))

Add an effect to the sequencer, most are applied on top of existing strips

Parameters: [snipped]

‘Sequencer operators’ (https://docs.blender.org/api/current/bpy.ops.sequencer.html#module-bpy.ops.sequencer)

That gets us a text effect strip! From there we can hover for a tooltip to see the python for modifying the object’s text:

the size and colour of text:

and the font:

although the last one is more complicated than ‘simply’ selecting a font, as you might in pygame for example. But this is a ‘broad strokes’ pass, we’ll figure out the details when we write it.

This gets us a good amount of information, and we now know where we can find more! Whether this is easier than working entirely within Blender is another question…

1 thought on “Highlight Videos with Blender: A Text Object Generator?”

  1. Pingback: Highlight Videos With Blender: Quicker Text Editing – Rob's Blog

Tell us what's on your mind

Discover more from Rob's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading