Skip to main content
Lucas Greek
Known Participant
July 10, 2022
Answered

auto adjusting the text layer's time to the length and position of an audio layer

  • July 10, 2022
  • 2 replies
  • 863 views

Hello everyone,

I just wonder if there’s any way/script/expression to make one layer mirror/copy/adjust itself to another layer’s lenght? Now i’m working on some quotes and the audio is much longer than a text layer. There are a 200 quotes. Is it posssible to make the text layer to follow the time of the audio layer? and position itself automatically?

 

thank you

This topic has been closed for replies.
Correct answer Dan Ebberts

I guess as every text and audio is named in the order

quote1

quote2

Maybe by using a pickwhip tool? I would apply it to every single one.

 

 

At the same time what bothers me: as the length of the audio layers changes every time... is there any extra expression for making all audiolayers to just be one after another? Without any spare space in betweeen them?

 

Thank you


As a simple example, this little script will go through your comp looking for text layers and when it finds one, it looks for another layer with the same name, but ending in ".wav". For each matching pair, it trims the text to the length of the audio an moves it to match the timing.

function adjustText(){
	var myComp = app.project.activeItem;
	if (myComp == null || ! (myComp instanceof CompItem)){
		alert ("No comp active.");
		return;
	}
	var myTextLayer;
	var myAudioLayer;
	for (var i = 1; i <= myComp.numLayers; i++){
		if (myComp.layer(i) instanceof TextLayer){
			myTextLayer = myComp.layer(i);
			try{
				myAudioLayer = myComp.layer(myTextLayer.name + ".wav");
			}catch (err){
				myAudioLayer = null;
			}
			if (myAudioLayer == null) continue;
			myTextLayer.startTime = myAudioLayer.inPoint;
			myTextLayer.outPoint = myAudioLayer.outPoint;
		}
	}

}
adjustText();

2 replies

Warren Heaton
Community Expert
Community Expert
July 10, 2022

You could go with keyboard shortcuts.

 

Based on your screenshot with Layer 64 selected, press "o" to move the Current Time Indictor (CTI) to the out point of the selected layer, then press command or control up arrow to select Layer 63, then press press command or control up arrow again to select Layer 62 (the corresponding Text Layer), then press option or alt right bracket to extend the out of Layer 62 to the CTI.

 

Other handy keyboard shortcuts to continue:

  • command or control down arrow to select next layer back
  • "i" to move the CTI to the in point of the selected layer
  • option or alt left bracket to trim or extend to the CTI

 

 

 

You might also be able to come up with a workflow around Digital Anarchy's free After Effects SRT Importer Script.   That uses Layer Markers on one layer with audio source to control Source Text on a corresponding; however, it starts with a SubRip Subtitle (SRT) file (a text document with time indecies for the text). 

Lucas Greek
Known Participant
July 11, 2022

Thank you for putting out those options, that's something new on my beginning journey with AE. It's good to play around with it for a little while.

Dan Ebberts
Community Expert
Community Expert
July 10, 2022

If you assume the text layer is the layer before your audio layer (as in your example) you could use an opacity expression on the text layer, like this:

L = thisComp.layer(index+1);
(time >= L.inPoint && time < L.outPoint) ? 100 : 0

If you need to actually move and trim the text layer, you'd need to run a simple script.

 

Lucas Greek
Known Participant
July 10, 2022

Thank you for your answer, I highly appreciate that.

I’d like to know better about those scripts as there are like 200 layers with text / audio. So I guess linking it all - one by one would work w/o any hiccup. I’m a rookie when it comes to scripting as well… so far could always work on some simple tasks. This one is more complex so if you could give me some guidance where to start or what to look for I’d be super grateful 🙂

 

Thank you 

Dan Ebberts
Community Expert
Community Expert
July 10, 2022

With a script like that, the main trick is defining the work flow. For example, how does the script identify the text/audio layer pairs?