Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Build difference matte with expression

  • Build difference matte with expression

    Posted by Trevor Asquerthian on June 2, 2014 at 6:09 am

    I’m trying to build a template (so I can change out background video source easily) that involves a difference matte to key moving objects back above text.

    I have a background plate (a locked off empty foreground shot), a text overlay layer then the background plate layered back over the top using a difference matte effect that uses a freeze frame of the first frame of the background plate as the difference layer source.

    I would like to build this using expressions / scripts if possible, so I can reuse and just change one BG layer

    Pseudo code for top (null or solid?) layer with difference matte applied would be:
    Get video from BG layer current frame and display for this layer
    Get video from BG layer start frame and use for difference matte source

    Thanks for any help, pointers etc

    Kevin Camp replied 11 years, 11 months ago 2 Members · 3 Replies
  • 3 Replies
  • Kevin Camp

    June 2, 2014 at 6:37 pm

    i think you can do most of this with an animation preset…

    create a new solid (solid should be the same size as the bg layer), add the compound arithmetic effect and set the second source layer to your bg layer (that should put a copy of the bg layer onto the solid)

    to create the freeze frame, add the posterize time effect after the compound arithmetic effect and then add this expression to hold on the first frame:

    thisComp.frameDuration/thisComp.duration

    now add the difference matte effect, leaving the difference layer as the solid (which is now a freeze frame of the bg).

    last, duplicate the compound arithmetic effect and move it to last in the effect stack (this will put the keyed objects back onto the solid).

    now you can tweak the difference matte settings to refine the key.

    if that works for you, you can save it as a preset to apply when needed. to do that, select the solid and type ‘uu’ to reveal modified properties. select the effects and also the frame rate property of the posterize time effect (with the expression) and maybe some of the difference matte settings that you want to keep, and then choose animation>save animation preset and save it in the after effects presets folder.

    when you need it again, make sure now layers are selected in a comp, then find the preset in the effects & presets panel and apply it (double-click) and it will create a new solid and add those effects. all you’ll need to do is select the bg layer in the 2 compound arithmetic effects.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Trevor Asquerthian

    June 3, 2014 at 6:56 am

    That is most excellent, and does exactly what I was asking for, thank you.

    A couple of questions arising, if I may:

    Is there an advantage to using the expression in the posterise time effect, rather than just setting the frame rate to 0?

    [Kevin Camp] “last, duplicate the compound arithmetic effect and move it to last in the effect stack (this will put the keyed objects back onto the solid).”

    I’m trying to understand the composting at work here. I would have thought that this extra copy of the source layer would be fully opaque, negating the difference composite, rather than having the (desired) blending effect back on top?

    thanks again

    Trevor

  • Kevin Camp

    June 3, 2014 at 3:53 pm

    [Trevor Asquerthian] “Is there an advantage to using the expression in the posterise time effect, rather than just setting the frame rate to 0?”

    doh! zero would probably work just fine… i was over thinking and trying to get too fancy.

    [Trevor Asquerthian] “I would have thought that this extra copy of the source layer would be fully opaque, negating the difference composite, rather than having the (desired) blending effect back on top?”

    by default the effect is set to composite only the rgb channels onto the layer and not effect the current alpha, however, you can set the ‘operate on channel’ setting to rgb & alpha (argb) or even just the alpha, both of which can be very useful when needed.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

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