Skip to content

Instantly share code, notes, and snippets.

@zlovatt
Last active January 19, 2022 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zlovatt/7c74c7d7ecd5496ce2192236fdd0ec66 to your computer and use it in GitHub Desktop.
Save zlovatt/7c74c7d7ecd5496ce2192236fdd0ec66 to your computer and use it in GitHub Desktop.
Extendscript: Get After Effects Camera Data
// Figuring out some math to determine aov, filmSize and focalLength in an AE camera, as these values aren't script-accessible.
// Assuming units are pixels, film size measuring horizontally
var comp = app.project.activeItem;
var camera = your camera layer;
var compSize = comp.width;
var cameraZoom = camera.zoom;
var depthOfField = camera.depthOfField;
var focusDistance = camera.focusDistance;
var aov = 2 * Math.atan(compSize / (2 * cameraZoom));
// given focalLength, get filmSize:
var filmSize = 2 * focalLength * Math.tan(aov / 2);
// OR: given filmSize, get focalLength:
var focalLength = cameraZoom * filmSize / compSize;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment