Currently I give away all my motion scripts for free. If you've found them useful and would like to support future development, you can do so here →
How to use the script
Always check code before running it on your computer. Even basic scripts like this one. If you’re not a developer, ask a LLM like ChatGPT, Claude, or Gemini to verify it for you.
Option 1: Install to your AE Folder
Download this and install the below .jsx file in your After Effects Script folder. You can then run it using the scripts menu, or by using a launcher like Quick Menu 3.
Option 2: Adapt the script yourself
Alternatively copy the code below and develop your own version. If you’re not a developer you can do this easily with a LLM like ChatGPT.
Camera Rig 1.jsx5.5KB
// Create a new camera
var comp = app.project.activeItem;
if (comp && comp instanceof CompItem) {
var camera = comp.layers.addCamera("Camera 1", [comp.width / 2, comp.height / 2]);
if (camera) {
// Set the camera's zoom level to 10000
var zoomLevel = 10000;
camera.property("ADBE Camera Options Group").property("ADBE Camera Zoom").setValue(zoomLevel);
// Adjust the camera's Z position to offset the increased zoom level
var zPosition = -5333.3 * (10000 / 5333.3);
camera.property("ADBE Transform Group").property("ADBE Position").setValue([1920, 1080, zPosition]);
// Enable depth of field
camera.property("ADBE Camera Options Group").property("ADBE Camera Depth of Field").setValue(true);
// Set aperture to 100 pixels
camera.property("ADBE Camera Options Group").property("ADBE Camera Aperture").setValue(100);
// Set the camera layer color to pink
camera.label = 9; // Pink color label
// Create a new null object for focus
var focusNull = comp.layers.addNull();
if (focusNull) {
focusNull.threeDLayer = true;
focusNull.name = "FocusNull1";
focusNull.source.name = "FocusNull1"; // Change the source name
// Set the focus null layer color to pink
focusNull.label = 9; // Pink color label
// Link the camera's focus distance to the 'FocusNull1'
var focusDistance = camera.property("ADBE Camera Options Group").property("ADBE Camera Focus Distance");
if (focusDistance) {
var focusDistanceExpression =
"var targetLayer = thisComp.layer('FocusNull1');\n" +
"var targetPos = targetLayer.toWorld(targetLayer.anchorPoint);\n" +
"var cameraPos = thisComp.activeCamera.toWorld([0,0,0]);\n" +
"length(targetPos - cameraPos);";
focusDistance.expression = focusDistanceExpression;
}
// Apply expression to restrict Z transformation of the focus null's position
var position = focusNull.property("ADBE Transform Group").property("ADBE Position");
if (position) {
var positionExpression =
"var original = position;\n" +
"[original[0], original[1], 0];";
position.expression = positionExpression;
}
}
// Create a new null object for the camera rig
var cameraRig = comp.layers.addNull();
if (cameraRig) {
cameraRig.name = "CameraRig1";
cameraRig.source.name = "CameraRig1"; // Change the source name
cameraRig.property("ADBE Transform Group").property("ADBE Position").setValue([0, 0, 0]); // Position to top-left corner
// Set the camera rig layer color to pink
cameraRig.label = 9; // Pink color label
// Add a slider control to the camera rig and name it "Zoom"
var zoomSlider = cameraRig.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
zoomSlider.name = "Zoom";
zoomSlider.property("ADBE Slider Control-0001").setValue(10000);
zoomSlider.property("ADBE Slider Control-0001").expression = "clamp(value, 2000, 20000);";
// Add a second slider control to the camera rig and name it "Aperture"
var apertureSlider = cameraRig.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
apertureSlider.name = "Aperture";
apertureSlider.property("ADBE Slider Control-0001").setValue(100);
apertureSlider.property("ADBE Slider Control-0001").expression = "clamp(value, 0, 20000);";
// Add a third slider control to the camera rig and name it "Blur Level"
var blurSlider = cameraRig.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
blurSlider.name = "Blur Level";
blurSlider.property("ADBE Slider Control-0001").setValue(100);
blurSlider.property("ADBE Slider Control-0001").expression = "clamp(value, 0, 1000);";
// Add expression to the camera's zoom property
var zoom = camera.property("ADBE Camera Options Group").property("ADBE Camera Zoom");
if (zoom) {
zoom.expression = 'thisComp.layer("CameraRig1").effect("Zoom")("Slider")';
}
// Add expression to the camera's aperture property
var aperture = camera.property("ADBE Camera Options Group").property("ADBE Camera Aperture");
if (aperture) {
aperture.expression = 'thisComp.layer("CameraRig1").effect("Aperture")("Slider")';
}
// Add expression to the camera's blur property
var blur = camera.property("ADBE Camera Options Group").property("ADBE Camera Blur Level");
if (blur) {
blur.expression = 'thisComp.layer("CameraRig1").effect("Blur Level")("Slider")';
}
}
// Add keyframes at the current time for the camera's point of interest and position properties
var currentTime = comp.time;
var pointOfInterest = camera.property("ADBE Transform Group").property("ADBE Point of Interest");
var position = camera.property("ADBE Transform Group").property("ADBE Position");
if (pointOfInterest && position) {
pointOfInterest.setValueAtTime(currentTime, pointOfInterest.value);
position.setValueAtTime(currentTime, position.value);
}
}
}
What this script does:
- Create camera:
- Set the camera's zoom level to 10000.
- Adjust the camera's Z position to offset the increased zoom level.
- Enable depth of field.
- Set aperture to 100 pixels.
- Set the camera layer color to pink.
- Create focus null:
- Make the focus null a 3D layer.
- Name the focus null "FocusNull1".
- Set the focus null layer color to pink.
- Change the source name of the focus null to "FocusNull1".
- Connect focus to null position:
- Link the camera's focus distance to the 'FocusNull1' using an expression.
- Restrict null z depth:
- Apply an expression to restrict the Z transformation of the focus null's position.
- Add control null with keyframable zoom, aperture, blur level:
- Create a new null object for the camera rig.
- Name the camera rig "CameraRig1".
- Change the source name of the camera rig to "CameraRig1".
- Set the camera rig layer color to pink.
- Add a slider control to the camera rig and name it "Zoom".
- Set the slider range from 2000 to 20000 and its initial value to 10000.
- Add a second slider control to the camera rig and name it "Aperture".
- Set the slider range from 0 to 20000 and its initial value to 100.
- Add a third slider control to the camera rig and name it "Blur Level".
- Set the slider range from 0 to 1000 and its initial value to 100.
- Add expressions to the camera's zoom, aperture, and blur properties to link them to the respective slider controls.
- Name layers:
- Ensure that the focus null and camera rig layers are properly named and their source names are updated.