|
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