Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random duration expression

  • Random duration expression

    Posted by Dimitri Sourzac on May 30, 2016 at 2:20 pm

    Hi there!
    I’m trying to make an expression on time remapping that allows me to randomly change the position of the playhead of a video. This code works but I’d like to be able to randomize the duration of each segment (segDur in the code).
    I tried to use random() but a new value is calculated every frame.
    Any ideas?

    //segDur - This variable controls how often the playhead will be changed.
    segDur = 0.3;// duration of each "segment" of random time
    minVal = inPoint;
    maxVal = outPoint - segDur;
    seed = Math.floor(time/segDur);
    segStart = seed*segDur;
    seedRandom(seed,true);
    startVal = random(minVal,maxVal);
    endVal = startVal + segDur;
    linear(time,segStart,segStart + segDur, startVal, endVal);

    Dimitri Sourzac replied 10 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 30, 2016 at 6:45 pm

    This should work as long as the keyframe marking the end of the video content is still there:


    minDur = .25;
    maxDur = .35;
    tStart = tEnd = dur = 0;
    seedRandom(index,true);
    while (tEnd <= time){
    tStart = tEnd;
    dur = random(minDur,maxDur);
    tEnd += dur;
    }
    seedRandom(tStart,true);
    vStart = random(inPoint,key(numKeys).time-dur);
    vEnd = vStart+dur;
    linear(time,tStart,tEnd,vStart,vEnd)

    Dan

  • Dimitri Sourzac

    May 30, 2016 at 7:00 pm

    It works great!
    Thanks for your help!

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