Skip to main content
ti.s.cavalcanti
Inspiring
June 18, 2015
Answered

Script to Comp Duration

  • June 18, 2015
  • 1 reply
  • 15465 views

I have "Main Comp" with 30 seconds of time, and inside have:

A footage called "Forest"

I want to replace Footage which can vary of time, being greater, like 59 seconds for example, so I need wich the "Main Comp", also adjusts according to Footage time duration. "Main Comp" staying with 59 seconds.

Thanks.

This topic has been closed for replies.
Correct answer David Torno

I try this:

var myComp = app.project.activeItem;

myComp.duration = myLayer.property("Footage").duration

That didn't work because layer objects do not have a duration attribute. The math has to be done manually. Normally you take the layer outPoint minus the inPoint to get the layer duration.

var myComp = app.project.activeItem;

var myLayer = myComp.layer(1);    //Assumes layer 1 is your choice

myComp.duration = (myLayer.outPoint - myLayer.inPoint);    //Assumes the layer is normal and not reversed

This won't be bullet proof though because a layer can also be reversed, which places the inPoint after the outPoint, so you would need to flip the order. You would say inPoint minus the outPoint.

var myComp = app.project.activeItem;

var myLayer = myComp.layer(1);    //Assumes layer 1 is your choice

myComp.duration = (myLayer.inPoint - myLayer.outPoint);    //Assumes the layer is reversed

1 reply

Szalam
Community Expert
Community Expert
June 18, 2015

You can go into your composition settings and adjust it to be a longer period of time. Is that what you're asking for?

ti.s.cavalcanti
Inspiring
June 18, 2015

Yeah, but i need to write a Script.

I try this:

var myComp = app.project.activeItem;

myComp.duration = myLayer.property("Footage").duration

Not work.

Szalam
Community Expert
Community Expert
June 18, 2015

If you just want to buy a script, this should do it: Trim Comp to Contents - aescripts + aeplugins - aescripts.com