Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Sum Marker Values

  • Posted by Andres Torres on February 3, 2010 at 8:28 pm

    I’m using the expression below on the Source Text stopwatch of a text layer display the marker text:

    try{timeout = effect("Timeout (secs)")(1) + thisComp.frameDuration; alignBottom = effect("Align Bottom")("Checkbox");
    nextTime = marker.nearestKey(time).time;
    if(time>=nextTime) indx = marker.nearestKey(nextTime).index else indx = marker.nearestKey(nextTime).index -1;
    if(indx>0) if(time < marker.key(indx).time+timeout) subtitle = marker.key(indx).comment else subtitle = "" else subtitle=""; if(alignBottom==true){if(subtitle.indexOf(String.fromCharCode(13))==-1) subtitle = String.fromCharCode(13) + subtitle;}} catch (e) { subtitle="Create markers with comments" }

    I will be using numbers as my marker text and want the text layer to display a cumulative sum of the value. If this can't be done only on the Source Text stopwatch of text layer, would it be possible to also use a Slider to assist with the counting process?

    Thanks so much for your help. BTW, am I the only one that thinks Dan Ebberts needs a PayPal Donate button?

    Dan Ebberts replied 16 years, 5 months ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    February 3, 2010 at 8:43 pm

    This expression should display the sum of all markers up to the current time:

    total = 0;
    n = marker.numKeys;
    if (n > 0){
    markerIdx = 1;
    while((markerIdx <= n) && (marker.key(markerIdx).time <= time)){ newVal = parseFloat(marker.key(markerIdx).comment); if (! isNaN(newVal)) total += newVal; markerIdx++; } } total Dan

  • Andres Torres

    February 3, 2010 at 9:12 pm

    If there were an After Effects Superhero…his name would be Dan Ebberts.

  • Andres Torres

    February 4, 2010 at 2:56 am

    This expression worked flawlessly.

    I would like the markers to trigger an additional event. I need to have the opacity fade down about 30 frames before the marker and fade back up about 40 frames after the marker.

    I know the marker fades are traditionally measured by milliseconds, frames would be preferred if possible.

    -Andres

  • Andres Torres

    February 4, 2010 at 3:00 am

    I meant to be more specific…I should have specified the need to have control over when the fade-out begins and when the fade-in begins in relation to the marker. It will not be timed evenly on either side, i.e., the fade-out would probably begin more like 200 frames before the marker and the fade-in would begin about 60 frames after the marker.

    Thanks again,
    Andres

  • Dan Ebberts

    February 4, 2010 at 4:18 am

    Something like this, maybe:

    fadeDownFrames = 30;
    fadeUpFrames = 40;

    if (marker.numKeys > 0){
    t = marker.nearestKey(time).time;
    if (t > time){
    linear(time,t-framesToTime(fadeDownFrames),t,100,0);
    }else{
    linear(time,t,t+framesToTime(fadeUpFrames),0,100);
    }
    }else{
    value
    }

    Dan

  • Andres Torres

    February 4, 2010 at 3:12 pm

    This is good. The only thing it’s missing is a fadeWidth variable to control how many frames to hold the opacity at zero.

  • Andres Torres

    February 4, 2010 at 5:02 pm

    So there’s 3 parts to this:

    1. A fade out that lasts for 20 frames that begins -10 frames from the marker (or 10 frames before the marker)

    2. hold the opacity at zero until 50 frames after the marker.

    3. A fade in that lasts for 20 frames and begins 50 frames after the marker.

    The expression below doesn’t exactly achieve this:

    startOutDown = -10; // frames from marker
    fadeOutFrames = 20; // duration of fade
    startFadeUp = 50 // frames from marker
    fadeUpFrames = 20; // duration of fade

    if (marker.numKeys > 0){
    t = marker.nearestKey(time).time;
    if (t > time){
    easeOut(time,t+startFadeOut+framesToTime(fadeOutFrames),t,100,0);
    }else{
    easeIn(time,t,t+startFadeUp+framesToTime(fadeUpFrames),0,100);
    }
    }else{
    value
    }

    This approach may be more robust:

    1. A fade out that lasts for 20 frames that begins -10 frames from the marker (or 10 frames before the marker)

    2. hold the opacity a specified number of frames, then begin a fade in that lasts for 20 frames.

  • Dan Ebberts

    February 4, 2010 at 5:53 pm

    May be this is closer:

    fadeOutBegin = 10; // frames before marker
    fadeOutDur = 20; // duration of fade out
    holdDur = 40; // duration of fade hold
    fadeInDur = 20; // duration of fade in

    if (marker.numKeys > 0){
    t = marker.nearestKey(time).time;
    t1 = t – framesToTime(fadeOutBegin);
    t2 = t1 + framesToTime(fadeOutDur);
    t3 = t2 + framesToTime(holdDur);
    t4 = t3 + framesToTime(fadeInDur);
    if (time < t2){ ease(time,t1,t2,100,0); }else if (time < t3){ 0; }else{ ease(time,t3,t4,0,100) } }else{ value } Dan

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