After Effects scripting sink
Adobe After Effects scripting
· Adobe After Effects MOC · API · #code/js · #note/sink
TOC
Subframe layer nudge
var comp = app.project.activeItem;
var lr = comp.selectedLayers[0];
if (comp.selectedLayers.length > 0) {
var frl = comp.frameDuration;
app.beginUndoGroup("Layer Nudge");
lr.startTime += frl/4; // or -= to move the layer to the left
app.endUndoGroup();
} else alert("Select a layer");
Master Properties
// creating master properties
function R(P) {
if (P.numKeys > 0) P.addToMotionGraphicsTemplate(C);
for (var d = 1; d <= P.numProperties; d++) {
R(P.property (d));
}}
var C = app.project.activeItem;
var L = C.layers;
for (var i = 1; i <= L.length; i++){
R(L);
}
property.getMotionGraphicsTemplateControllerName(#) //- name of controller # in the master properties
property.setMotionGraphicsControllerName(#)
comp.motionGraphicsTemplateControllerCount //-> number of items
Comp.motionGraphicsTempalteName //-> name
Layer markers
l = app.project.activeItem.selectedLayers[0];
p = l.property("marker");
$.writeln(p.keyValue(3).comment);
alert("layer "+ l.name + " - " + p.keyValue(3).comment);
Render active composition with FFmpeg
renderActiveComp();
function renderActiveComp() {
// render comp out
var location = "C:/Users/Natel/Desktop/Renders/";
var comp = app.project.activeItem;
var rqItem = app.project.renderQueue.items.add(comp);
var module = rqItem.outputModule(1);
module.applyTemplate("MOV Cineform Q5");
var thisExtension = "." + module.file.fsName.split(".")[1];
module.file = File(location+comp.name);
app.project.renderQueue.render();
// ffmpeg call
var pathToFFMPEG;
pathToFFMPEG = $.fileName.slice(0, $.fileName.lastIndexOf("/"));
pathToFFMPEG+="/ffmpeg.exe";
system.callSystem('\"'+File(pathToFFMPEG).fsName.replace(/%20/g, " ")+'\" -i \"'+(location+comp.name+thisExtension)+'\" \"'+location+comp.name+'.mp4\"');
// remove ae rendered file
File(location+comp.name+thisExtension).remove();
}