Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions access the velocity of a 3D camera via expression

  • access the velocity of a 3D camera via expression

    Posted by Noah Wankner on February 9, 2012 at 6:46 pm

    Hello Guys,

    I already posted this question in the After Effects Forum, but I was sent here 🙂

    I really hope someone can help me with this, I have an idea of what i want to do, but since the only expressions I’ve ever used are wiggle and smooth, I have no idea of how to accomplish this!

    I’m currently working on a steadycam-shot, but it still isn’t steady enough, so one thing i’m doing is of course stabilising the position of the picture. But what I also want to do is stabilizing the velocity of the movement, because you can still see the steps of the operator.
    So I tracked the camera and now my idea was to link the velocity (the difference between let’s say the cameraposition 3 frames before minus the cameraposition 3 frames after the current frame) of the solved 3D-camera to the frame rate in Twixtor or Kronos. So when the camera moves slowly, the frame rate will speed up.

    Has anyone got an idea on how to do this? That would be really really great!

    Thanks for your help!
    Noah

    Immanuel Morales replied 14 years, 2 months ago 2 Members · 11 Replies
  • 11 Replies
  • Immanuel Morales

    February 12, 2012 at 4:27 pm

    yea you just need a variable to contain the speed in the effect. use “.speed” to access the speed of an animated property.

    posSpeed = thisComp.layer("Camera").transform.position.speed;
    poiSpeed = thisComp.layer("Camera").transform.pointOfInterest.speed;
    var totalSpeed = posSpeed+poiSpeed;

  • Noah Wankner

    February 19, 2012 at 7:15 pm

    Alright, thanks for the help, that was what i was searching for.

    But it seems like what i’m trying to do is much more complicated than I thought it would be. The problem is: By connecting the playback speed of twixtor to the speed of my 3D-camera, after the first frame nothing fits anymore because the playback speed was adjusted, so frame 2 is not frame 2 of my original footage anymore.
    An example to make clear my problem: if my expression adjusts the playback speed to 50% on the first 9 frames, the 10th frame is the 5th frame of my original footage, so i also have to look at the camera speed at frame 5 and not frame 10.

    I tried to fix this problem by summing up the playback-speed-values in order to calculate the frame, at which the expression looks at the cameraspeed, but it seems i’m doing something wrong.
    I heard the expression language is based on javascript, so I tried a for-loop, maybe that’s my mistake? Is this even possible in After Effects?

    This is my latest try (it also gives me an error in the last line, but i don’t know why):

    (explanation: the values of the camera-speed are saved in the v_cam-slider and my project is in 50fps, that’s were the 0.02 come from.)

    My brain really hurts of thinking of this stuff, it would be so great if someone could try helping me with this!!!

    Thanks, Noah

    x = thisComp.layer("values").effect("x")("slider");

    timeSum = 0;

    for (i=0; i<time; i=i+0.02){
    timeSum= timeSum+((effect("Twixtor")("Speed %").valueAtTime(i))/100);
    }

    (x/(thisComp.layer("Werte").effect("v_cam")("slider").valueAtTime(timeSum*0.02)));

  • Immanuel Morales

    February 19, 2012 at 8:13 pm

    Ok clearly your head has exploded.. Put it together and think simply first lol.

    First off, let’s just be clear here. You ARE trying to distort time, right? If that is the case, then it is to be expected that the frames will not match anymore because they have been offset by twixtor. If you slow down time, your footage will be longer. You speed it up, it will be shorter.

    Secondly, there is no need for loop expressions in AE unless you’re scripting or making a plugin. This is because of the time object which you have called with the keyword “time”. In AE all expressions are re-evaluated on EVERY FRAME. So every expression is inevitably a ‘loop’ by definition and the “time” value increments by a value of 1.0 on every frame no matter what. See if you can design an expression with that in mind.

    Also, if the clip length is giving you problems then you could keyframe the twixtor speed% to anchor the beginning and ending of the clip. btw, i’ve never heard of someone adjusting playback speed to fix tracking – just saying you might find out that it doesn’t work.

    Lastly, If you’re getting this complex with camera stabilization, I’d say you might be biting off more than it’s worth. Have you considered the Warp Stabilizer?
    https://tv.adobe.com/watch/cs-55-production-premium-feature-tour-/stabilize-shaky-footage-with-the-warp-stabilizer-in-after-effects-cs55/ It’s the latest in stabilization technology, using 3D point cloud camera tracking and intelligent warp distortion. There is a known artifact when it’s pushed to the extreme (think looking through a fishtank), but it may be worth it if the shot is that bad.

  • Noah Wankner

    February 19, 2012 at 8:38 pm

    it clearly has 🙂

    but the thing is – in order to find out where a frame went because of the time distortion, i have to know the time distortion of ALL the frames before, i do not see another way. And to achieve that, i need a loop, which adds all the speed% of all frames before, so i know where i am in time. I really don’t see a simpler way. So the question is – is it even possible in After Effects?

    The clip length is not a problem, to adjust that is pretty simple compared to that other stuff. And I don’t want to fix my camera-track, it’s the movement of the real camera when we shot the scene, that was too inconsistent in speed. Or is that what you mean when you say “tracking”?

    I also tried the Warp Stabilizer, but there’s to much paralax in the shot, it totally messed up.

    Thanks for your help!
    Noah

  • Immanuel Morales

    February 19, 2012 at 9:05 pm

    Alright, well if you really need a frame reference, try plugging your distorted time result into the source text of a text layer and just throw it down by the lower left of the screen. Would that help?

  • Noah Wankner

    February 19, 2012 at 9:37 pm

    sorry i don’t get how this could help?

  • Immanuel Morales

    February 19, 2012 at 9:46 pm

    Well if I’m understanding (probably not), you simply need to know what frame is being shown at any given time – is that right? So I am just recommending that you use the source text of the text layer to display the result of the time distortion. for instance if you were at 150% speed, then at frame 10 in the comp you are at frame 15 in the footage. You just need that displayed at all times, right? to do that, you would simply put this into the source text.. “time*1.5” or if your twixtor settings were at 50% speed then you could put in “time*.5” etc. I imagine I’m just missing something that you’re trying to get across. Anyway, I hope that fixes it!

  • Noah Wankner

    February 19, 2012 at 9:57 pm

    okay i think i understand now what you mean. But this will not work because the cameraspeed is different every single frame and so is the twixtor-speed. so if at frame 10 the speed is 150% it could still be any frame because you don’t know which speed the frames before had.

  • Immanuel Morales

    February 19, 2012 at 10:13 pm

    ah.. then what you’ll have to do is plug the speed % into a variable. that way the “time*1.5” isn’t fixed, and it’ll vary with the animated speed %. so something like this..

    velocity = effect("Twixtor")("Speed %")/100;
    time*velocity;

  • Noah Wankner

    February 20, 2012 at 7:43 pm

    but then the time still doesn’t regard the frames before. still when the speed is at 150%, the time only refers to this value, so it’s like the whole clip to this point was at 150%, which was not the case.

    i kind of almost solved the problem with a loop, but then again i have another problem. But i posted that problem in a new thread, because the question how to access the velocity of a 3D camera has been solved long ago 🙂 So thanks again for your help with this!

    Greets, Noah

Page 1 of 2

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