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
