Skip to main content
Legend
February 3, 2016
Answered

Script to time stretch layer so outpoint is set at detemined comp time.

  • February 3, 2016
  • 1 reply
  • 2389 views

Hi Everyone!

After doing some reading on the documentation and thinking through this problem, I thought I would ask for some guidance.  I'm curious to know if it's possible, with ExtendScript, to time stretch a layer such that its outpoint land's on at a determined point in the timeline.  I see that we can set the value of a layer's .stretch property, but I suppose I wan to know if there is a way to devise what that percentage value is based on where I want the layer's .outPoint to end up.

Let's say I have a layer whose inPoint starts at 0, and outpoint ends at 5.  Now, let's say I want to stretch the layer negatively so that the outpoint ends at 3.25.  What is the best way to determine the stretch value for the layer?

Thanks,
Arie

This topic has been closed for replies.
Correct answer Dan Ebberts

I guess it depends on how general you need it to be, but for the situation you've described, maybe like this:

var layer = app.project.activeItem.layer(1);

var d = layer.outPoint - layer.inPoint;

layer.stretch = (3.5/d)*100;

Dan

1 reply

Dan Ebberts
Community Expert
Community Expert
February 3, 2016

I think some variation of this should work:

var layer = app.project.activeItem.layer(1);

var d = layer.source.duration;

layer.stretch = (3.5/d)*100;

Dam

Legend
February 3, 2016

Hi Dan,

Thanks for your response.  Does this assume, though, that the selected layer's outpoint is at the source's extent?  That is, the layer's outpoint is at the end of the footage duration?  What if the footage layer is already trimmed?

Thanks,
Arie

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
February 3, 2016

I guess it depends on how general you need it to be, but for the situation you've described, maybe like this:

var layer = app.project.activeItem.layer(1);

var d = layer.outPoint - layer.inPoint;

layer.stretch = (3.5/d)*100;

Dan