Monday 28 January 2013

Play Only Frames with Markers


Play Only Frames with Markers

Suppose you want to achieve a stop motion animation
effect by displaying only specifi c frames of your footage, say

playing only the frames when your actor reaches the apex
of a jump so he appears to fl y or hover.
First enable time remapping for the layer, then scrub
through the Timeline and drop a layer marker at each
frame that you want to include. Finally, apply this expression
to the Time Remap property:
n = marker.numKeys;
if (n > 0){
f = timeToFrames(time);
idx = Math.min(f + 1, n);
marker.key(idx).time
}else{
value
}
In this expression, the variable n stores the total number of
markers for the layer. The if statement next checks whether
there is at least one marker. If not, the else clause executes,
instructing After Effects to run the clip at normal speed. If
there are markers, the expression fi rst calculates the current
frame using timeToFrames(), which converts whatever time
you pass to it into the appropriate frame number. Here,
it receives the current comp time and returns the current
frame number, which is stored in variable f.
Next you need to convert the current frame number to a
corresponding marker index for the frame you actually
want to display. It turns out that all you need to do is add 1.
That means when the current frame is 0, you actually want
to show the frame that is at marker 1. When frame is 1, you
want to show the frame at marker 2, and so on. The line
idx = Math.min(f + 1, n);
calculates the marker index and stores it in the variable
idx. Using Math.min() ensures the expression never tries to
access more markers than there are (which would generate
an error and disable the expression). Instead, playback
freezes on the last frame that has a marker.
Finally, you use the idx variable to retrieve the time of the
corresponding marker. This value becomes the result of

the expression, which causes After Effects to display the
frame corresponding to the marker.


No comments:

Post a Comment