programming4us
 
Graphics
 

Adobe After Effects CS5 : Expressions - Time Remapping Expressions

6/19/2013 7:41:42 PM

There are many ways to create interesting effects with time remapping expressions. You’ve already seen one (the last expression in the previous section). Here are a few more illustrative examples.

Jittery Slow Motion

Here’s an interesting slow-motion effect where frames 0, 1, 2, and 3 play, followed by frames 1, 2, 3, and 4, then 2, 3, 4, and 5, and so on. First, enable time remapping for the layer and then apply this expression to the Time Remap property:

cycle = 4;
f = timeToFrames();
framesToTime(Math.floor(f/cycle) + f%cycle);

The first line sets the value of the variable cycle to the number of frames After Effects will display in succession (4 in this case). The second line sets variable f to the frame number corresponding to the current comp time. Next comes a tricky bit of math using JavaScript’s Math.floor() method and its % modulo operator. The result is a repeating sequence (whose length is determined by the variable cycle) where the starting frame number increases by 1 for each cycle.

Wiggle Time

This effect uses multiple copies of the same footage to achieve a somewhat creepy echo effect. This effect actually involves three short expressions: one for Time Remap, one for Opacity, and one for Audio Levels. First, you enable time remapping for the layer. Then apply the three expressions and duplicate the layer as many times as necessary to create the look you want (Figure 1).

Figure 1. The time-wiggling effect with multiple layers.


Note that this time-wiggling effect is interesting, even with a single layer. The Opacity and Audio Levels expressions are necessary only if you want to duplicate the layer.

The expression for the Time Remap property is

Math.abs(wiggle(1,1))

wiggle() is an extremely useful tool that can introduce a smooth or fairly frenetic randomness into any animation, depending on your preference. wiggle() accepts five parameters, but only frequency and amplitude are required. Check the After Effects documentation for an explanation of what the remaining three optional parameters do.

The first parameter, frequency, represents the frequency of the wiggle in seconds; wiggle(1,1) varies the playback speed at the rate of once per second. The second parameter is the amplitude of the wiggle, given in the units of the parameter to which wiggle() is applied, which in this case is also seconds. So, wiggle(1,1) lets the playback time deviate from the actual comp time by as much as one second in either direction.

You use Math.abs() to make sure that the wiggled time value never becomes less than 0, which would cause the layer to sit at frame 0.

The Opacity expression gives equal visibility to each layer. Here’s what it looks like:

(index/thisComp.numLayers)*100

This is simply the ratio of the layer’s index divided by the total number of layers in the comp, times 100%. That means if you duplicate the layer four times (for a total of five layers), the top layer will have an Opacity of 20%, the second layer will have an Opacity of 40%, and so on, until the bottom (fifth) layer, which will have an Opacity of 100%. This allows each layer to contribute equally to the final result.

If the footage has audio, you have a couple of choices. You can turn the audio off for all but one of the layers, or you can use an expression for Audio Levels that normalizes them so that the combined total audio level is roughly the same as it would be for a single layer. I think the second option enhances the creepiness of the effect; here’s the Audio Levels expression for a stereo audio source (for a mono source you could just leave out the second line of the expression):

db = -10*Math.log(thisComp.numLayers)/Math.log(10);
[db,db]

This is just a little decibel math that reduces the level of each layer based on how many total layers there are (using the comp attribute numLayers). You’ll also notice a couple of JavaScript elements you haven’t encountered before: Math.Log() and an array (the second line of the expression). In expressions, you specify and reference the value of a multidimensional property, such as both channels of the stereo audio level, using array square bracket syntax.

Random Time

In this example, instead of having the time of each layer wander around, the expression offsets each layer’s playback time by a random amount. The expression you need for the Time Remap property is

maxOffset = 0.7;
seedRandom(index, true);
time + random(maxOffset);

The first thing to notice about this expression is the use of seedRandom() and random() and the relationship between these functions. If you use random() by itself, you get a different random number at each frame, which is usually not what you want. The solution is seedRandom(), which takes two parameters. The first is the seed. It controls which random numbers get generated by random(). If you specify only this parameter, you will have different random numbers on each frame, but they are an entirely new sequence of numbers. It’s the second parameter of seedRandom() that enables you to slow things down. Specifying this parameter as true tells After Effects to generate the same random numbers on each frame. The default value is false, so if you don’t specify this parameter at all, you get different numbers on each frame. It’s important to note that seedRandom() doesn’t generate anything by itself. It just defines the subsequent behavior of random().

Here’s an example. This Position expression randomly moves a layer to a new location in the comp on each frame:

random([thisComp.width,thisComp.height])

Close-up: More About random()

There are several ways to use random(). If you call it with no parameters, it will generate a random number between 0 and 1. If you provide a single parameter (as in the Random Time example), it will generate a random number between 0 and the value of the parameter. If you provide two parameters, separated by a comma, it will generate a random number between those two parameters. It’s important to note that the parameters can be arrays instead of numbers. For example, this expression will give you a random 2D position somewhere within the comp:

random ([thisComp.width,
thisComp.height])

In addition to random(), After Effects provides gaussRandom(), which operates in much the same way as random() except that the results have more of a Gaussian distribution to them. That is, more values are clustered toward the center of the range, with fewer at the extremities. Another difference is that with gaussRandom(), sometimes the values may actually be slightly outside the specified range, which never happens with random().


This variation causes the layer to stay in one random location:

seedRandom(1,true);
random([thisComp.width,thisComp.height])

This version is the same as the previous one, except that it generates a different, single random location because the value of the seed is different:

seedRandom(2,true);
random([thisComp.width,thisComp.height])

Let’s get back to the Time Remap expression. The first line creates the variable maxOffset and sets it to the maximum value, in seconds, that each layer’s playback time can deviate from the actual comp time. The maximum for the example is 0.7 seconds.

The next line tells After Effects that you want the random number generator (random()) to generate the same random number on each frame.

The last line of the expression calculates the final Time Remap value, which is just the sum of the current comp time plus a random offset between 0 and 0.7 seconds.

Next, you would apply the Opacity and Audio Levels expressions from the wiggle() example so that each layer’s video and audio will be weighted equally. Duplicate the layer as many times as necessary to get the effect you like.

 
Others
 
- Adobe After Effects CS5 : Expressions - Using Markers
- Adobe After Effects CS5 : Expressions - Looping Keyframes
- Adobe Fireworks CS5 : Fireworks and Flash (part 2) - Importing a flattened bitmap
- Adobe Fireworks CS5 : Fireworks and Flash (part 1) - Importing Fireworks documents into Flash
- Adobe Flash Professional CS5 : Working Within the Flash Environment - Working with Page Setup in Macintosh
- Adobe Flash Professional CS5 : Working Within the Flash Environment - Setting Warning Preferences
- Adobe Flash Professional CS5 : Working Within the Flash Environment - Setting Text Preferences, Setting Clipboard Preferences
- QuarkXPress 8 : Special effects for pictures - Exporting modified pictures, Managing imported pictures
- QuarkXPress 8 : Special effects for pictures - Making adjustments, Applying filters
- Adobe InDesign CS5 : Working with Objects and Layers - Shearing Objects
 
 
REVIEW
 
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
 
VIDEO TUTORIAL
 
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
 
Top 10
 
- How To Install Android Market & Google Apps On Kindle Fire
- How To Make Ubuntu Look Like Windows 7
- How To Add A New Account in MS Outlook 2013
- Get Android & Mac OS X Style Gadgets For Windows 7 & Windows 8 With XWidget
- How To Activate Microsoft Office 2013
- How To Install Actual Facebook App On Kindle Fire
- How To Create, View And Edit Microsoft Office Files On Kindle Fire
- Download Attractive Business PowerPoint Templates For Free At SlideHunter
- How To Use And Enable Hibernate & Sleep Mode In Windows 8
- How To Get Microsoft Office 2013 Trial Product Key From Microsoft