Resize & reposition text layer, based on multiple layers position

Community Beginner ,
Jan 29, 2022 Jan 29, 2022

Copy link to clipboard

Copied

I'm in the middle of creating a script/process, where I press a few buttons, and AE creates a fully working typography video based on a video file, and the transcription of the video.

Within this process, all words transcription are split up into seperate layers, with in and out points matching the word duration, based on markers that were applied via text analysis in a separate scriptlet. The scriptlet I've written (with the help of my seasoned, programmer father. He'd kill me if I didn't give him any credit, ha!), creates a new text layer for every word, and sets the in and out points to the duration of that word, unless the words are spoken very close together (within 6 frames), then it sets the outPoints to "phraseEnd" outPoint. It's not perfect yet. Bit confusing, pic below may make sense of it.
Capture.PNG

I have expressions set on each layer to check if the word is part of a "phrase", and dynamically position the layers below each other, and scale them up or down so they match their previous word (another pic below).

Capture 2.PNG

My issue comes when there are too many words in one phrase, and some of the words are below the bottom of the comp. So i've looped through all of the layers, and found the "layerEndPhrase" layer and "layerEndPhraseBottomLeft". But I have no idea what to do with this information. I'm just not sure of the calculations and values that I need in order to create an expression like this.
If the layers after the start of the phrase are determining the layer at the end of the phrase, then I cant reference "layerEndPhraseBottomLeft" as it will change depending on where the first word in the phrase is, is that correct?

Does anyone have any ideas as to how I could do this?

Pretty new to all of this so excuse any rookie mistakes.

Here's my current code:

 

On position:

 

 

layerBelow = thisComp.layer(index+1);



if (thisLayer.outPoint <= layerBelow.outPoint)

{

layerBelowBottomLeft = layerBelow.effect("Source HUD")("Bottom Left");

layerBelowWidth = layerBelow.effect("Source HUD")("Box Width");

thisLayerWidth = effect("Source HUD")("Box Width");

thisLayerHeight = effect("Source HUD")("Box Height");

newPosition = [layerBelowBottomLeft[0]+(thisLayerWidth/2),layerBelowBottomLeft[1] + thisLayerHeight + 15];

}

else

{

l = thisLayer.index;

while( l <= thisComp.numLayers && thisComp.layer(l).outPoint == thisComp.layer(l-1).outPoint)

{

l--;

}

layerEndPhrase = thisComp.layer(l);

layerEndPhraseBottomLeft = layerEndPhrase.effect("Source HUD")("Bottom Left");

}

 

 

 

On scale:

 

 

try{

layerBelow = thisComp.layer(index+1);

if (thisLayer.outPoint <= layerBelow.outPoint)

{

layerBelowBottomLeft = layerBelow.effect("Source HUD")("Bottom Left");

layerBelowWidth = layerBelow.effect("Source HUD")("Box Width");

thisLayerWidth = effect("Source HUD")("Box Width");

oldValue = thisLayer.sourceRectAtTime(0).width;

newValue = (layerBelowWidth/oldValue)*100;

[newValue,newValue]

}

else

{

[value[0],value[1]]

}

}

catch(err) {value}

 

 

TOPICS
Expressions , Scripting

Views

80

Likes

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
Adobe Community Professional ,
Jan 29, 2022 Jan 29, 2022

Copy link to clipboard

Copied

Not sure what specifically you are asking, as I can't sse your expressions do anything beyond setting up static layers. In such a case you would simply add more markers to split your phrases, I guess. Otherwise the smartest way to go about this would likely to create some sort of side & push animation within such a segment itself, swiping the old text out to one side and moving in more words from another. This could totally be based on an animation preset or by creating a suitably tall pre-comp and moving that around....

 

Mylenium

Likes

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
Participant ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

It seems to me that your issue is because layers are scaled to longest width on a phrase, sometimes you end up in the situation where short words becomes large enough and goes outside of the comp? And to put the matters worse, when there are more rows, it just doesn't fit in? 

Likes

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
Adobe Community Professional ,
Feb 05, 2022 Feb 05, 2022

Copy link to clipboard

Copied

LATEST

Premiere Pro and Adobe Audition can both generate labeled markers for subtitles. The workflow is smooth and efficient. It is then an easy task to turn that data into subtitles. Breaking up audio layers into individual phrases based on Markers then converting that marker data to text is a long way around the barn. You could do everything you are describing with one audio layer with markers and a single text layer with a text animator if needed. Even easier, you could just generate the subtitles in Premiere Pro, including transitions.

 

There is not a. thing in any of your expression language that will generate the width of a text layer. You need sourceRectAtTime(), a reference to the width, left edge, and top of the source text, to create or move boxes behind the text layer. 

 

A little more info on your comp and some screenshots that show the modified properties of the text and/or shape layer you are trying to control would help us help you. We don't have much to go on.

Likes

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