Skip to main content
TimSx
Inspiring
December 18, 2018
Answered

How to time remap layer using scripting?

  • December 18, 2018
  • 1 reply
  • 4755 views

I have a AVLayer that is 6s long. I'd like to slow down the first 2 seconds, speed up the 2-4s part and then again slow down the final 2 seconds.

I am totally lost when it comes to scripting keyframes.. I am even more lost now, because there is no "move" functionality when it comes to keyframes. Has anyone tried using time remap with scripting? I'd love to see some examples.

This is my starting code:

var layer = containerComp.layers[layerIndex];

layer.timeRemapEnabled = true; // sets 2 keyframes at start and end of the layer

This topic has been closed for replies.
Correct answer zlovatt

Hey!

This is how I'd go about doing it--

(function () {

    app.beginUndoGroup("Time Remap Layer");

    var comp = app.project.activeItem;

    var layer = comp.layer(1);

    

    layer.timeRemapEnabled = true;

    var timeRemapProp = layer.property("ADBE Time Remapping");

    var times = [0, 2, 4, 6];

    var values = [0, 2, 4, 6];

    timeRemapProp.setValuesAtTimes(times, values);

    app.endUndoGroup();

})();

The key parts are `var times = []; var values = [];`. This is where you'd list where you want Time Remap keys to go, and the values you want them to have.

The values I have there aren't going to do much-- it'll add a key at 0 with time 0, a key at 2 with time 2, 4 with 4, 6 with 6.

For your purposes, it depends on how much you want to speed up / slow down things. As you seem to be doing this by eye, the values are really up to you.

Something like this would slow down the first 2 seconds of animation (stretch 0-2 to 0-2.5), speed up the middle (squish 2-4 to 2.5-3.5), then slow down the last two (stretch 4-6 to 3.5-6).

    var times = [0, 2.5, 3.5, 6];

    var values = [0, 2, 4, 6];

1 reply

zlovatt
zlovattCorrect answer
Inspiring
December 20, 2018

Hey!

This is how I'd go about doing it--

(function () {

    app.beginUndoGroup("Time Remap Layer");

    var comp = app.project.activeItem;

    var layer = comp.layer(1);

    

    layer.timeRemapEnabled = true;

    var timeRemapProp = layer.property("ADBE Time Remapping");

    var times = [0, 2, 4, 6];

    var values = [0, 2, 4, 6];

    timeRemapProp.setValuesAtTimes(times, values);

    app.endUndoGroup();

})();

The key parts are `var times = []; var values = [];`. This is where you'd list where you want Time Remap keys to go, and the values you want them to have.

The values I have there aren't going to do much-- it'll add a key at 0 with time 0, a key at 2 with time 2, 4 with 4, 6 with 6.

For your purposes, it depends on how much you want to speed up / slow down things. As you seem to be doing this by eye, the values are really up to you.

Something like this would slow down the first 2 seconds of animation (stretch 0-2 to 0-2.5), speed up the middle (squish 2-4 to 2.5-3.5), then slow down the last two (stretch 4-6 to 3.5-6).

    var times = [0, 2.5, 3.5, 6];

    var values = [0, 2, 4, 6];