CC/Transcription via external CSV

Use the CSV file here to modify your transcript/CC and place in your AE project folder.

This After Effects expression script is designed to dynamically update the text content in a text layer based on markers placed on a null layer and data stored in a CSV file. Here’s how it works:

  1. Marker Setup:
    • You create a null layer in After Effects, let’s call it “MARKER-LAYER”. This null layer will hold time markers.
    • The time markers placed on this null layer correspond to specific rows in a CSV file.
  2. Expression on Text Layer:
    • The expression is applied to the source text property of a text layer.
    • It first retrieves the nearest marker on the “MARKER-LAYER” to the current time.
    • Then, it adjusts to ensure that it only considers the most recent marker by decrementing the marker index if the current time is less than the time of the marker.
    • Finally, it returns the index of the marker (or essentially the row number in the CSV file).
  3. Loading Data from CSV:
    • The expression uses footage("cc-data-01.csv").dataValue([0,0 + n]) to access data from the CSV file.
    • [0,0 + n] represents the row index n obtained from the marker, assuming the CSV file is formatted with rows and columns, and the first row and first column are used for indexing.
  4. Dynamic Text Update:
    • When you modify and save the CSV file in Excel or any other editor, the changes are reflected in the After Effects composition because the expression references the data directly from the CSV file.
  5. Vertical Center Alignment:
    • Additionally, there’s a script provided to vertically center align the text layer’s anchor point. This script adjusts the anchor point based on the source rectangle of the text at the current time.

In summary, this setup allows for dynamic updating of text content in After Effects based on the markers placed on a null layer and data stored in a CSV file. It provides a convenient way to manage and update text content within the composition.

The AE Expression below gets applied to the text layer that contains the CC:

//The Following script goes on the empty text layers source text
let timeMarker = thisComp.layer("MARKER-LAYER").marker;
let n = timeMarker.nearestKey(time).index; // get index of the closest key in time on the Marker Layer
if (time < timeMarker.key(n).time) { n--; } // make sure n == most recent key index only
n;

//Convert Source Text to cell number text within the csv file
text.sourceText = footage("cc-data-01.csv").dataValue([0,0 + n]);

Create a Null Layer that will hold the time markers for the CC. The excel/csv rows are associated to the time markers on that Null layer. When you modify and save the CSV in excel, the text will update in the AE comp and you can place a new marker to advance the text in the the CSV row.

To vertically center align your text you can place the following script on the the text layer’s anchor point:

s=sourceRectAtTime();[0,s.top-45+s.height/2]+value
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *