Skip to main content
Participating Frequently
June 26, 2023
Question

How to render a composition in After Effects using ExtendScript

  • June 26, 2023
  • 1 reply
  • 3201 views

I have a use case where I need to render specific layers in an After Effect's project, using my custom encoder.

In a high-level overview, when facing that "specific" layer, I creates a temporary composition to hold it for rendering, and then render that temporary comp.

The following is code snippet of how I do it:

var comp = app.project.activeItem; // assuming "activeItem" is a composition.
var layer = comp.layer(1); // assuming the first layer is the layer I which to render.

// creating a "dummy" comp to be sent to the render queue:
var duplicated = app.project.items.addComp(
    "".concat(layer.containingComp.name, "-duplicated"), 
    layer.containingComp.width, layer.containingComp.height, 
    layer.containingComp.pixelAspect, layer.containingComp.duration, 
    layer.containingComp.frameRate);
    layer.copyToComp(duplicated
);

var renderQueueItem = app.project.renderQueue.items.add(duplicated);
var outputModule = renderQueueItem.outputModule(1);
var path = "/path/to/my/output/file";
var file = new File(path);

outputModule.applyTemplate("my-custom-output-template");
outputModule.file = file;

app.project.renderQueue.render();

 

The issues are the following:

  1.  The function "app.project.renderQueue.render()" blocks the entire AE UI, including the render queue panel and its progress bar. Threre is indication once or ever what's going on until there rendering process terminates.
  2. I've found an undocumented function - "app.project.renderQueue.renderAsync()" which does not block the UI, and in addition AE render queue progress bar works perfectly. The problem with that approach, that I don't have any indication when the rendering process finishes, and/or if any error has occurred.

 

I tried to search for examples/answers online but found nothing usefull. I'll appriciate any help!!!

1 reply

Justin Taylor-Hyper Brew
Community Expert
Community Expert
July 5, 2023

You can use aerender to render headlessley in the background which would avoid both of these issues. Just make sure you save your project first:

https://helpx.adobe.com/after-effects/using/automated-rendering-network-rendering.html

Participating Frequently
July 16, 2023

Is there a way to call it using ExtendScript API, or do I have to call it as a CLI tool?

Justin Taylor-Hyper Brew
Community Expert
Community Expert
July 17, 2023

Yes, @ConstantinMaier answered it pretty well below, you would via system.callSystem()