# How to add an animated time controlled text effect to the VSE

I'm trying to edit videos for my dance group. What I'd like to be able to do is have an overlay that I can set the B.P.M (beats per minute) and I can display a simple metronome + counter over the video.

I notice that there is a text effect in the VSE

Is there any way to hook a callback based on the frame count that can change the text as the video progresses? This might be able to get me what I need.

Progress

I've discovered that I can do

import bpy

def my_handler(scene):
print("Frame Change", scene.frame_current)

bpy.app.handlers.frame_change_pre.append(my_handler)


and the current frame count is output to the console. Now I would need to calculate and inject some text into the VSE

First real attempt

import bpy

def my_handler(scene):
print("Frame Change", scene.frame_current)
ob = bpy.data.objects['TimeCode']
ob['Text']=scene.frame_current

bpy.app.handlers.frame_change_pre.append(my_handler)


where I have a text effect added to the VSE and defined as

but I get console errors as

• You could try out the TextFX addon. – Samoth Oct 29 '17 at 21:46

You can use Animation Nodes to do this very easily:

You can do all sort of editing like:

The Frame Rate input is hidden by default, show it like this:

• This looks great. However I have blender 2.79 and my node editor window is a little different. Next to the node menu I only have 3 icons not 4 and the far left one you have selected I don't have. What am I missing? – bradgonesurfing Oct 29 '17 at 21:40
• Have you installed the animation nodes addon? – Samoth Oct 29 '17 at 21:45
• No. I guess that will be the problem – bradgonesurfing Oct 29 '17 at 21:51
• Got it. Solution rocks :) – bradgonesurfing Oct 29 '17 at 22:08

The following script displays the frame count as an overlay

import bpy

def my_handler(scene):
print("Frame Change", scene.frame_current)
bpy.data.scenes['Scene'].sequence_editor.sequences_all["TimeCode"].text=str(scene.frame_current)

bpy.app.handlers.frame_change_pre.append(my_handler)


• Nice. Could expand this for a generic case for any strip in scene named "TimeCode". .Would need to check seq = scene.sequence_editor is not None, and seq.sequences_all.get("TimeCode") is not None. – batFINGER Oct 29 '17 at 16:11
• Actually this does't work as it only works in manual mode. When I create a rendering the script is not called. No idea why. – bradgonesurfing Oct 29 '17 at 16:53
• lol, see what you mean. Does appear to work in render (still) image. Suggest adding a text object to scene and using frame change handler to animate its body. – batFINGER Oct 29 '17 at 17:22

I know nothing about scripting. Try to answer it with the manual way. From my understaning, it is about rendering a sequence of numbers and clamp it into one minute.

If anything fancy is not needed. Frame counter can be generated from Metadata.

Properties > Render > Metadata > Stamp Output

• Setup a empty Scene and set End Frame = BPM
• Render the empty scene with Metadata ON and Transparent.
• Overlay the clip to the dancing video, Transform the clip to one minute long with Speed Control. and Loop it over.

For video looping, please refer to:

How do you make a movie loop in the sequencer?