Skip to main content
Participant
April 3, 2023
Answered

One text line at a time every frame

  • April 3, 2023
  • 1 reply
  • 811 views

I am looking for a script that display each line of text from a multi-line text in After Effects, every frame. To get the ideea, i want to export subtitles in a sequence file. Can anyone help me, please. Thanks!

This topic has been closed for replies.
Correct answer Rick Gerard

If you set the Range Selector/Advanced/Mode to Subtract and subtract one from the Start value with this expression, you will get one line at a time. Apply this expression to End.

 

text.animator("Animator 1").selector("Range Selector 1").start -1

 

You can use the frame number of the Range Selector start and multiply that by the leading value in the text to offset the position of the text layer the height of a line on every frame. Unfortunately, different fonts have different heights so just copying the kerning value from the text layer, or dividing the height by the number of layers is not going to give you a perfect offset between frames. The easiest solution would be to add an expression control slider for Leading and add that into the expression for position. Something like this would work:

 

f = text.animator("Animator 1").selector("Range Selector 1").start;
l = effect("Leading")("Slider");
d = l * f;
[value[0], value[1] - d ]

 

I've included a project file.

That should do it. You'll just have to adjust the slider to make sure the text does not appear to move.

1 reply

Community Expert
April 3, 2023

Create your text layer. Add a text animator for opacity. Spin down the Range Selector and set the Advanced options units to Index and Based on to Lines. Set the Range Selector/Opacity to zero. Add this expression to the  Range Selector/Start property:

 

t = time - inPoint;
t / thisComp.frameDuration;

As soon as the layer starts, the lines of text will appear one after another. Frame 0, no text, frame 1 = first line, frame 1 = second line, and so on until you run out of lines. 

 

 

 

Participant
April 3, 2023

It does so, but i need to appear each line for one frame, line one for one frame and the next frame to dissaper and appear the second line for one frame, in the same place. Thank you for responding!

Participant
April 11, 2023

You mean from End value, i guess, but that will make every line apear at every frame, just that enery line stays in place. I need every line, in order, to apear at the same position, at every frame. The idea is to export a sequence with every line, in the same position , like a subtitle.


Thank you! The next challenge is to have for every line, at every frame, a text box with the length of each line!