Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions How to repeat a frame if the following frame is too bright.

  • How to repeat a frame if the following frame is too bright.

  • tilghman wendel

    June 2, 2021 at 7:30 pm

    First post and a longtime fan of this community.

    In an attempt to thwart photosensitive seizures caused by strobing media, I’m trying to build some AE expressions that will repeat/duplicate the “safe” frame in place of the “dangerous” frame that suddenly rises in luminescence.

    i.e IF frame 23 is this much brighter than frame 22, THEN hold frame 22 for an extra frame.

    Thus, I came across some brilliant code to analyze the brightness of the frame.

    sampleLayer = effect(“Layer Control”)(“Layer”)
    color = sampleLayer.sampleImage([sampleLayer.width/2, sampleLayer.height/2], [sampleLayer.width/2, sampleLayer.height/2]);
    brightness = Math.sqrt(0.299*color[0]*color[0] + 0.587*color[1]*color[1] + 0.114*color[2]*color[2]);

    This successfully spits out a brightness value between 0-1. The next step is to tell After Effects “IF the next frame has a rise of .2 in brightness, THEN hold the current frame for one frame. This is where I got stuck.

    Thank you kindly for any help.

  • Dan Ebberts

    June 2, 2021 at 10:03 pm

    Assuming that the layer in question is time remapped, then a time remapping expression like this might mask single-frame brightness bursts:

    sampleLayer = thisLayer;

    cNow = sampleLayer.sampleImage([sampleLayer.width/2, sampleLayer.height/2], [sampleLayer.width/2, sampleLayer.height/2]);

    brightnessNow = Math.sqrt(0.299*cNow[0]*cNow[0] + 0.587*cNow[1]*cNow[1] + 0.114*cNow[2]*cNow[2]);

    cPrev = sampleLayer.sampleImage([sampleLayer.width/2, sampleLayer.height/2], [sampleLayer.width/2, sampleLayer.height/2],true,time-thisComp.frameDuration);

    brightnessPrev = Math.sqrt(0.299*cPrev[0]*cPrev[0] + 0.587*cPrev[1]*cPrev[1] + 0.114*cPrev[2]*cPrev[2]);

    if (brightnessNow - brightnessPrev > .2)

    time - thisComp.frameDuration

    else

    time

Viewing 1 - 2 of 2 posts

Log in to reply.

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