Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Randomise frames without repetition

  • Randomise frames without repetition

    Posted by Peter Stenhouse on June 20, 2011 at 2:46 pm

    Hi there all. I hope you are well.
    I would like to randomise frames of a precomp without repeating them. Just give them a shuffle.
    I found this expression on a previous post courtesy of Dan Ebberts, but it doesn’t seem to work when I plug it into the timeRemap. The problem is with line 9. I flipped the bracket but then it threw up and error about an illegal use of a reserved word at line 12.
    I am not familiar with the for(i… etc) bit of the expression to know what is going wrong.
    Could some kind soul please give me a hand
    Thanks in advance

    Peter

    n = 100; // number of images
    minDur = 25;
    maxDur = 40;

    seedRandom(index,true);
    images = [];

    for(i = 0; i < n; i++){
    images[i] = i;
    }

    for (i = 0; i < n; i++){
    idx = i + Math.floor(random(images.length - i));
    temp = images[i];
    images[i] = images[idx];
    images[idx] = temp;
    }

    dur = 0;
    f = -1;
    while (time >= dur*thisComp.frameDuration && f < images.length - 1){
    f++;
    dur += Math.floor(random(minDur,maxDur+1));
    }
    images[f]*thisComp.frameDuration

    Peter Stenhouse replied 14 years, 11 months ago 1 Member · 1 Reply
  • 1 Reply
  • Peter Stenhouse

    June 20, 2011 at 2:55 pm

    ignore the above! It is working! I am not sure what happened but I was pasting in only part of the expression.
    Sorry to have wasted your time reading this post… though if I have brought more attention to this useful expression then it has served some purpose.
    Thanks Dan!

    small flowers crack concrete

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