Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Text source using frame number starting at previous marker

  • Text source using frame number starting at previous marker

    Posted by Barend Onneweer on April 3, 2011 at 8:31 pm

    Hi,

    I’d like to create a framecounter that starts at 0 at every comp marker.

    Basically I’ve got an edit that I’d like to put this text layer on top of. I’ve got a marker at each edit point and for each shot I’d like to burn in the frame counter.

    Can this be done using expressions?

    Thanks for any help,

    Barend

    Barend Onneweer replied 15 years, 1 month ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    April 3, 2011 at 10:42 pm

    Like this:


    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n--;
    }
    }
    if (n > 0){
    t = time - marker.key(n).time;
    timeToFrames(t);
    }else{
    0
    }

    Dan

  • Barend Onneweer

    April 4, 2011 at 9:20 am

    Hi Dan, thanks, but I keep getting “0” as the output when I paste this into the source text expression.

    Barend

    Raamw3rk – digital storytelling and visual effects

  • Barend Onneweer

    April 4, 2011 at 9:33 am

    Ah.. waitaminute, it was set to work with layermarkers and I was using comp markers. No problem, it works now.

    Another question.

    Let’s say I’d like to get some more data rendered into text, like source clip names for top layers and comp timecode. I can use multiple text layers of course, but how would I go about combining for instance timecode and the clip frame counter into one?

    Thanks,

    Barend

    Raamw3rk – digital storytelling and visual effects

  • Barend Onneweer

    April 4, 2011 at 10:13 am

    To be more precise: I’ve got this expression working that displays layer name and source name, but how do I get the framecounter to work in this scheme?

    layer_name = "";
    for (i = 1; i <= thisComp.numLayers; i++){
    if (i == index) continue;
    my_layer = thisComp.layer(i);
    if (! (my_layer.hasVideo && my_layer.active)) continue;
    if (time >= my_layer.inPoint && time < my_layer.outPoint){
    try{
    layer_name = my_layer.name;
    }catch(err1){
    layer_name = my_layer.name
    }
    break;
    }
    }

    source_footage_name = "";
    for (i = 1; i <= thisComp.numLayers; i++){
    if (i == index) continue;
    my_layer = thisComp.layer(i);
    if (! (my_layer.hasVideo && my_layer.active)) continue;
    if (time >= my_layer.inPoint && time < my_layer.outPoint){
    try{
    source_footage_name = my_layer.source.name;
    }catch(err1){
    source_footage_name = my_layer.name
    }
    break;
    }
    }

    layer_name + " " + source_footage_name

    Raamw3rk – digital storytelling and visual effects

  • Dan Ebberts

    April 4, 2011 at 11:55 pm

    You should be able to just replace the last line with this (not tested):


    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n--;
    }
    }
    if (n > 0){
    t = time - marker.key(n).time;
    f = timeToFrames(t);
    }else{
    f = 0;
    }
    layer_name + " " + source_footage_name + " " + f

    Dan

  • Barend Onneweer

    April 6, 2011 at 9:42 pm

    Works like a charm… Thanks!

    Greedy as I am I’m now wondering if I can burn in things like the AE project name and possibly the current date… But I’m guessing that expressions don’t have direct access to things like that?

    Barend

    Raamw3rk – digital storytelling and visual effects

  • Dan Ebberts

    April 6, 2011 at 9:55 pm

    I don’t think there’s any way to get the project name, but you can get the current date, like this:

    D = new Date(Date(0));
    dateStr = “” + D.getDate() + “/” + (D.getMonth()+1) + “/” + D.getFullYear()

    Dan

  • Barend Onneweer

    April 6, 2011 at 10:06 pm

    Ha! That’s actually more than I expected, so thanks again. Being able to burn project name into the picture would also be helpful, but this is not bad for a start. Now that I do a lot of work in Assimilate Scratch, After Effects looks somewhat metadata-impaired…

    Barend

    Raamw3rk – digital storytelling and visual effects

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