0
Render multiple parts of same composition using script
New Here
,
/t5/after-effects-discussions/render-multiple-parts-of-same-composition-using-script/td-p/14375211
Jan 23, 2024
Jan 23, 2024
Copy link to clipboard
Copied
Hi!
I've been trying to come up with a script that takes information from markers in a composition, to add one or multiple instances of this same comp to Render Queue - the markers should define custom Start and Duration for each render.
I have the following script so far, but I'm having trouble with setting the timeSpanStart and timeSpanDuration (the way I'm entering information seems to be invalid to latest versions of AE):
// Get the active composition
var comp = app.project.activeItem;
// Check if the active item is a composition
if (comp && comp instanceof CompItem) {
var markers = comp.markerProperty;
var renderQueue = app.project.renderQueue;
// Iterate through all markers
for (var i = 1; i <= markers.numKeys; i++) {
var marker = markers.keyValue(i);
// Check if the marker's duration is greater than 0
if (marker.duration > 0) {
foundMarkers = true;
// Set the output file name based on the marker's comment
var outputName = "export_" + marker.comment + ".mp4";
// Create a new render queue item
var renderQueueItem = renderQueue.items.add(comp);
renderQueueItem.outputModule(1).file = new File(outputName);
// Set the time span start and duration
renderQueueItem.timeSpanStart = marker.time;
renderQueueItem.timeSpanDuration = marker.duration;
}
}
// Show an alert if no duration markers were found
if (!foundMarkers) {
alert("No duration markers were found");
}
} else {
alert("Please open a composition before running this script.");
}
alert("Great job! Now go back to editing");
Thanks in advance for any help!
TOPICS
Expressions
,
Scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
LATEST
/t5/after-effects-discussions/render-multiple-parts-of-same-composition-using-script/m-p/14375806#M243014
Jan 23, 2024
Jan 23, 2024
Copy link to clipboard
Copied
It's not:
app.project.activeItem.markerProperty.keyValue(i).time;
but:
app.project.activeItem.markerProperty.keyTime(i);
// Get the active composition
var comp = app.project.activeItem;
// Check if the active item is a composition
if (comp && comp instanceof CompItem) {
var markers = comp.markerProperty;
var renderQueue = app.project.renderQueue;
// Iterate through all markers
for (var i = 1; i <= markers.numKeys; i++) {
var marker = markers.keyValue(i);
var t = markers.keyTime(i);
// Check if the marker's duration is greater than 0
if (marker.duration > 0) {
foundMarkers = true;
// Set the output file name based on the marker's comment
var outputName = "export_" + marker.comment + ".mp4";
// Create a new render queue item
var renderQueueItem = renderQueue.items.add(comp);
renderQueueItem.outputModule(1).file = new File(outputName);
// Set the time span start and duration
renderQueueItem.timeSpanStart = t;
renderQueueItem.timeSpanDuration = marker.duration;
}
}
// Show an alert if no duration markers were found
if (!foundMarkers) {
alert("No duration markers were found");
}
} else {
alert("Please open a composition before running this script.");
}
alert("Great job! Now go back to editing");
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

