Copy link to clipboard
Copied
I'm making a video where I talk to the camera with constantly cycling different lengths of hair. I recorded each scene entirely with different lengths of hair and some scenes have more takes than others. I would like to cycle through each layer (length of hair) changing to the next layer every frame. So far my method has been to have a "layer selector" slider on a separate layer that I animate with a loop expression and then tell each video layer to have this expression so the layer only becomes visible when the slider calls it's number
if(index==Math.round(thisComp.layer("Adjustment Layer 6").effect("Layer Selector")("Slider"))){100}else{0};
But this gets messy when the "layer selector" slider animates from say 2-6 and doesn't align exactly with the frames of the video and we get layers which show slightly longer than others. The frame rate is also something I'd like to experiment with so my goal would really be to have the "layer selector" slider use an expression rather than keyframes. Something like this is what I'm thinking:
var startlayer = 2
var endlayer = 6
var framerate = 3
loop from start to end changing every [framerate] frames
Any help much appreciated!
I think the expression for your layer selector slider would look like this:
startlayer = 2;
endlayer = 6;
framerate = 3;
numLayers = endlayer - startlayer + 1;
currentLayer = Math.floor(timeToFrames(time)/framerate)%numLayers + startlayer;
Copy link to clipboard
Copied
Pre-compose the layers and stagger them accordingly, use time-remapping with posterizeTime() or the Posterize Time effect. Your current approach is going to end up in disaster. The constant changes in the layers would cause render artifacts and in order to address it dynamically it would require a ton of code or "remoting" the layer content to a compositing effect liek Channel combiner so it switches to other layers dynamically, which makes it crash-prone.
Mylenium
Copy link to clipboard
Copied
How are you handling audio sync?
I would probably start in Premiere Pro, syncing the multiple takes close to where the audio overlaps. Premiere will do this automatically. Once you get the audio layers synced up for every few words, you can then stack the layers in After Effects and use a simple expression that changes opacity based on layer index. If you want to see a different layer for every frame, the expression would be:
t = time / thisComp.frameDuration;
if (t == index - 1)
100
else
0
You can adjust the math or fiddle with frame rates to keep each layer visible for more than one frame. If you want each layer to play for 10 frames, the expression would be:
t = time / thisComp.frameDuration;
n = Math.floor(t/10);
if (n == index - 1)
100
else
0
As I said, the hardest part is going to be making sure that the audio stays in sync. Make a comp for every one or two seconds of your video and then render or nest each of the comps to put the whole thing together. That is how I would handle the problem.
Copy link to clipboard
Copied
I think the expression for your layer selector slider would look like this:
startlayer = 2;
endlayer = 6;
framerate = 3;
numLayers = endlayer - startlayer + 1;
currentLayer = Math.floor(timeToFrames(time)/framerate)%numLayers + startlayer;
Copy link to clipboard
Copied
Hah! Dan I just said it in the creative cow forum but you are a genius. This is 10x cleaner than the method I had arrived at minutes before reading this, thank you so much!