Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Time Remap to Markers

  • Time Remap to Markers

    Posted by Matthew Borgatti on April 25, 2011 at 5:42 pm

    I’ve got a pretty simple project that I’ve got mostly working. I’ve got a pre-comp with some footage (named “Footage”) with some composition markers designating crucial spots. It’s nested within the main comp which also possesses a layer called “some.wav” that has its own set of markers.

    The idea is to set up markers at key spots in the “some.wav” (the soundtrack) layer and have the footage randomly jump between the marked positions whenever the playhead passes the soundtrack’s markers.

    Everything seems to work with the following expression, except only one frame will play from the marked spot in “Footage” before it returns to the beginning of the pre-comp. I’d like to have it play continuously until another jump is triggered. This expression lives on the Time Remap effect on the “Footage” pre-comp.

    Advice would be really appreciated. Thanks.

    markerLayer = thisComp.layer("some.wav");
    myNearestKey = markerLayer.marker.nearestKey(time);

    n = comp("Footage").marker.numKeys;
    i = Math.floor(random(1,n));

    if (time >= myNearestKey.time){
    markerCounter = comp("Footage").marker.key(i).index;
    timeRemap.valueAtTime(comp("Footage").marker.key(i).time);}
    else{
    framesToTime(markerCounter );}

    Lem Assad replied 12 years, 7 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    April 25, 2011 at 6:41 pm

    I think this works:


    m = thisComp.layer("some.wav").marker;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n--;
    }

    t = (n > 0) ? time - m.key(n).time : 0;

    seedRandom(n,true);

    cm = comp("Footage").marker;
    if (cm.numKeys > 0){
    i = Math.floor(random(cm.numKeys))+1;
    cm.key(i).time + t;
    }else
    0

    Dan

  • Matthew Borgatti

    April 25, 2011 at 7:05 pm

    Wow. That’s a fantastic, elegant bit of code. Thank you so much. I just tested it on a project and it worked right out of the gate.

  • Lem Assad

    December 21, 2013 at 7:50 pm

    Really nice piece.

    Do you know if it’s possible to have the jumps remember where it stopped and continues from there then?

    It can be really nice for parallel edits

  • Lem Assad

    December 22, 2013 at 12:05 pm

    Something like markertime+elapsedtime

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