Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions digital dolly zoom following tracking points…

  • digital dolly zoom following tracking points…

    Posted by Iacopo Boccalari on July 27, 2016 at 1:33 pm

    Ok, so my question is:
    I have a 4k footage and my output is going to be 1080, this allows me to do a dolly zoom effect in post by cropping.
    Animating scale with simple keyframes is very easy and effective, but my aim is to keep the size of the object I’m dollying towards perfectly constant.
    My idea is tracking two points of the object, they will get further or closer depending on the camera movement.
    Is there a way to use the distance between those two points to determine the exact amount of zoom I need?

    What I came up with is the attached expression

    pA and pB are two nulls tracked to the two furthest point on the object, the rest is easy to understand.
    The tricky part is that 543.8 … This is the maximum distance between the two points and of course explicitly putting that value in the expression is very dumb as I’d have to edit the expression every time I use it on something different.
    So the question is… is there a way to get the maximum or minimum value of “dist” in the whole timeline and use it as a parameter? I guess the answer is no, but it’s worth trying

    pA = thisComp.layer("A").transform.position;
    pB = thisComp.layer("B").transform.position;

    dist = length(pA, pB);

    scale = 543.8/dist*100;

    [scale, scale];

    Iacopo Boccalari replied 9 years, 9 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    July 27, 2016 at 5:55 pm

    I haven’t tested this, but it should give you the max distance. I maybe slow though, if your comp is long:


    pA = thisComp.layer("A").transform.position;
    pB = thisComp.layer("B").transform.position;
    dist = 0;
    t =0;
    while(t < thisComp.duration){
    dist = Math.max(dist,length(pA.valueAtTime(t),pB.valueAtTime(t)));
    t += thisComp.frameDuration;
    }

    Dan

  • Kalleheikki Kannisto

    July 28, 2016 at 8:03 am

    I would think you should be able to track the motion of the object with “scale” turned on, apply the tracking to the footage and then delete position keyframes.

  • Iacopo Boccalari

    July 28, 2016 at 8:23 am

    Yes, normally I can use “Stabilize Motion” in the tracker tab and only select scale, but this time I really need 2 nulls to control the effect

  • Iacopo Boccalari

    July 28, 2016 at 8:25 am

    WOW!!
    Thanks a lot, really! I’m no expert in ae expressions and simply assumed expressions could only consider the “here and now”.

    The while function you showed me clearly proves I was wrong!

  • Iacopo Boccalari

    July 28, 2016 at 8:36 am

    So here is the final expression.
    It gets the distance at any given time and the maximum distance in the whole timeline

    pA = thisComp.layer("A").transform.position;
    pB = thisComp.layer("B").transform.position;

    NowDist = length(pA, pB);

    MaxDist = 0;
    t =0;
    while(t &lt; thisComp.duration){
    MaxDist = Math.max(MaxDist,length(pA.valueAtTime(t),pB.valueAtTime(t)));
    t += thisComp.frameDuration;
    }

    scala = MaxDist/NowDist*100;

    [scala, scala];

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