Skip to main content
Inspiring
February 7, 2023
Answered

Fit Composition length to video length over expression

  • February 7, 2023
  • 2 replies
  • 1617 views

Hey pros!

 

I have a project where I keep replacing video footage in a composition in an automated way. Since the footage is not the same length every time, I need to shorten or lengthen the composition length to the length of the footage.

Unfortunately, I can't use third-party plugins, so I have to solve it with Expressions.

I already tried to adjust the length via a slider control, but I'm not sure if this is even possible.

Here is the code I am working on at the moment:

var comp = thisComp;
var layer = comp.layer("run-footage");
var footage = layer.source;
layer.outPoint = layer.inPoint + footage.duration;
comp.duration = layer.outPoint;


The composition is called "run". The video layer is called "run-footage". The run-footage layer is the only layer in the composition. The expression above is on the slider control.

I work with 1920x1080, 50fps. The video footage is also 1920x1080, 50fps (don't know if this is relevant).

Does anyone have an idea what I'm failing at?
Thanks for your inputs!

Translated with DeepL

This topic has been closed for replies.
Correct answer Mylenium

Again, you cannot change anything about the project structure with an expression. Shifting stuff in time could be done with time-remapping to some degree, but that's another of those things. Why would you, given that even AE's basic Sequence Layers keyframe assistant could do it and there are a ton of other scripts out there as well.

 

Mylenium 

2 replies

Mylenium
MyleniumCorrect answer
Legend
February 7, 2023

Again, you cannot change anything about the project structure with an expression. Shifting stuff in time could be done with time-remapping to some degree, but that's another of those things. Why would you, given that even AE's basic Sequence Layers keyframe assistant could do it and there are a ton of other scripts out there as well.

 

Mylenium 

Inspiring
February 7, 2023

Thanks for the reply.

I'll have a look around how to get this done.

 

Mylenium
Legend
February 7, 2023

You cannot change project items with expressions. You will require a script and have to run it every time you replace your layer. I'm sure something like that already exists on AE scripts.com.

 

Mylenium 

Inspiring
February 7, 2023

Hi Mylenium
Thanks for your fast response!

So, everything that's about the timeline won't work over expressions? 
What about shifting a composition to the end of a previous composition? Would that be possible or is this also something to execute over a script?