Auto adjust the duration in the comp

Hi all,
I just want to know is there a way to auto adjust the duration of the comp according to the video clip duration in after effects?

this script

function fun(){
var curComp = app.project.activeItem;
   if (!curComp || !(curComp instanceof CompItem)){
        alert("no active comp");
if(curComp.numLayers < 2){
    alert("Not enough layers");
var compone = curComp.layer(1);
var comptwo = curComp.layer(2);
comptwo.startTime = compone.outPoint;

1 Like

Thanks buddy, but where should I put this script?

1 Like

Ok got it, but this is not what I want.

What I want is: there is a composition with a video_clip_1 (10sec) and I want to replace that video clip with the video_clip_2 (20sec) so at the same time the composition duration also change automatically to 20sec.

Is there a way to do that?


You can make time adjustments here by adding a slider for the adjustment layer. I’ve done this once before, but in the first AE CC guide. For example, we can make composition scales automatically with a script. Likewise we can do it on StartTime and EndTime.

Or we can add a global automatic StartTime and EndTime by creating an Adjustmant layer in the outermost layer and adding the same Adjesment Layers to each composition.

1 Like

Still can’t find a solution, is there an option in After Effects newer version?

Hey buddy,
Can you show me how global automatic StartTime and EndTime works?

Of course, I will make a sample for this and send it to you.

Great! thanks buddy waiting for it.