Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions time expression

  • Posted by Yaniv Cahoua on November 5, 2020 at 4:46 pm

    Hey everyone !

    Anyone knows if there is a way to do something like this:

    If a value is above zero start playing a video from start ( with time remap), else stop.

    Meaning everytime a character talks I can have the content of the video played from the start each time.

    we are doing a split screen, and I need to have 2 logos animating once from start each time one of two characters talking and I find a bit tiedious to make it by hand as there are many layers that need this treatment.

    Thanks !

    Yaniv Cahoua replied 5 years, 6 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    November 5, 2020 at 6:38 pm

    Something like this might work. Adjust the threshold value to what works best for you:

    aud = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

    threshold = 5;

    val = 0;

    if (aud.value > threshold){

    t = time - thisComp.frameDuration;

    while (t > 0){

    if (aud.valueAtTime(t) < threshold) break;

    t -= thisComp.frameDuration;

    }

    val = time - t;

    }

    val

  • Yaniv Cahoua

    November 5, 2020 at 9:04 pm

    oh this is great ! thanks so much.

    I am trying now to adapt your expression to not start from 0 each time and I thought removing val =0; would be enough but I get an error…
    any chance you provide a solution also for this one.

    oh I wish I could solve this alone but my maths are a bit rusted

  • Dan Ebberts

    November 5, 2020 at 9:54 pm

    I think this is what you mean. Just adjust tStart to where you want playback to begin:

    aud = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

    threshold = 5;

    tStart = 1;

    val = tStart;

    if (aud.value > threshold){

    t = time - thisComp.frameDuration;

    while (t > 0){

    if (aud.valueAtTime(t) < threshold) break;

    t -= thisComp.frameDuration;

    }

    val += time - t;

    }

    val

  • Yaniv Cahoua

    November 5, 2020 at 10:19 pm

    when the voice goes down, I need the comp to stay where it is and then continue from there when the sound goes up again I need the video to continue playing from the same point

    currently when the sound goes down the video is going to a fixed timecode

    I need Val to not be set to 0 at the start of each frame.

    I don’t want it to be a loop any more, I want it to be on offset mode (as if using loopOut)

    I have another video that don’t need to be looped.

  • Dan Ebberts

    November 5, 2020 at 11:04 pm

    That’s quite different. This should work, but it might become a processor hog if your comp gets too long:

    aud = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

    threshold = 5;

    tStart = 0;

    runFrames = 0;

    f = timeToFrames(time);

    while (f >= 0 ){

    if (aud.valueAtTime(framesToTime(f)) > threshold){

    runFrames++;

    }

    f--;

    }

    tStart + framesToTime(runFrames)

  • Yaniv Cahoua

    November 6, 2020 at 7:44 am

    thiis is brilliant thanks so much.

    I thought it would be much more easier, but the way you count the frames was actually not easy enough to find by myself

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