Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Marker Names to Text layers

  • Marker Names to Text layers

    Posted by Christoph Heimer on April 20, 2016 at 3:25 pm

    Hi,

    is there a script or an expression for the following case:
    I’m supposed to make a lyric video animation and I set markers in Premiere on every sentence basically, sometimes even separate words.

    It would be soo convenient if there was a way to import that track via copy paste to after effects with all the markers on it (so far it works) and then have text layers generated at the according time for all the layer markers. This has got to be possible somehow? 🙂

    Best,
    Christoph

    Leonardo F. massocco replied 7 years, 2 months ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    April 20, 2016 at 4:47 pm

    It would be a fairly straightforward script to generate text layers from the markers of a selected layer, but would it work to just have one text layer displaying the text of the most recent marker? You could do that with an expression like this:


    m = thisComp.layer("Marker Layer").marker;
    txt = "";
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    if (n > 0) txt = m.key(n).comment;
    }
    txt

    Dan

  • Christoph Heimer

    April 20, 2016 at 5:02 pm

    Hey,

    no this won’t work for me I suppose. I need the quicker access to all the separate text layers so I can just easily move them around in space and scale, maybe change the font etc. It’s so much easier when it’s separate layers then keyframing all this on one layer… So there’s no existing solution for this yet?

  • Dan Ebberts

    April 20, 2016 at 6:09 pm

    Something like this should be close:


    function BuildTextLayers(){
    var myComp = app.project.activeItem;
    if ((myComp == null || ! (myComp instanceof CompItem))){
    alert ("No comp active.");
    return;
    }
    var myLayers = myComp.selectedLayers;
    if (myLayers.length == 0){
    alert ("No layer selected.");
    return;
    }
    var myLayer = myLayers[0];
    var myMarker = myLayer.property("Marker");
    if (myMarker.numKeys == 0){
    alert ("Selected layer has no markers.");
    return;
    }
    var txt;

    for (var i =1; i <= myMarker.numKeys; i++){
    myTextLayer = myComp.layers.addText(myMarker.keyValue(i).comment);
    myTextLayer.startTime = myMarker.keyTime(i);
    }
    }
    BuildTextLayers();

    Dan

  • Dan Ebberts

    April 20, 2016 at 6:11 pm

    That wasn’t quite right. Try this one:


    function BuildTextLayers(){
    var myComp = app.project.activeItem;
    if ((myComp == null) || ! (myComp instanceof CompItem)){
    alert ("No comp active.");
    return;
    }
    var myLayers = myComp.selectedLayers;
    if (myLayers.length == 0){
    alert ("No layer selected.");
    return;
    }
    var myLayer = myLayers[0];
    var myMarker = myLayer.property("Marker");
    if (myMarker.numKeys == 0){
    alert ("Selected layer has no markers.");
    return;
    }
    var txt;

    for (var i =1; i <= myMarker.numKeys; i++){
    myTextLayer = myComp.layers.addText(myMarker.keyValue(i).comment);
    myTextLayer.startTime = myMarker.keyTime(i);
    }
    }
    BuildTextLayers();

    Dan

  • Leonardo F. massocco

    April 2, 2019 at 4:22 pm

    Is there any expression to display the marker text only inside marker duration?

  • Dan Ebberts

    April 2, 2019 at 4:40 pm

    Something like this maybe:


    m = thisComp.layer("Marker Layer").marker;
    txt = "";
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    if (n > 0 && time <= m.key(n).time + m.key(n).duration) txt = m.key(n).comment;
    }
    txt

    Dan

  • Leonardo F. massocco

    April 2, 2019 at 4:58 pm

    Wow! It works perfectly!
    You are the best.

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