ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Sync photos with audio

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Johan Bakke
Sync photos with audio
on Nov 14, 2018 at 11:35:10 pm

I'm working with a music video where I want photos to flash by the eights of the song. I have made a click track and converted it to keyframes, so I have the eights as keyframes.

Is there any way I can select all photos and make them sync to the keyframes or do I have to do this manually?

Return to posts index

Walter Soyka
Re: Sync photos with audio
on Nov 15, 2018 at 11:18:53 am

[Johan Bakke] "Is there any way I can select all photos and make them sync to the keyframes or do I have to do this manually?"

Put all your photos in a precomp (let's call it PHOTOS), set the duration of each photo to be one single frame, then use the Sequence Layers Keyframe Assistant [link] to put them all back-to-back with no overlap.

In your main comp, select your PHOTOS precomp layer and enable Time Remapping. (Either go to the Layer menu, select Time, then select Time Remapping, or press the shortcut key Ctrl+Alt+T on Windows, Cmd+Opt+T on macOS).

Alt+click the animation stopwatch for the Time Remap property and paste this expression:
// use the pickwhip to select the layer and property which holds the keyframes we should use to advance the comp
keyframeSource = thisComp.layer("Keyframe layer").effect("Slider Control")("Slider");

// find the index of the closest keyframe to the current time
keyframeIndex = keyframeSource.nearestKey(time).index;

// if the closest keyframe hasn't happened yet (in other words, we're closer to the next keyframe than the last one),
// go back one. We'll hold on the previous keyframe until the next one actually happens
if (keyframeSource.nearestKey(time).time > time){

// if we haven't hit the first keyframe yet, reset our index to the first keyframe's index
if (keyframeIndex < 1) {
keyframeIndex = 1;

// decrement and return the keyframe index. Keyframes are indexed from 1, but frames are indexed from 0

// time remapping expects time in seconds, but we've been counting frames. let's convert and return!

You will need to modify one line: the one that starts with keyframeSource =

Delete the rest of that line, then use the pickwhip to select the property in your timeline that contains the keyframes. Don't forget to add a semicolon at the end of the line.

The precomp will advance one frame for every keyframe in your linked property.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved