How to render a composition in After Effects using ExtendScript
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:
- 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.
- 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!!!
