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
Create an Arrow or Pointer preset for After Effects

Create an Arrow or Pointer preset for After Effects

In this video tutorial, Graham reveals a really quick way to use Shape Layers to make an arrow preset that you can use to point to anything in Adobe After Effects.


Graham Quince
Adobe After Effects
Realistic Water Movement with Fractal Noise

Realistic Water Movement with Fractal Noise

In this tutorial video, Andy Ford shows you how to use the Fractal Noise effect in After Effects to add movement to water in a still photo

Feature
Andy Ford
Adobe After Effects
Adobe Creative Cloud September 2020 Update: Streamlined workflows that make storytelling easier

Adobe Creative Cloud September 2020 Update: Streamlined workflows that make storytelling easier

The current environment is forcing us to rethink and reimagine so much. Content creators, from broadcasters to streaming services to social video creators, are finding new ways of working that prove creativity and resourcefulness are inherent to the video industry. Adobe's Eric Philpott explores Adobe's developments in response to the ever evolving challenges we face today.

Editorial
Eric Philpott
Adobe After Effects
Makin' Planets! Saturn (with rings and shadows)

Makin' Planets! Saturn (with rings and shadows)

In this video, Graham shows how to make Saturn's rings using Polar Coordinates, then use an Alpha Invert Matte along with a simple expression to cut the rings out.


Graham Quince
Adobe After Effects
Text Box Background Preset in After Effects

Text Box Background Preset in After Effects

Graham's latest tutorial shows you how to combine several effects to generate a background for any text layer you add to an After Effects comp.

Tutorial
Graham Quince
Adobe After Effects
Makin' An Eclipse

Makin' An Eclipse

In this tutorial for Adobe After Effects, I use the Circle effect, Fractal Noise, Polar Coordinates and CC Light Rays to create a 2D solar eclipse.

Tutorial
Graham Quince
Adobe After Effects
How To Put Yourself In Any Movie Part 3: Keying Greenscreen

How To Put Yourself In Any Movie Part 3: Keying Greenscreen

Following the huge response to parts one and two of independent filmmaker Cody Pyper's Adobe Photoshop and After Effects tutorial series, "Put Yourself In Any Movie!", here is the truly EPIC series finale, which is the most complete single keying tutorial we've ever seen. It's all here, including Red Giant's Primatte Keyer, Premiere Pro's Lumetri Color Panel, AE's Keylight filter, everything you need to know about curves and levels, realistic blurs, shadows and VFX, and more! Did we mention that this is epic? EPIC!


Cody Pyper
Adobe After Effects
Makin' a 3D Nebula in Photoshop, Cinema4DLite, and After Effects

Makin' a 3D Nebula in Photoshop, Cinema4DLite, and After Effects

Graham continues his space tutorial series, featuring the Orion Nebula

Tutorial
Graham Quince
Adobe After Effects
Motion Tracking in After Effects

Motion Tracking in After Effects

During this short video tutorial, Andy Ford shows you how to apply Track Motion to aerial drone footage

Feature
Andy Ford
Adobe After Effects
Free Tablet and Phone Screen Replacement Tracking Images

Free Tablet and Phone Screen Replacement Tracking Images

Here's a giveaway for anyone interested in trying to do a screen replacement for their iPad, iPhone, Tablet or phone.


Graham Quince
MORE
© 2020 CreativeCOW.net All Rights Reserved
[TOP]