How to keep audio and video synchronized across compositions in After Effects

Written on 29 March 2018, 11:48pm under Techniques

Tagged with: ,

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 = thisLayer.startTime;
fullEndTime = thisLayer.outPoint+thisLayer.startTime;

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

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

This expression was written by the great Zack Lovatt

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.

Other popular articles