Copy link to clipboard
Copied
Hi,
I would like to change the duration of a comp through an expresion (ideally) or a script. The duration would come from a text field within a comp within the AE project.
I have been looking around but can't find a solution. Is it possible?
Or is there another way to achieve this? Like the comp duration could adjust to be the same length as a targeted piece of footage?
Many thanks,
Nick
Copy link to clipboard
Copied
You can't do it with an expression--expressions can only change the value of the property to which the expression has been applied. Basically, if you can't keyframe it, you can't change it with an expression.
You could change comp duration with a script, but it wouldn't be automatic--you'd have to run the script after you change the text field (or replace the footage).
Copy link to clipboard
Copied
It would be ok if it is after the text field is changed or the footage is updated. thanks !
Copy link to clipboard
Copied
The script would very much depend on the specific details of your project, so it would be difficult to come up with something generic without knowing those details.
Copy link to clipboard
Copied
Footage replacement would need to be done by a script, and it's a one-time process. There's not really a point to putting that data in a text layer.
You could write a simple script that duplicates a comp, replaces the footage, then trims the comp to the duration of the comp. This sounds more like what you'ure looking for.
Also off the shelf solutions exist for this like Templater (paid) or Nexrender (open source).
Copy link to clipboard
Copied
there is an expression that would keep the opening animation and the ending animation consistent and everything inbetweeen would be frozen, so it would not work if you had continual movement the whole duration of the precomp.
Copy link to clipboard
Copied
Thanks for the feedback. This script seems to be what I am looking for. I am just wondering if:
1. you can target a layer by name?
2. You can set the comp duration instead of the workAreaDuration?
Many thanks.
Nick
Copy link to clipboard
Copied
{
var theComp = app.project.activeItem;
var theLayer = theComp.selectedLayers[0];
theComp.workAreaStart = theLayer.inPoint;
theComp.workAreaDuration = theLayer.outPoint - theLayer.inPoint;
}
Copy link to clipboard
Copied
Like this, I think:
var theComp = app.project.activeItem;
var theLayer = theComp.layer("Layer 1");
theComp.duration = theLayer.outPoint;
Copy link to clipboard
Copied
That is fantastic thank you for your reply!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more