Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Render multiple parts of same composition using script

New Here ,
Jan 23, 2024 Jan 23, 2024

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
226
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 23, 2024 Jan 23, 2024
LATEST

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");

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines