Welcome to my first tutorial.

It’s going to be a small one but might be useful to those who use a version of After Effects pre CS5.5 (before the Warp Stabilizer was included).

First, an update. This post was written on june 19th 2011 and at that time I was using After Effects CS 5. I now have CS 6 and this version has a new effect called the ‘Warp Stabilizer’. If you want to stabilize a long panning shot it is enough to just drag this effect onto your clip (using just the default settings) and you will end up with a perfectly smooth shot. The effect can be heavy to render depending on your computer but once it is done you can save the project and when ever you load it again, you won’t have to render it again. The effect can be found under Effects -> Distort -> Warp Stabilizer.

Youtube now also has a feature that detects shaky footage and can smooth-en it out for you, although it’s rather crude.

Now back to the original post:

I recently found myself with the following problem. I just came back from holiday and I was editing some footage I shot of the skyline of Oxford filmed from the top of a tower (Carfax tower, to be precise). The footage was all shaky because it was a hand-held shot but I wanted it to look like a scene from the tv series Inspector Morse so I had to stabilize it. Problem was that I couldn’t just track it coz the pan spanned 180 degrees along the horizon so none of the tracking points would stay in view for the whole length of the clip. I tried finding tutorials about this but couldn’t find any that directly addressed this problem so I thought, let’s see if I can tackle this one myself. It didn’t take me too long to find out how to do it and I thought I’d share this methode with you all. Please note: this might not be the only way to do this and I wouldn’t dare to claim that this is the best way to do it. It’s just a methode that worked for me. It got the job done and reasonably easy too so I hope you find it useful.

Here’s how to stabilize a long panning shot in After Effects:

1.  Import the clip (full length) and drag it into the ‘create new comp’ icon. Now activate the Motion Tracker in After Effects. We are going to use the ‘Stabilize Motion’  function of AE’s built in tracker.  Choose to just track the ‘position’. Go to frame 0 (start) in the timeline and set the tracking-point on a high contrast point at the side of your video which will move over the screen. So if the image comes into view from the righthand side you choose a high contrast point at that side of the screen.

2. Track your footage forward until your trackingpoint is about to move off screen. With the layer selected, press ‘Alt+]’ to set the end of layer 1 (out-point) to this point in time. Apply the tracking data to your layer. If all is well you should now see the image on screen stay in one place whilst the frame of your video moves slowly off screen until the screen is totally black. Make sure the Current Time Indicator is set to the last frame of tracked part of your video.

3. Make a new layer with the same footage by once again dragging your video from the project-field into your composition to position 2 (layer 2). Trim the beginning (In Point) of layer two to the end of layer one by selecting layer 2 and pressing ‘Alt+[‘. Now repeat the tracking process again until your tracking-point is about to move off screen. Apply the tracking data to layer 2 and trim the end of the layer to the last tracker-keyframe.

4. Now I’m sure you can see where this is going. You repeat this process until you have tracked the full length of your original clip. You’ll end up with a layer for every completed track you did. Note we didn’t use any ‘Null-Objects’. In fact in AE CS5 it’s not possible to assign tracking data made with the ‘Stabilize Motion’ option, to a null object. You can only apply it to the tracked layer itself.

Sidenote (off topic): For motiontracking with the purpose of sky replacement or adding SFX ellements you use this methode with null objects. Make a different Null for every track you do and then parent the subsequent Nulls to the first Null. Then parent your effects layer(s) to the first null. Job done, your effects will stay in place all through the clip. In Motiontracking you CAN apply the tracking data to a null object.

5. Now go to (select) layer 1 and press ‘P’ for position. Set the Current Time Indicator (CTI) to frame 0 and press the little stopwatch for position to set a keyframe. Now move forward until your image is almost off screen and drag the image back to the middle of your screen. A keyframe will automatically be set at this point in time. Move forward again until the image is almost off screen or until you are on the last frame of layer 1 and once again drag the image back to the middle of the screen. Go over the clip and if at some point you see a big black area appear, pull the video back in place but try to keep the number of keyframes to an absolute minimum. This is very important because more keyframes means more movement of your footage and we want to stabilize it, not see it move around to much. Scale the image up a little by selecting the layer and pressing ‘S’ for scale. Scale up no more then 110% if that should be necessary but a lower value is preferable. If after scaling up there are still black areas to the sides of your image then put a ‘MotionTile’ effect on the layer and increase the output width and height to about 140% and choose mirror edges. That should take care of any black border problems.

Screen Shot

6. Now make sure you scale up all the layers to the same value as you used on layer 1. So select all layers except layer 1, press ‘S’ and set the scale to the same value as layer 1.

7. Select layer one and lower the opacity to 50%. Select layer 2 and go to the first frame of layer 2. Zoom in on the timeline so you can edit frame by frame. Now go back one frame, and pull the In-Point of the layer back one frame so you have an overlap with layer 1 of one frame. Now drag/move the video in layer 2 so it exactly fits over the last frame of layer 1.  Set a keyframe for position on layer 2. Go back to layer 1 and set the opacity back to 100%. Now repeat the action of item 5 and thus go forward in time until the video is about to move off screen and drag it back to the middle of the screen. Repeat this as often as need-be taking care to use as few keyframes as possible.

This should do the trick, as they say. The above steps can be repeated as many times as you need to cover the whole length of your original clip and you should end up with a very smooth pan across the horizon. See the result of my efforts at the beginning of this video I took of Oxford:

Horizontal pan stabilized

There can be differences in the speed of your pan but it’s easier to solve that in your editing program. In the video above, you can see I had some speed differences but I didn’t find it enough of a problem to correct it but if it is a problem in your clip then note down the times at which the speed differences begin and end from looking at the timeline in After Effects and then in (for example) Premiere Pro, do a razorblade cut at those times and use the ‘Rate-Stretch’ tool to speed-up or slow-down your footage by pulling it to make it shorter or longer. That should easily take care of that.

Well, I hope this was useful to you. If it was then please give me some feedback by commenting or sending me a message.

Thank you and good bye!!