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
  • 3208 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

In addition, in my use case I have to build a RenderQueueItem manually in order to apply custom settings and parameters, then render everything insdie the render queue. Reading the documentation mentioned by you above, I can do it by calling

$ ./aerender -project <project-path>

 it does render successfully and my terminal process executing the task above does wait until the render process is done, but there is no user indication of any progress in After Effects UI. I'm not sure this tool is meant for those kind of use-cases. Am I doing something wrong? can I use it differently?

Participating Frequently
July 20, 2023

Move that inside your renderFinishedMessage() function.


Can you provide more details please?