Data-driven animations are created using live data collected from various data sources that drive animations in your composition. You can use data from multiple data sources. The data can be static or time-varying. You can import the data into your After Effects project and use it as input that can animate graphs, characters, control visual effects and movie titles, and other motion graphics.
You can use data from almost every possible source such as:
- Device Generated Data Files – Data from devices such as fitness trackers that record activity through sensors and store them in different file formats. This time-varying data includes - speed, altitude, distance, heart rate, and various other parameters of user activity.
- User Generated Static Data – Global static data such as survey results that can be changed to drive graphics. A user created data file could provide a workflow for global data.
- URL – Live data from websites such as entry and exit path of a user navigating through a web page.
- Metadata - Data embedded in Video File Metadata.
You can import data files in the following formats:
If you have data files in other formats, convert them to any of the supported import file formats and import into After Effects project. There are various conversion tools available to convert data files into After-Effects-supported formats.
You can import a standard JSON file into After Effects as footage and the data files work in the background. After Effects directly references the data in these data files to drive animations within projects. JSON footage is not represented as data streams in the Timeline panel. You can reference the data using expressions as an evaluated JSON object.
You can modify the expressions to change how data is referenced. You can write the data in a text editor, referenced by After Effects to drive animations. JSON support is based on the JSON schema, which specifies and defines how an application uses and modifies JSON data.
JSON's basic data types are:
- Number: A signed decimal number.
- String: A sequence of zero or more Unicode characters.
- Boolean: Either of the values true or false.
- Array: An ordered list of zero or more values.
- Object: an unordered collection of name or value pairs where the names (keys) are strings.
- Null: An empty value, using the word ‘null’.
You can import a MGJSON data file as footage in your project. When you add data footage to a composition, data property streams are grouped into a top-level group "Data". The Data group displays footage data as Properties. Each property in the data group is expression linked back to the footage file that access the data file value using the expression footage("foo.mgjson").dataValue(N). Here N is the path to the data stream in the file. MGJSON works based on a schema, which is designed to simplify referencing and importing data streams in After Effects.
Each individual data property has an expression applied which links that property to the data in the MGJSON file. If the source MGJSON file is changed, the data property values are automatically updated.
In the Timeline panel, you can twirl open the Data layers and use the pick-whip to link parameters to other parameters. The changes are automatically populated.
You can also convert the data samples from the data file into keyframes. To convert into keyframes, follow these steps:
After keyframe conversion, the data is no longer live and is not referenced from the data file.
You can also view live data as a graph in the Graph Editor. To view, click the Graph Editor icon in the Timeline panel.
Data-driven animation uses expression reference. For more information, see Data-driven animation (expression reference).
The Layer > Time > Align Video to Data command offsets video layers by various frames, as specified in an mgJSON file. You can use this command to align video in time to data samples stored in a matching mgJSON file. For example, if you captured data during a race, but the start time of the video does not match the start time of the captured data, you can specify the offset so that the data is automatically aligned.
To align video in time to mgJSON data, use the following steps:
For this to work, the mgJSON file must contain a videoSyncTimeList group that contains:
- The name of one or more target layers (fileName)
- The number of frames to offset (frameNumber) those layers from the start of the data layer.
A fileName value must be the layer name of a selected layer, not the the source name of the layer. If you change the name of a layer with a source in your composition, for example - rename the layer "sample1.mp4" to "Race Camera 1", you also need to change the fileName value in the mgJSON file to match. Layers referenced by fileName do not have to be footage items with a source file, they can also be solids, nested compositions, or other layer types.
Positive frameNumber values offset the target layer to the left (before the data layer). Negative frameNumber values offset the target layer to the right (after the data layer). A frameNumber value of 0 aligns the start of the target layer to the start of the data layer.
You can import Comma-separated value (.csv) and Tab-separated value (.tsv or .txt) files as footage into After Effects and use them as data sources. CSV and TSV files store tabular data in plain text format with values separated either by comma characters or tab characters. The CSV and TSV data files work similar to how the JSON files work.
To use CSV or TSV data files in After Effects, follow these steps:
In the Timeline panel, twirl open the properties of the footage. Link the data properties of the layer in the composition to another layer with the expression pick whip or the Property Link pick whip. To open the expressions text field, hold Shift and click the timer icon against the name of the layer. You can also link the data properties through the Edit > Copy With Property Links command .
To learn about layer data properties in the Timeline, see Basics of Data properties.
To reference the data footage file, use an expression on the property that you want the data to drive. Use the dataValue() footage attribute to read the data from a specified row and column. Rows and columns are zero-indexed. For example, footage("sample.tsv").dataValue([15,1])returns the value on row 16 of the second column.
When you add a JSON, CSV, or TSV file to a composition and open their properties, they contain only a Data properties group, instead of the Transform properties group. The Data properties group contains the hierarchy of data as defined in the file.
This data group is similar to how After Effects treats Motion Graphics JSON (.mgJSON) files. The difference is that JSON, CSV, and TSV can only contain static data values, while mgJSON can contain dynamic data (data that changes over time).
Each individual data property has an expression applied which links that property to the data in the JSON, CSV, or TSV file. If you change the source data file, the data property values reflect the change.
If you do not wish to write complex expressions, you can use the Property Link pick whip or the Edit > Copy with Property Links command to link th data properties to properties of other layers. As you link the layers, the Property Link pick whip automatically writes expressions for you.
While you work with Data-driven animations in After Effects, you can run into a few issues. For a complete list, see known issues with Data-driven animations.