Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Time To Next Keyframe Expression

  • Time To Next Keyframe Expression

    Posted by Mar Perez on June 6, 2023 at 1:19 pm

    Hey, just wrote an expression to find the (fractional) time to next keyframe. Hope someone finds this useful.

     

    var textlayer = thisComp.layer("Commentary").text.sourceText;
    var nrstkey = textlayer.nearestKey(time);
    var ind = 0;

    if(nrstkey.time<=time){
    ind = nrstkey.index+1;
    }else{
    ind = nrstkey.index;
    }

    var result = “”;

    if(ind-1==0){
    var ttnextkey = textlayer.key(ind).time-time;
    var rounded = Math.round(ttnextkey*100)/100;
    result = rounded+”s”;
    }else if(ind>textlayer.numKeys){
    result = “fin”
    }else{
    var ttnextkey = textlayer.key(ind).time-time;
    var tbetwnkeys = textlayer.key(ind).time-textlayer.key(ind-1).time;
    result = “|”.repeat(Math.ceil(ttnextkey/tbetwnkeys*10));
    }
    result;

     

     

    Mar Perez replied 3 months, 3 weeks ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy