(Page 2 of 2 pages for this article  <  1 2)

Saturday, May 01, 2010

Filed under: Post ProductionVisual Effects

Deeper Modes of Expression, Part 5: Comp, Footage, and Layer Attributes

Chris Meyer | 05/01

Grabbing numbers from places such as the comp settings.

Frames and Seconds

Expressions, as well as most effects, think of time in terms of seconds. However, most animators think of time in term of number of frames. You can use comp and footage attributes to automatically translate between the two for you.

After Effects features a pair of expression methods – timeToFrames() and framesToTime() – which make it easy to convert these two ways of representing time. You can enter one, two, or three parameters in the () of these methods. If you enter just one number, it is used as the time or frame number you want to convert from. For example, if you want to know the current frame number of a composition, you would write timeToFrame(time) (as time is always the current time in a composition, in seconds).

If you enter two numbers inside the () for these methods (separated by commas), the first number is still the time or frame number, and the second number is the fps (frames per second) value. This number defaults to the comp’s current frame rate; if you instead wanted to know how the current time in seconds would translate to a frame number if the frame rate was 12 fps, you would write timeToFrames(time, 12).

The third, optional value inside () is known as isDuration; it defaults to false. If instead of an absolute frame or time number, you were calculating the difference between two different values, the result may be negative. (This is where the potential rounding errors we discussed back in the first installment with Math.floor and Math.ceil might creep in.) If you set this value to true, the result will always be rounded away from 0, which is generally what you want. Say you had an expression where you calculated a value – time_difference – that you now wanted to convert to the nearest whole frame, at a rate of 24 fps: You would use timeToFrames(time_difference, 24, true).

A simple example of using one of these methods is shown here. The Echo effect requires you to set its Echo Time as a number of seconds. To compute this as a number of frames, we added a Slider Control where we could set the number of frames. Then for the Echo Time parameter, we wrote framesToTime(, dragged the pick whip to our slider, typed ), and press Enter. The resulting expression is:

In addition to these handy time and frame methods, After Effects also provides a pair of attributes to help us find the duration of a frame, either at the comp’s frame rate, or the source layer’s frame rate:

  • thisComp.frameDuration: the length (in seconds) of one frame, using the comp’s current frame rate
  • source.frameDuration: the length (in seconds) of one frame of the source or precomp, using its own frame rate instead of the comp’s

To convert either of these to a frame rate value, rather than a frame duration, place 1 / before them. For example, 1 / thisComp.frameDuration gives you the comp’s frame rate.

(A complete list of attributes is available as part of the Expression Language Reference section of the After Effects Online Help.)

Next Installment: Managing Time

Continuing the theme of calculating time, the next installment will discuss tricks such as setting up delayed animations using valueAtTime, using indexing to change a layer’s values based on its index in the Timeline, finding the rate at which a value changes, and triggering animations based on markers. Until then…

We’re in the process of serializing the Deeper Modes of Expression bonus chapter from our book Creating Motion Graphics with After Effects into a set of 12 posts here on PVC.

The next edition of Creating Motion Graphics - for After Effects CS5 - is due out by the end of June 2010.

The content contained in Creating Motion Graphics with After Effects - as well as the CMG Blogs and CMG Keyframes posts on ProVideoCoalition - are copyright Crish Design, except where otherwise attributed.

(Page 2 of 2 pages for this article  <  1 2)

               



You must be registered to comment. This is an effort to reduce spam. Please REGISTER HERE.

Name:

Email:

Location:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:




After Effects Apprentice Free Video: Rendering a 4:3 Center Cut Movie from a 16:9 Composition
After Effects Apprentice Free Video: Using Parenting to Animate Layers as a Unit
After Effects Apprentice Free Video: Working with Nested 3D Compositions
After Effects Apprentice Free Video: Copying Paths from Illustrator to After Effects
After Effects CS6 Tutorial: Exporting 3D Camera Tracker Data to Cinema 4D
After Effects CS6 Tutorial: Targeting Properties in the new Ray-Traced 3D Engine
After Effects CS6 (P)Review
After Effects Apprentice Free Video: Exploring Shape Effects
After Effects Apprentice Free Video: Drawing Parametric Shapes
After Effects Apprentice Free Video: The Puppet Starch Tool
After Effects Apprentice Free Video: Eraser Tool Modes
After Effects Apprentice Free Video: Tracking with mochaAE
After Effects Apprentice Free Video: Performing a Motion Track
After Effects Apprentice Free Video: Creating 3D Objects using Adobe Repoussé
After Effects Apprentice Free Video: Understanding Axis Modes
Using After Effects as an Advanced Titler for Premiere Pro
After Effects Apprentice Free Video: Creating an Orbit Camera Rig
CMG Hidden Gems: Chapter 45 – What’s Your Preference?
CMG Hidden Gems: Chapter 44 – Prerendering and Proxies
CMG Hidden Gems: Chapter 43 – Advanced Rendering
CMG Hidden Gems: Chapter 42 – Render Queue
CMG Hidden Gems: Chapter 41 – Video Issues
CMG Hidden Gems: Chapter 40B – 3D Channel Effects
CMG Hidden Gems: Chapter 40 – Integrating with 3D Applications
CMG Hidden Gems: Chapter 39 – Integration 101
After Effects Apprentice Free Video: Multiple Playback Speeds
CMG Hidden Gems: Chapter 38 – Import and Interpret
CMG Hidden Gems: Chapter 37B and 37C – Expressions and Scripting Bonus Chapters
CMG Hidden Gems: Chapter 37 – Expressions
CMG Hidden Gems: Chapter 36B – Audio Effects







After Effects Apprentice: The Final Project

Chris and Trish Meyer | 04/10

The 3+ hour video course on the Final Project from After Effects Apprentice 2nd Edition has finally been released.

As we mentioned awhile back, we’ve been busy the past year and a half creating an extensive, multi-course video training series…

Expression Shorts - Numerical Readout

David Torno | 02/05

Create numerical readouts for use in HUD style graphics.

image

With this Expression, I will show you how to feed numerical property information…

JVC Unveils ProHD Portable Monitor Series

PVC News Staff | 01/30

Can display 480i, 480p, 720p, 1080i, and 1080p video signals at a variety of frame rates

image

JVC Professional Products Company, a division of JVC Americas Corp., today announced the DT-X71 Series of portable ProHD LCD monitors. Ideal for field and studio applications, the new seven-inch AC/DC…

CMG Hidden Gems: Chapter 37B and 37C – Expressions and Scripting Bonus Chapters

Chris and Trish Meyer | 09/02

This time, a collection of resources on expressions and scripting - including a PDF of Bonus Chapter 37C on scripting.

We’re going through our book Creating Motion Graphics with After Effects 5th Edition (CMG5) and pulling out a few “hidden gems” from…

To be considered for listing, contact pr (at) provideocoalition (dot) com


Copyright © 2012, HD Expo, LLC a division of Diversified Business Communications. DBA Createasphere

All rights reserved. HD EXPO, High Def EXPO, Createasphere, E-Tech, Entertainment Technology Exposition, 3D Production Workshop, VariCamp, P2 Camp, ColorCamp 101, and Lighting, Filters & Gels for HD are all trademarks of HD Expo, LLC.

Terms of Use  |  Privacy Policy

Check PageRank