FORUMS: list search recent posts

digital dolly zoom following tracking points...

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Iacopo Boccalari
digital dolly zoom following tracking points...
on Jul 27, 2016 at 1:33:40 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];


Return to posts index

Dan Ebberts
Re: digital dolly zoom following tracking points...
on Jul 27, 2016 at 5:55:44 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



Return to posts index

Kalle Kannisto
Re: digital dolly zoom following tracking points...
on Jul 28, 2016 at 8:03:36 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.


Return to posts index


Iacopo Boccalari
Re: digital dolly zoom following tracking points...
on Jul 28, 2016 at 8:23:44 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


Return to posts index

Iacopo Boccalari
Re: digital dolly zoom following tracking points...
on Jul 28, 2016 at 8:25:48 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!


Return to posts index

Iacopo Boccalari
Re: digital dolly zoom following tracking points...
on Jul 28, 2016 at 8:36:04 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];


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]