Skip to main content
PetePLTR
Participating Frequently
November 14, 2022
Question

marker duration

  • November 14, 2022
  • 1 reply
  • 877 views

Hey,

I've been playing around with importing .srt files into After Effects usinf Digital Anarchy's free script found here...

https://digitalanarchy.com/demos/SRT-importer.html

I'm trying to add an expression to an opacity animator on the text layer that types on the words/characters over the duration of the marker from 0% to 100%....

 

m = thisLayer.marker.nearestKey(time);

s = timeToCurrentFormat(m.time)/25;

dur = m.duration;

linear(time, s, s + dur, 0, 100);

 

It starts off okay, but as soon as it detects the next marker it resets to 0.

Is there anyway to keep it going until the end of the marker duration and then reset to 0 at the start of the next marker?

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
November 14, 2022

Try this:

m = marker;
val = 0;
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n > 0){
    dur = m.key(n).duration;
    t = time - m.key(n).time;
    val = linear(t,0,dur,0,100);
  }
}
val
PetePLTR
PetePLTRAuthor
Participating Frequently
November 14, 2022

Amazing as always!

Thanks Dan