On Moria’s Race Movie I have a lot of shots inside a driving car. And for all of them I wanted a camera shake that is consistent. For the first few shots I made it manually by adding noise modifiers to rotation animation curves. But now I have a script to do this.
# GNU General Public License version 3 or any later
# version as published by the Free Software foundation.
# https://www.gnu.org/licenses/gpl-3.0.html
# This a short script that took me forever to figure out
# to add camera shake into the cockpit of a driving car.
####################################### USAGE ########################################
# Have an object named "Camera" in the scene.
# Add to it at least one key-frame of rotation on each X, Y and Z axis.
# ( If your camera is animated it's good enough, otherwise press I > Rotation ).
# Then copypaste this script into the scripting window.
# If you can't paste, create an empty text first, then paste.
# Besides the name field, on the right, there should be a "play" button. [>] Press it.
# Now you have a camera shake in your shot.
######################################################################################
import bpy
# It works by adding two noise modifiers to each rotation axis. It doesn't touch the location.
# The following numbers I found by trial and error while making shots for Moria's Race.
# noise 1
# scale = 3.0
# strength = 0.01
# noise 2
# scale = 1.1
# strengh = 0.005
# Simple for-loop to do task for each of the fcurves from the object called "Camera".
# NOTE: I assume that your camera is called Camera. If it's not, change the string here.
for n, f in enumerate(bpy.data.objects["Camera"].animation_data.action.fcurves):
# Then I filter out only rotation fcurves. I don't care about location, focus distance, zoom...
# Only fcurves with "rotation_euler" type will have the noise.
if f.data_path == "rotation_euler":
# Creating the first noise
noise = f.modifiers.new(type="NOISE")
noise.scale = 3.0
noise.strength = 0.01
# This is an offset so the noises will not sync up.
# The number is found by hammering on the keyboard at random.
noise.offset = n*2.535081
# Creating the second noise
noise = f.modifiers.new(type="NOISE")
noise.scale = 1.1
noise.strength = 0.005
# Same kind of technique for the offset as in the first noise.
noise.offset = n*1.2168212