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
Imagineer mocha Pro 5 Plug-In for Adobe: An In Depth Review

Imagineer mocha Pro 5 Plug-In for Adobe: An In Depth Review

Imagineer mocha Pro 5 Plug-in for Adobe brings all the amazing features of the professional version of the mocha Planar Tracker directly into After Effects and Premiere Pro in the form of a plugin. In this in-depth review, After Effects tutorial guru Tobias Gleissenberger of Surfaced Studio will show you what you can do with this new plug-in, and discuss what he likes and doesn't like about the new update.

Tutorial
Tobias Gleissenberger
Adobe After Effects
After Effects 2015.3 - My Favorite Features

After Effects 2015.3 - My Favorite Features

Learn why you should upgrade to After Effects CC 2015.3 - 13.8.1 - a close and detailed look at the latest release of After Effects (August 2016). Roei Tzoref will be focusing on his favorite features that set this release apart from previous versions: Performance, Queue in AME, Lumetri Color new features, and more.

Tutorial
Roei Tzoref
Adobe After Effects
Advanced Masking in Adobe After Effects

Advanced Masking in Adobe After Effects

Some of the coolest stuff you can do inside of Adobe After Effects is only possible once you unlock the power of masks. Join After Effects whiz Tobias Gleissenberger of Surfaced Studio to learn about mask animation and interpolation, using the variable width feathering tool, managing mask modes and ordering, and more.

Tutorial
Tobias Gleissenberger
Adobe After Effects
Fixing Common After Effects Problems and Mistakes

Fixing Common After Effects Problems and Mistakes

Got problems using Adobe After Effects? Exported files too large, Expressions not working, mixing shapes and makes, modes/switches, selecting previews for layers vs. comps - Surfaced Studio's Tobias Gleissenberger shows you fast fixes for these and more!

Tutorial
Tobias Gleissenberger
Adobe After Effects
mocha AE Planar Tracker for Absolute Beginners

mocha AE Planar Tracker for Absolute Beginners

Want to learn how to create advanced visual effects? Learn how to use mocha AE to track your shot and add advanced visual effects to live action footage inside Adobe After Effects. mocha can help you track shots that would be hard to track using traditional 2D point or feature trackers because it is a PLANAR TRACKER. A planar tracker uses planes and textures to track as opposed to points or groups of pixels. This allows the tracker to stay on track even if your shot contains motion blur or a very shallow depth of field. mocha AE comes included with Adobe After Effects and is available since CS3 and there is no reason for you not to use this awesome tool to make it easier for you to track your shot, replace screens or rotoscope!

Tutorial
Tobias Gleissenberger
Adobe After Effects
How to Make After Effects Faster with Proxies

How to Make After Effects Faster with Proxies

Learn how to make Adobe After Effects faster by using PROXIES! A proxy is a placeholder that stands in place for a very large video file or image sequence in your project. You can easily create proxies for the large source files that you are using and After Effects will automatically link them to the item in your project panel.

Tutorial
Tobias Gleissenberger
Adobe After Effects
Stabilize & Smooth: mocha 5 Plug-in for Adobe & Avid

Stabilize & Smooth: mocha 5 Plug-in for Adobe & Avid

Imagineer Systems and Boris FX product specialist Mary Poplin shows you how to stabilize with the new mocha Pro 5 plug-in inside of Avid Media Composer, Adobe Premiere Pro and After Effects. This tutorial covers artistic stabilization, such as smoothing out camera movements or stabilizing around moving objects, completely locking down shots, and automatically replacing edge fill on planar backgrounds.

Tutorial
Mary Poplin
Adobe After Effects
Adobe After Effects Puppet Tool

Adobe After Effects Puppet Tool

Become a puppet master by learning how to use the Puppet Tool in Adobe After Effects! This intermediate-level tutorial from After Effects guru Tobias will show you how the Puppet Tool allows you to add joints and animations to bring life to any static image!

Tutorial
Tobias Gleissenberger
Adobe After Effects
How to Spawn A Clone in Adobe After Effects

How to Spawn A Clone in Adobe After Effects

Want to learn how to create a cool clone spawn effect in Adobe After Effects? Follow along with After Effects whiz Tobias from Surfaced Studio in this exciting new visual effects tutorial that combines green screen using Keylight, CC Vector Blur, the Liquefy Effect, CC Particle World, and much more, delivered in Tobias' inimitable style!

Tutorial
Tobias Gleissenberger
Adobe After Effects
Creating A Flame on Your Finger with After Effects

Creating A Flame on Your Finger with After Effects

It is easy to do some motion tracking and attach a basic stock footage element of fire onto your hands, but there is a little bit of work involved if you actually want to make it look good. In this intermediate tutorial by After Effects expert Tobias, you'll see how to use a fire stock footage element to set your thumb on fire! There are lots of useful tricks for null objects, expressions, and more in this tutorial that will help you create all sorts of other cool visual effects -- or set even more things on fire!

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