Copy link to clipboard
Copied
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
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 <
...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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();
Copy link to clipboard
Copied
Wow! You're a genius to write down the script that's exactly what I needed. So I pasted the code saved the file with the extension jsx, but when I go to Run Script File I get the syntax error, tried to solve it myself but I cannot spot the wrong element 😞
Copy link to clipboard
Copied
it works! Thano you Dan Ebberts,
That's exactly what I needed, now I know my workflow.
the file didn't comply with UTF-8 that's why I've seen this syntax error, but now all fixed. Thank you one more time 🙂
Copy link to clipboard
Copied
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:
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).
Copy link to clipboard
Copied
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.