Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Jamie Bradshaw on January 9, 2010 at 1:04 pm

    Hi all.

    Can anyone shed any light on why the function below in an expression causes very slow render times?

    Any help would be massively appreciated.

    Thanks,
    Jamie

    //
    // this function returns an array of [prevMarkerIndex, prevMarkerTime, nextMarkerIndex, nextMarkerTime] for markers on any given layer.
    function getMarkerInfo(mLayer1) {
    if (mLayer1.marker.numKeys > 0) {
    nearestMarker = mLayer1.marker.nearestKey(time);
    prevMarkerIndex = nearestMarker.index - (nearestMarker.time > time);
    if (prevMarkerIndex < mLayer1.marker.numKeys) {
    nextMarkerIndex = prevMarkerIndex + 1;
    } else {
    nextMarkerIndex = prevMarkerIndex;
    }
    if (prevMarkerIndex == 0) {
    prevMarkerTime = 0;
    } else {
    prevMarkerTime = mLayer1.marker.key(prevMarkerIndex).time;
    }
    nextMarkerTime = mLayer1.marker.key(nextMarkerIndex).time;
    } else {
    prevMarkerIndex = 0;
    prevMarkerTime = 0;
    nextMarkerIndex = 0;
    nextMarkerTime = 0;
    }
    return [prevMarkerIndex, prevMarkerTime, nextMarkerIndex, nextMarkerTime];
    }

    JimJam•Graphics
    https://www.jimjamgraphics.com/

    Michael Natkin replied 16 years, 5 months ago 3 Members · 10 Replies
  • 10 Replies
  • Dan Ebberts

    January 9, 2010 at 5:29 pm

    There doesn’t seem to be anything in there that should take a lot of time. How are you using it?

  • Jamie Bradshaw

    January 9, 2010 at 6:35 pm

    Hi Dan. Thanks for looking at this for me.

    The rest of the expression was very simple, just using the prevMarkerIndex and prevMarkerTime and nextMarkerTime variables to update a source text property on a text layer. The marker layer was an audio layer that had a lot of markers on (over 1,000).

    The comp is about 6.5mins long at 30fps, so it’s a fairly hefty piece, but still took 17 hours to render on a new mac pro with 12gb of RAM?! Considering there were no more complicated stuff than I’ve already explained I’m pretty flumaxed.

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Michael Natkin

    January 11, 2010 at 7:14 pm

    Ah, in that case the likely culprit is nearestKey. Is it faster when there are less markers?

    Michael Natkin
    Sr. Software Engineer
    Adobe After Effects

  • Jamie Bradshaw

    January 11, 2010 at 9:31 pm

    Thanks for your answer Michael. Is the render likely to get slower as it progresses too? In other words does the nearestMarker function take longer the more markers there are before the current time?

    I guess one solution is to break up the comp onto smaller chunks

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Jamie Bradshaw

    January 11, 2010 at 9:47 pm

    Oops I meant nearestKey not nearestMarker

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Michael Natkin

    January 11, 2010 at 9:59 pm

    I don’t think it should get slower as the current time increases. It uses a binary search to find them. I could also be wrong that that is your problem, it is an unproven but educated guess. Unfortunately if that is true, you would have to divide your comp up a lot to make a signficant difference by reducing the total number of markers per comp. Maybe if you give us the background of why there are 1000s of markers we could suggest a different approach?

    Michael Natkin
    Sr. Software Engineer
    Adobe After Effects

  • Jamie Bradshaw

    January 11, 2010 at 10:19 pm

    Thanks again for your help on this Michael. The reason for me having so many markers is that I’ve developed what I find to be a very good process for using After Effects for making music videos. I use an audio editing package to put all my markers in and then import them into AE to control and manipulate many things. I’d be more than happy to supply you with my project file for this if that helps?

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Michael Natkin

    January 11, 2010 at 10:36 pm

    Not sure there is much I’ll be able to do. Maybe here’s one idea. If you are using that same expression a bunch of times, create a dummy layer (like a NULL) and put that as the expression on some Expression Control properties there. You’d have to modify it to read from the layer you are interested in. Now point all the expressions that use that to pull their value from the other layer. That may give you better expression caching behavior. Again, this is only going to help if you have that same expr repeated on multiple properties of one layer right now.

    Michael Natkin
    Sr. Software Engineer
    Adobe After Effects

  • Jamie Bradshaw

    February 13, 2010 at 12:37 pm

    Hi Michael.

    Just to update (for anyone who might be interested or going through a similar dilemma)

    I took your advice and basically instead of using a Null layer, I’ve used an expression on the sourceText of a text layer to store a data string that holds the index and time of both the previous and next markers as well as the the marker comment. I then extrapolate this data string to use on other expressions. It works a treat!

    It might seem like a convoluted way of going about things, but it’s massively cut down the render time (a previous 8 hours render now down to ~30mins).

    Thanks for your help on this.

    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Michael Natkin

    March 10, 2010 at 9:43 pm

    Hey, I’m really glad to hear that worked out for yoU!

    Michael Natkin
    Sr. Software Engineer
    Adobe After Effects

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