Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Change a comp duration from an expression or script

Community Beginner ,
May 22, 2023 May 22, 2023

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

TOPICS
Expressions
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2023 May 22, 2023

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 22, 2023 May 22, 2023

It would be ok if it is after the text field is changed or the footage is updated. thanks !

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2023 May 22, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2023 May 23, 2023

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 23, 2023 May 23, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 24, 2023 May 24, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 24, 2023 May 24, 2023

{

var theComp = app.project.activeItem;

var theLayer = theComp.selectedLayers[0];

theComp.workAreaStart = theLayer.inPoint;

theComp.workAreaDuration = theLayer.outPoint - theLayer.inPoint;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2023 May 25, 2023

Like this, I think:

var theComp = app.project.activeItem;
var theLayer = theComp.layer("Layer 1");
theComp.duration = theLayer.outPoint;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 25, 2023 May 25, 2023
LATEST

That is fantastic thank you for your reply!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines