LIBRARY: Tutorials Reviews Interviews Editorials Features Business Authors RSS Feed

Synchronizing Video to Audio with Layer Markers and Expression Sets

COW Library : Adobe After Effects Tutorials : Joel Hooton : Synchronizing Video to Audio with Layer Markers and Expression Sets
Synchronizing Video to Audio with Layer Markers and Expression Sets
CreativeCOW.net Adobe After Effects Tutorial

 

Sychronizing Video to Audio with Layer Markers and Expression Sets

 

   

Joel Hooton
Detroit , Michigan , USA

©2005 by Joel Hooton and CreativeCow.net. All rights are reserved.

 

Article Focus:

A while back, Dan Ebberts made an article talking about synchronizing animation to audio using layer markers.  It was really cool and easy to setup.  Make a comp add the expression to an attribute and just click away on the * key on the num pad to sync video to audio. In this article, Joel Hooton wanted to see how many different useful sets of expressions he could develop that make use of this great feature.  We'll also see how they are used together to make more complex outputs.

 

 

AE file (5.5) zip                            movie               excel file


Introduction


There have been several times in the past where I wanted to sync audio and video together but did not know how.  Key framing was not the answer (too cumbersome and LOOOOOONG).  Trapcode Soundkeys works well; however, sometimes I want to have movement at specific words or notes that Soundkeys did not pick up consistently.  Plus it is not free.  Then I saw a little expression Dan Ebberts setup for someone that used layer markers to trigger a timeremap.  I looked at this expression and was amazed at how simple it was.  So I decided to rip it apart and figure out how to do other things with it.

Other people out there might already have this stuff done but I thought that since I did it and people sometimes have these questions, I might as well put it all together for everyone.  When I started compiling all of the different expressions, I wanted to cover as much ground as possible and make many different expression sets.  Yes some of these are very similar and might not be useful to everyone but I wanted to cover as much as possible.  Some expression sets have a value from 0 to 1 between markers while others step by one at each marker.  By adding, subtracting, multiplying and dividing the different sets together you can get many different outputs (we will some of this later).

Objective


First of all I am not a programmer.  I repeat I am not a programmer.  This article is not to show that I found the best way to code these expressions.  It is to let others see how easy and versatile the layer markers can be in syncing video to audio.  Hopefully that after seeing the information below, you can better understand why the code works so you can better decide how you can best use it for yourself.

 

The different code arrangements


I have setup 10 different code variations using layer makers to trigger the expressions.  Some of these are very similar but they give a better overall view of the possibilities available.

 

(1) Ramp Up Reset [between Markers]

            The code below starts increasing from zero at the first marker and continues to increase to a value of 1 at the next marker.  The distance between the markers determines the speed to the increase and the value never goes higher than 1. Repeat and Reset at next marker. 

(There MUST be a layer marker at past the end of the layer for this expression to work, see AE file)

 

if (marker.num_keys > 0){

  m = marker.nearest_key(time).index;

  if (marker.key(m).time <= time){

    (1/(marker.key(m+1).time-marker.key(m).time))*(time-marker.key(m+1).time)+1

  }else if (m != 1){

    (1/(marker.key(m).time-marker.key(m-1).time))*(time-marker.key(m).time)+1

  }else{

    0

  }

}else{

  0

} 

 

 


The red dots represent layer markers. 


=======================================================================================

 

(2) Ramp Down Reset [between Markers]

            The code below starts decreasing from 1 at the first marker and continues to decrease to a value of 0 at the next marker.  The distance between the markers determines the speed to the decrease and the value never goes higher than 1. Resets and Repeats at next marker.

(There MUST be a layer marker at past the end of the layer for this expression to work, see AE file).

 

if (marker.num_keys > 0){

  m = marker.nearest_key(time).index;

  if (marker.key(m).time <= time){

    (-1/(marker.key(m+1).time-marker.key(m).time))*(time-marker.key(m+1).time)

  }else if (m != 1){

    (-1/(marker.key(m).time-marker.key(m-1).time))*(time-marker.key(m).time)

  }else{

    0

  }

}else{

  0

} 

 



The red dots represent layer markers. 

 

=======================================================================================

 

(3) Ramp Down Reset [1 sec]

The code below starts decreasing from 1 at the first marker and continues to decrease to a value of 0 in 1 sec.  The distance between the markers is not important and the value never goes higher than 1. Resets and Repeats at next marker.

 

if (marker.num_keys > 0){

  m = marker.nearest_key(time).index;

  x=m%2;

 if (time-marker.key(m).time<1&&time>=marker.key(m).time){

    1-(time-marker.key(m).time)

 }else if (marker.key(m).index==1){

    0

 }else if(time-marker.key(m-1).time<1&&time>=marker.key(m-1).time){

    1-(time-marker.key(m-1).time)

 }else{

    0

  }

}else{

0

}

} 

The red dots represent layer markers. 

 

=======================================================================================

 

(4) Ramp Up Reset

The code below starts increasing from 0 at the first marker and continues to increase till the next marker.  The distance between the markers determines the value. The final value is equal to the time distance between the markers.  Resets and Repeats at next marker.  (This is the expression that I found from Dan Ebberts.  Thanks again)

 

if (marker.num_keys > 0){

  m = marker.nearest_key(time).index;

  if (marker.key(m).time <= time){

     time-marker.key(m).time

  }else if (m != 1){

    time -marker.key(m - 1).time

  }else{

    0

  }

}else{

  0

} 

 



The red dots represent layer markers. 

 

=======================================================================================

 

(5) Ramp Up Reset [On/Off]

The code below starts increasing from 0 at the first marker and continues to increase till the next marker.  The distance between the markers determines the value. The final value is equal to the time distance between the markers. 

Turns off at every EVEN marker then Resets and Repeats at next ODD marker.

 

if (marker.num_keys > 0){

  m = marker.nearest_key(time).index;

  x=m%2;

  if ( marker.key(m).time <= time && x==1){

    time-marker.key(m).time

  }else if (marker.key(m).time>time && x==0){

    time -marker.key(m - 1).time

  }else{

    0

  }

}else{

  0

} 

 



The red dots represent layer markers. 

 

=======================================================================================

 

(6) Ramp Up/Down Reset

The code below starts increasing from 0 at the first marker and continues to increase till halfway to the next marker.  Then the value decreases to 0 at the next marker.  The distance between the markers determines the maximum value.  Resets and Repeats at next marker.

 

 

if (marker.num_keys > 0){

  m = marker.nearest_key(time).index;

  if (marker.key(m).time <= time){

     time-marker.key(m).time

  }else if (m != 1){

   marker.key(m).time-time

  }else{

    0

  }

}else{

  0

} 

 


The red dots represent layer markers. 

 

=======================================================================================

 

(7) Step Up

The code below starts with a value of 1 at the first marker and continues to increase by 1 at each additional marker.  The total number of markers determines the maximum value. 

 

 

if (marker.num_keys > 0){

  m = marker.nearest_key(time).index;

  if (marker.key(m).time <= time){

     marker.key(m).index

  }else if (m != 1){

    marker.key(m - 1).index

  }else{

    0

  }

}else{

  0

} 

 


The red dots represent layer markers. 

 

=======================================================================================

 

(8) Step Up [On/Off]

The code below starts with a value of 1 at the first marker.  It turns off at every EVEN marker and increases by 1 at every ODD marker.  The total number of markers determines the maximum value.

The markers below indicate when the picture to the right switches.

 

if (marker.num_keys > 0){

   m = marker.nearest_key(time).index;

   x=m%2;

  if ( marker.key(m).time <= time && x==1){

     if( marker.key(m).index ==1){

       marker.key(m).index

    }else{

       marker.key((0.5*m)+.5).index

    }

  }else if (marker.key(m).time>time && x==0){

    if( marker.key(m).index==2){

      marker.key(m-1).index

    }else{

      marker.key(m/2).index

    }

  }else{

    0

   }

 }else{

  0

} 


 

The red dots represent layer markers. 

 

=======================================================================================

 

(9) Flat [+/- switch]

The code below starts with a value of +1 at the first marker.  It turns to -1 at every EVEN marker and +1 at every ODD marker.   Just basically a flip/flop expression. Values between +1/-1.

 

if (marker.num_keys > 0){

   m = marker.nearest_key(time).index;

   x=m%2;

  if ( marker.key(m).time <= time && x==1){

     1

  }else if (marker.key(m).time>time && x==0){

     1

 }else if (marker.key(1).time>time && x==1){

     0

  }else if (marker.key(m).time>time && x==1){

     -1

  }else{

    -1

  }

 }else{

  0

} 


The red dots represent layer markers. 

 

======================================================================================

 

(10) Flat

The code below starts with a value of 1 at the first marker.  It turns off at every EVEN marker and back to 1 at every ODD marker. Values between +1/0 

 

if (marker.num_keys > 0){

   m = marker.nearest_key(time).index;

   x=m%2;

  if ( marker.key(m).time <= time && x==1){

     1

  }else if (marker.key(m).time>time && x==0){

     1

  }else{

    0

  }

 }else{

  0

} 



The red dots represent layer markers. 

 

Combining the Sets

Now that the expression sets have been explained individually, combining them together can give many more complex forms possibly to cumbersome to type out in an individual expression.

 I expression set (1) is multiplied by itself and then by 100, the final graph looks like this.  This gives a second degree polynomial function that starts at zero and ends at 100.  Apply this to a layer’s opacity.  Now instead of the linear increase from zero to 1 (the standard code for set 1) the combination returns a much complex range of values based on the layer markers.

 


The red dots represent layer markers. 


 

Conclusion

I hope that this has been helpful to someone out there.  I really enjoyed setting it up and learning as I went.  The movie I made is just a quick example of how these expressions can be used.  I used no key framing in the animation of these effects.  I did manually position the layers, but all movement, opacity changes, color changes and pattern shifts were all controlled by the layer markers for each effect. 

The included excel file has the above 10 sets of expressions listed in tabular form.  You can pick and choose which sets to add, subtract, multiply and divide.  The chart in the file shows the two initial sets and the one produced after the combination.  It is useful for seeing how interactions occur. Thanks for reading.

Feel free to post your question on the Adobe After Effects Forum at CreativeCOW.net.


If you found this page from a direct link, please visit our forums or read other articles at CreativeCOW.net



Related Articles / Tutorials:
Adobe After Effects
What Are Adobe Motion Graphics Templates?

What Are Adobe Motion Graphics Templates?

A Motion Graphics Template, referred to as a MOGRT, is an animated sequence that is self-contained and can be used in Adobe Premiere Pro, Adobe Premiere Rush and Adobe After Effects, combining graphics, text, audio and video files, as well as vector or still images (including logos), to create a still or animation that can then be customized by the MOGRT user. The result is a dynamic creative tool that provides design freedom and is consistent to its users across apps and devices. Reuse, share, and even sell them!


Rod Harlan
Adobe After Effects
Compositing Secrets Everyone Can Use Pt. 4 - Advanced Alphas

Compositing Secrets Everyone Can Use Pt. 4 - Advanced Alphas

When most people hear the words "alpha channels", they think "transparency", but that's not exactly accurate. The truth is more complex, and a quite bit more interesting! Join longtime VFX artist, editor, software developer, and business owner Simon Ubsdell for Part 4 of the best look behind the technology of compositing that you've ever seen, packed with practical advice for applying the secrets of alpha channels that's simply not possible before understanding these underlying principles. No matter which applications you're using for editing, compositing, or visual effects, this one is a must-see!

Tutorial
Simon Ubsdell
Adobe After Effects
Compositing Secrets Everyone Can Use: Pt. 3 - Alpha Channels

Compositing Secrets Everyone Can Use: Pt. 3 - Alpha Channels

When most people hear the words "alpha channels", they think "transparency", but that's not exactly accurate. The truth is more complex, and a quite bit more interesting! Join longtime VFX artist, editor, software developer, and business owner Simon Ubsdell for Part 3 of the best look behind the technology of compositing that you've ever seen, packed with practical advice for applying the secrets of alpha channels that's simply not possible before understanding these underlying principles. No matter which applications you're using for editing, compositing, or visual effects, this one is a must-see!

Tutorial
Simon Ubsdell
Adobe After Effects
Compositing Secrets Everyone Can Use 2: Advanced Blend Modes

Compositing Secrets Everyone Can Use 2: Advanced Blend Modes

Whether you're a full-time compositor and VFX artist, an editor working in one of the many NLEs that supports Blend Modes (including Adobe Premiere, Apple FCP and FCPX, Avid Media Composer, DaVinci Rsolve, and VEGAS Pro), or whether you just want the additional graphics power that comes with insight into the secret world of pixels, this is the tutorial for you! Join longtime VFX artist, editor, software developer, and business owner Simon Ubsdell for Part 2 of the best look behind the technology of blend modes that you've ever seen, with some practical steps you can start taking today to make your work look better than ever.

Tutorial
Simon Ubsdell
Adobe After Effects
Compositing Secrets Everyone Can Use: Pt. 1 - Blend Modes

Compositing Secrets Everyone Can Use: Pt. 1 - Blend Modes

Join longtime VFX artist, editor, software developer, and business owner Simon Ubsdell for the best look behind the technology of blend modes that you've ever seen. This isn't just for graphics and VFX, but for video editors too -- anyone who puts anything together, and wants to learn more about HOW images combine at the most basic level, in a way that applies to every application you might use, whether Adobe Premiere Pro, Apple FCPX, Avid Media Composer, DaVinci Resolve, VEGAS Pro, and yes, graphics and VFX programs like After Effects, Motion, Fusion, Nuke, Scratch, and many more.

Tutorial
Simon Ubsdell
Adobe After Effects
Disintegration VFX in Adobe After Effects

Disintegration VFX in Adobe After Effects

Join VFX guru Tobias Gleissenberger of Surfaced Studio for a classically energetic Adobe After Effects tutorial combining difference mattes, displacement maps, edge glows, and compositing tricks to dissolve (or explode!) one element in your frame while leaving the rest alone.

Tutorial
Tobias Gleissenberger
Adobe After Effects
Adobe After Effects: Common QT & Export Problems & Solutions

Adobe After Effects: Common QT & Export Problems & Solutions

Problems with Adobe After Effects? Can't import or export QuickTime videos? Exports too big? Missing codecs? AE guru and VFX whiz Tobias Gleissenberger of Surfaced Studio has the answers you're looking for to make every project come to completion more smoothly, including a comparison of exported file sizes for common codecs.

Tutorial
Tobias Gleissenberger
Adobe After Effects
Fancy Title Animations In Adobe After Effects -- FAST!

Fancy Title Animations In Adobe After Effects -- FAST!

Follow along as VFX guru Tobias Gleissenberger shows you how how to quickly create professional-looking animated text elements using the free presets that are included with Adobe After Effects, customizing them to suit your needs. Tobias will also show you how to apply masks to your text layers to have them appear from behind other elements.

Tutorial
Tobias Gleissenberger
Adobe After Effects
Remove People from Moving Video in After Effects with Mocha

Remove People from Moving Video in After Effects with Mocha

Learn how to remove a person from a moving video using the Remove module of the Mocha Pro plug-in for Adobe After Effects! In one of his most epic tutorial's yet, Surfaced Studio's Tobias Gleissenberger then adds a bonus Beam Up effect using some of the great filters from the Boris Continuum and Sapphire collections.

Tutorial
Tobias Gleissenberger
Adobe After Effects
Basic Clone Effect Interaction - After Effects Tutorial

Basic Clone Effect Interaction - After Effects Tutorial

Want to take your CLONE EFFECT to the next level? Want to know how to make your clones INTERACT? Tobias Gleissenberger shows you how.

Tutorial
Tobias Gleissenberger
MORE
© 2019 CreativeCOW.net All Rights Reserved
[TOP]