Animating to audio is an important part of working inside of After Effects. But it can become messy very quickly. As soon as you move things around you have to manually resynchronize everything. Here’s a solution that I’ve been using for a couple of years that works very well.

Disclaimer first, I know I found this expression somewhere at some point and saved it as an animation preset, but I have no idea where I found it. After some REsearch I was not able to find it. So if you happen to know where it comes from, please let me know in the comments and I will gladly give credit where its due.

How it works

First level compositions

Let’s say you have your main composition, which contains your animation. Inside of it are many compositions and each one is a scene. These are your first level compositions. In your main composition, place the composition you want synced. It might be a composition containing your voice-over. It may also contain a video. Whatever will work since we’re using time-remapping. For our example we’ll use # Main > Voice over.

Assuming that your main composition is called # Main (see A composition naming system for After Effects for why I think it should), you can just time-remap the composition you want synchronized and add this expression to the time-remap property.

parentComp = comp("# Main");

compStartTimeInParent = parentComp.layer(thisComp.name).startTime;
audioStartTimeInParent = parentComp.layer(thisLayer.name).startTime;
fullStartTime = this.startTime;
fullEndTime = this.source.duration+startTime;

linear(time, fullStartTime, fullEndTime, fullStartTime+compStartTimeInParent-audioStartTimeInParent, fullEndTime+compStartTimeInParent-audioStartTimeInParent)

Now replace the parentComp variable if your composition is named differently.

This assumes your synchronized composition is not time-remapped inside the parent (# Main) composition. It should be anyway. The one placed in # Main is your guide composition. The one that will drive the ones placed inside your other compositions. When using a time-remapped parent, use the following technique.

Second level compositions

Your second level compositions are the ones placed inside the first level compositions. As in the hierarchy # Main > ## Scene 1 > ### Shot 1

## Scene 1 would be first level and ### Shot 1 would be second level. Again, refer to A composition naming system for After Effects if this naming system makes no sense to you.

For second level compositions to have a synchronized compositions, they have to refer a time-remapped parent composition. This can get problematic when reusing a composition inside many parents, but it will work when using a single child-parent hierarchy.

Use the same synchronized # Main > Voice over composition, time-remap it, and add this expression to its Time Remap property:

parentComp = comp("# Main > ## Scene 1");

compStartTimeInParent = parentComp.layer(thisComp.name).startTime;

parentComp.layer(thisLayer.name).timeRemap.valueAtTime(time + compStartTimeInParent)

And simply replace the parentComp variable.

For this to work, the targeted parent composition has to contain # Main > Voice over. The name of the composition is just an example, don’t worry about it. It is dynamic. And the targeted parent composition has to be time-remapped.

If you don’t care about setting those expressions yourself every time your want a layer synced, I get you. Presets do make things faster. Here’s links to presets for both setups:

  • First level compositions (preset named Sync Composition.ffx) Download
  • Second level compositions (preset named Sync Composition Time Remapped.ffx) Download

This thing has saved me countless hours over the years so I thought that’d make sense to share. Let me know if you have any questions of if you have another approach to this issue.

Expressions are a really powerful feature in After Effects. It can help you improve the quality and fluidity of your animation but it can also help you organize your project. Expressions if used well, gives you the opportunity to create yourself a custom dashboard on which you can control various global variables.

Create a controller

It is a good practice to keep a controller layer in a separate stand-alone composition. You will often see such a thing when you purchase items from marketplaces such as VideoHive.

But even when not selling your source files, you should act as if. Be it for a co-worker taking over your project or just the future you, who won’t enjoy searching through a messy compositions structure.

(more…)

How to use checkbox expressions in After Effects

Written on 15 September 2013, 01:42pm under Quick Tips

Tagged with: ,

You will often find yourself toggling the visibility of layers in After Effects. This can get really cumbersome and hazardous to click all those little eye icons in deeply nested compositions. Having a controller layer on top of everything with some checkbox expressions can really help organizing everything out.

Select the layer you’d want to toggle and add this expression in its opacity property.

(comp("the-comp-name").layer("the-layer-name").effect("the-checkbox-effect")("Checkbox") == 1 ? value : 0)

This layer will then show when the checkbox is checked. To invert the effect, just invert the value and the 0.

Heads up!

Most layers, when hidden, will not add time to renders and RAM Previews although sometimes, mostly when the hidden layer has expressions, it will still be processed when rendering.