Want to import audio markers in After Affects? Let me ease your pain.

Problem: I have a composition in Adobe After Effects (AE) and audio track with people speaking, which have to be synced. Well, what I don’t have is an easy way to import markers into Adobe After Effects (AE) to make syncing easier. Dealing with audio in AE can be painful, especially if you have to manually create markers during RAM preview – the only option to actually hear the sound during preview!… You know the pain, don’t you?

Surprise: After extensive search on the web I found … nothing useful. I was surprised, too. It was time for me to dive into  scripting.

Solution: Good news, days of hitting keyboard for adding markers during RAM preview are over! All we need is a tiny script that reads tab separated file with timings and (marker) labels from Audacity and adds markers to a layer in a composition in AE. As simple as that.

Note: I’m assuming you’re familiar with AE workflow and basic concepts of animating in AE… and some basic scripting. :) If you’re not, try reading a tutorial or two on these topics first.

Follow me through few steps to your audio-marker freedom:

0. Download and install Audacity. Audacity is beautiful “free, open source, cross-platform software for recording and editing sounds”. It is  amazing alternative to expensive pieces of software for audio editing. If you already have it, you’re audio-smart! :)

1. Import your audio track into Audacity project and add new Label track (Tracks>Add new>Label Track). Click on label track at desired location and add label(s) (markers) at selected position(s) either via menu Tracks>Add Label at Selection or keyboard shortcut (OS-dependent). Try it, it is quite simple.You can also define text for your label. You should get something like this (e.g. three labels added):

Btw. Moving back and forth on a timeline in Audacity is… beautifully simple and fast.

2. When you have your labels all set, export them into text file using menu File>Export Labels. You can check the contents of the file in any text editor. These are the lines with tab separated values in my case (bold values are the ones we need in AE):

0.534059 0.534059 intro
1.428027 1.428027 Joe laughs
2.020136 2.020136 Jane singing

3. Now you are ready for the big guns. Open your composition in AE. Beware: the script will add markers to the first layer in open (active) composition. Make sure you have a layer there. :)

4. Go to File>Scripts>Open Script Editor, create new JavaScript file and copy/paste following code:

var aFile = File.openDialog ( 'Select text file with timings:', '*.txt', false ) ;
var timings = loadTimings(aFile);

//list of compositions
var compList = app.project.items;

if(compList.length > 0) {

  //1. take the first composition OR
  //var currentComposition = compList[1];

  //2. take currently active composition
  var currentComp = app.project.activeItem;

  if(currentComp.layers.length > 0) {

    //take the first layer of the active composition
    var markerLayer = currentComp.layer(1)

    for (var i = 0; i < timings.length; i++) {            
      marker = timings[i].split('t');              
      var marker_label = "";              
      if(marker.length > 2) {
        marker_label = marker[2];
      markerLayer.property("Marker").setValueAtTime(marker[0], new MarkerValue(marker_label))
  else {
    alert("No layer in this composition. Create a layer first. It can be a Null Object layer.");
else {
    alert("No composition in the project. Create a composition first. Its duration should be equal or longer than the end timestamp of the last marker.");

//loads markers from Audacity text files with labels
function loadTimings(filePath) {

  var timings = new Array ( ) ;

  var fileObj = File(filePath);
    if ( ! fileObj.exists ) {
  return timings ;

  try {

    while(! fileObj.eof) {
    var currentLine = fileObj.readln();
  catch (errMain) {
  return timings;

P.S: Copy-paste might be the fastest way in comparison to saving file to god-knows-which-location-on-disk-depending-on-os-you-have. Just save your file where it suits you.

5. Run it either directly from ExtendScript Toolkit editor or save it and run it from AE via File>Scripts>Run Script from File or …

6. Enjoy the beauty of added markers in your composition. :) Don’t forget to add audio into your composition.


UPDATE [28 May 2013]:  Script has changed. Now it checks whether you have a composition (and layer) in the project. I also prepared a sample AE project, file with labels and the script in text format (download *.zip). Unpack the archive, open the project, copy the script in Script Editor and play with it using the label file provided. It works for AE CS5.

Enhanced by Zemanta

9 thoughts on “Want to import audio markers in After Affects? Let me ease your pain.

  1. You, sir… saved my day. I cannot understand how poor is that audio management in AE. I was fed up of ram previews and wasting my time in an useless way.

    Unfortunately for me I’m not good with scripting so finding your article is like water in the desert.

    Thank you very much!

  2. Ok, I see what it happened. Your CMS has changed the symbols for the CDATA equivalent in HTML < and > in lines 5 and 8.

    Additionally I still have error messages when script tries to read the first line of the audition document. “Unable to execute script at line 11. After Effects error: Unable to call ‘setValueAtTime’ because of parameter 1.4,9788724,97882 cua is not a number”

    What seems to happen here is that instead of taking only the first number it takes the whole line (in point, out point and label text) as if it was a number.

    Cannot help more than that. Hope you can fix it because this script is a must have!

  3. Hi Zapa, thanks for your comments and for pointing out the errors: yeah, this was due some plugin I used to display code. I fixed it so the code should be ready to copy-paste as it is. I tried it in a new project.

    Now to the other problem you’re having: can you paste here a few lines of your file with markers? Without it I’m not able to help.

    Please note that script provided here works *only* for markers exported with Audacity, which has specific file format – marker_start, marker_end and marker_label separated with tabs. I’m guessing your file was exported from some other software. Was it?

  4. I try the script from AE and get no results. Running the script in ExtendScript Toolkit, I added some lines to try and help debug (see below) and it chokes on “var markerLayer = app.project.item(1);” saying “undefined is not an object”. At the bottom is my label data from audacity.

    var aFile = File.openDialog ( ‘Select text file with timings:’, ‘*.txt’, false ) ;
    var timings = loadTimings(aFile)
    var markerLayer = app;
    var markerLayer = app.project;
    var markerLayer = app.project.item(1); //script chokes here
    var markerLayer = app.project.item(1).layer(1);

    ————— LABEL DATA.txt ——————-

    0.525657 0.525657 Donald Norman
    5.710300 7.171074 The Design of Everyday Things
    9.716362 9.716362 The term affordances
    11.973923 11.973923 and actual
    14.674142 14.674142 primarily those
    16.776772 16.776772 determine
    18.790869 18.790869 used
    22.155077 22.155077 affords sitting

  5. The error suggests you have no composition in your project…. I created a new project with a new composition and added a Null Object layer. Next I copied/pasted script in the Script editor and ran it. I was able to import your labels without error… I only tested this in AE CS5.
    I have also updated the script (now it warns you if you have to composition and/or label) and provided a sample project with your labels (download *.zip).

    Try the new script and check the sample project. If this doesn’t work, I can take a look at your project…

  6. Awesome. Will try tonight. It might also be that I have something like a dozen comps in the project.

Leave a Reply

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