• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

One text line at a time every frame

New Here ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

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!

TOPICS
Expressions

Views

483

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 03, 2023 Apr 03, 2023

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 cop

...

Votes

Translate

Translate
Community Expert ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

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. 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

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.

RickGerard_1-1680536632286.gif

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

LATEST

That's hard to do because sourceRectAtTime() is going to return the width of the widest line and the height of all lines. 

 

A better approach would be to use a JSON file to animate a single text layer by changing the text on every frame. That's the only way to fully automate the height, width, and position of a shape layer background. 

 

Take a look at This Thread and Dan Ebberts's solutions to driving a text layer by a JSON file.

 

You might also want to look here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines