Learn how to stabilize DSLR footage and correct the rolling shutter issues using Adobe After Effects CS4
Sometimes you have shaky footage from a handheld camera or shot from a tripod or other device that needs to be stabilized.
In case of most prosumer and consumer cameras the flaws of the shaky footage are limited to the X and Y offset that is pretty easy to correct. However in case of HDSLRs and other CMOS-based digital cameras the situation becomes more complicated as the rolling shutter effects appear and make it difficult to stabilize the footage using the most popular plugins.
There’s one good combination of plugins helping you to stabilize the shaky footage and solve the rolling shutter issues. These are the Core Melt’s Lock and Load plugin and The Foundry Rolling Shutter Plugin. Unfortunately the price of the RollingShutter Plugin is pretty high (around USD 500). Lock and Load is cheaper (USD 150) and seems to be a good solution. You’ll find the tests and comparison here:
During my recent project, a promo film for Michał Zygmunt, I wanted to use a few shots that were shot using the tripod set on the lever and w/out any stabilization. Pretty shaky and the situation looked difficult, especially because I didn’t have the plugins mentioned above nor the budget for them. So after a short consideration I decided to choose the Jedi Way. I reached back to the math basics and found the solution using a naked Adobe After Effects CS4 and a bit of scripting. The results are pretty pleasing.
So how to correct the rolling shutter effect?
The alpha angle of a straight line (the slope) is calculated as follows:
alpha = arctan ((|x1 - x2|) / (|y1 - y2|))
The scripting expression that we need to apply to the skew effect is as follows (fixed after your feedback):
skewAngle = (radiansToDegrees(Math.atan(
Math.abs(
(motionTracker("Tracker 1")("Track Point 1").featureCenter[0]
- motionTracker("Tracker 1")("Track Point 2").featureCenter[0])
)
/ Math.abs(
(motionTracker("Tracker 1")("Track Point 1").featureCenter[1]
- motionTracker("Tracker 1")("Track Point 2").featureCenter[1])
)
))-a)*(-1)
Where:
The expression needs to be multiplied by a -1 constant as we want to deskew the image by the calculated skew value.
The Math.atan function returns a value in radians, so we need to convert it to degrees using the radiansToDegrees function.
(radiansToDegrees(Math.atan(
Math.abs(
(motionTracker("Tracker 1")("Track Point 1").featureCenter[0]
- motionTracker("Tracker 1")("Track Point 2").featureCenter[0])
)
/ Math.abs(
(motionTracker("Tracker 1")("Track Point 1").featureCenter[1]
- motionTracker("Tracker 1")("Track Point 2").featureCenter[1])
)
))-0)*(-1)
Here are the results. The clip shows the raw, unstabilized and shaky footage, the stabilized footage, and finally the stabilized and deskew footage.
On the last shoot U should just use a good tripod;)
Michał, Thank you for your advice. However I think you missed one detail. Let me explain by posting a small BTS image

I get an error when I paste the script it says “Function Math.athan() is undefined”
Didn’t work for me as well as it did for you… Maybe I got the formula wrong, not sure. I had better results with deshaker. Thanks for posting the tutorial nonetheless.
The code that is posted definitely does not work. It yields an error. I had to check the image to extract the proper formula. I think my problem was the value in red to be copied and inserted into the formula. My number was 0.1 and it didn’t seem to do very much….
OK, I have checked the code and, indeed, there was a syntax error. I fixed it and you’ll find the right code in the post body. Apologies for my mistake.