Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Automate keyframe values and align with split markers

  • Automate keyframe values and align with split markers

  • Adam Walker

    April 9, 2021 at 8:49 am

    Hi all,

    I’m working on a karaoke type animation, where text comes onto the screen at the same time as the audio/video.

    I have a script that takes a file containing text/dialogue with time codes, creates a text layer in after effects and places the line of text at specific timecodes along the timeline, the duration of each line of text is automatically referenced using split markers. (see example attached)

    e.g. the first half of the split marker will be placed on the timeline at the point that the line of dialogue starts, the last half of the split marker will be placed further along the timeline at the point where the dialogue finishes.

    I have an opacity text animator with two key frames, the first set at 0% aligned with the first half split marker and the second set at 100% aligned with the second half split marker.

    Currently I am manually applying these keyframes however due to the vast amount of dialogue I’m looking for an automated way to set these two keyframes for an opacity range selector with the values as above and aligned with the split markers.

    Thanks in advance!

  • Andrei Popa

    April 12, 2021 at 12:43 pm

    This will make your text go from 0 to 100 for the duration of each marker on the layer.

    n = 0;
    if (marker.numKeys > 0) {
    n = marker.nearestKey (time).index;
    if (marker.key (n).time > time) {
    n--;
    }
    }
    if (n > 0) {
    t = marker.key (n).time;
    dur = marker.key (n).duration;
    linear (time, t, t + dur, 0, 100);
    } else {
    value;
    }
  • Adam Walker

    April 12, 2021 at 2:54 pm

    Thanks for your response Andrei, though after effects seems to have a problem with line two as I get the following error.

    ” Unable to execute script at line2. marker is undefined “

    I saved your script as a .jsx file and after selecting the text layer executed the script, could this be because the markers are split instead of whole?

    Thanks,

    Adam

  • Andrei Popa

    April 12, 2021 at 5:05 pm

    This is an expression. Will work after you put the markers. Alt+click the stop-watch of the desired property of your layer and write there this code(if it’s something 2d, like size, you need to modify it a bit to work).

  • Adam Walker

    April 12, 2021 at 7:31 pm

    This is a great expression and very close to what I’m looking for (thank you!) however is there a way to set actual key frames at the start and end of the split marker?

    I need to be able to place additional keyframes in between the two main key frames in order to customise the reveal of a word to be sooner or later, so that I can sync the audio with the text.

    Is this possible through an expression?

  • Andrei Popa

    April 13, 2021 at 6:49 am

    I think I understand what you want now. Here is a script that puts keyframes at the start and end of each marker of the selected layer. Select the layer than run this small script.

    var selLayer = app.project.activeItem.selectedLayers[0];
    var prop = selLayer ('ADBE Transform Group') ('ADBE Opacity');
    var markers = selLayer ('Marker');
    for (var i = 1; i <= markers.numKeys; i++) {
    prop.setValueAtTime (markers.keyTime (i), 0);
    prop.setValueAtTime (markers.keyTime (i) + markers.keyValue (i).duration, 100);
    }

    I thought that you wanted this to be responsive aka change when you modify the markers.

  • Adam Walker

    April 15, 2021 at 7:31 am

    This is exactly what I was looking for, thanks for you’re time and expertise Andrei!

Viewing 1 - 7 of 7 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy