Issue when adding items to the Render Queue via script (only with certain Starting Points ...)

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
mfe
Posts: 7
Joined: July 29th, 2010, 3:04 am

Hi there,

I encountered a very strange issue when adding items to the Render Queue via script. Most of the time the script works
great, but if the render should start for example on frame 3, 4 - 8, 9 - 13, 14 ... it starts one frame before ...

Here´s some background: I have to render about two hundred separate clips from one Comp in After Effects. To automate things I created Comp Markers from the Edits and wrote a script that adds new items to the RenderQueue for every Marker. It is not the prettiest script but it worked ... only issue is the weird behaviour with certain start points.

At first I thought it might be some kind of rounding error since after effects uses seconds and the render queue uses the current time settings, but even if I hard code said frames I get the same result ...
One thing I found out: if I change the fps for the comp the pattern of problematic Starting Points shifts....

So here´s the script I wrote:

Code: Select all

{
	// RenderQueueFromMarkers_v01.jsx
	//
	// This script renders multiple clips from one composition
    // the duration of each clip is defined by composition markers
	//
    // Make sure to adjust output path and output module before use !!!
    // also: clear Render Queue before runing this script
	
	function RenderQueueFromMarkers(thisObj)
	{
		var proj = app.project;
		var scriptName = "Add to Render Queue from Markers";
    
        // Set path to output folder
        var outputFolder = "/Users/Markus/Downloads";
        // Set name of the output module
        var outputModule = "PR 422 HQ 16bit";
			
        // main function
		if (proj) {
			var activeItem = app.project.activeItem;
			if (activeItem != null && (activeItem instanceof CompItem)) {
				app.beginUndoGroup(scriptName);

				// get active composition
                var myComp = app.project.activeItem;
                
                // go through all markers of the active composition
                for (j = 1; j <= myComp.markerProperty.numKeys-1; j++) { 
                    
                    // add composition to render queue, set start point, duration, output module and path
                    app.project.renderQueue.items.add(myComp);
                    app.project.renderQueue.item(j).setSetting("Time Span Start", myComp.markerProperty.keyTime(j));
                    app.project.renderQueue.item(j).setSetting("Time Span Duration", myComp.markerProperty.keyTime(j+1) - myComp.markerProperty.keyTime(j));
                    app.project.renderQueue.item(j).outputModule(1).applyTemplate(outputModule);
                    app.project.renderQueue.item(j).outputModule(1).file = File(outputFolder + "/" + myComp.name + "_" + j);

                    // Debug alert:
                    //alert(myComp.markerProperty.keyTime(j));
                }   
                
				app.endUndoGroup();
			} else {
				alert("Please select an active comp to use this script", scriptName);
			}
		} else {
			alert("Please open a project first to use this script.", scriptName);
		}
	}
	
	RenderQueueFromMarkers(this);
}

So if anyone can tell me what I am doing wrong (besides the whole rendering 200 clips in After Effects things) I would appreciate any help!

Cheers, Markus
Attachments
03_RenderQueueFromMarkers_v01.jsx
(2.06 KiB) Downloaded 732 times
mfe
Posts: 7
Joined: July 29th, 2010, 3:04 am

Just a quick update on the issue:
for some strange reason the "Time Span Start" property of the renderQueue.item acts really strange.

For most values that are not full seconds I received different values when I use the getSetting to check
after using the setSetting to set the property to the desired time.
But I am not sure if this is the reason for my initial issue with some RenderQueueItem items starting one frame early ...

Since I have no idea how to straighten this out I am trying to work around this issue with another script that moves
all layers in the comp so they all start on full seconds ...
User avatar
evefalcao
Posts: 4
Joined: December 25th, 2016, 12:27 pm
Contact:

Hi Markus, do you have a project file that reproduces this error? Because I tried your script and it seems to work 100% of the time. All start times match, although the end time seems to be an open interval. My project is on 30fps and my AE version is 24.1.0 (Build 78).
Attachments
2024-05-17_16-37.png
2024-05-17_16-37.png (73.89 KiB) Viewed 11891 times
mfe
Posts: 7
Joined: July 29th, 2010, 3:04 am

Hi Eve, thanks for checking out the issue !

Here´s a project file and I marked two faulty items on the render queue.
Screenshot 2024-05-21 at 11.16.54.jpg
Screenshot 2024-05-21 at 11.16.54.jpg (163.6 KiB) Viewed 11777 times
I am working on the latest version of after effects 24.4.0 my composition is set to 25fps but I could reproduce the problem with different frame rates (only the pattern of the errors is changing ...)
Attachments
RenderScript_debug_01.aep.zip
(187.71 KiB) Downloaded 740 times
User avatar
evefalcao
Posts: 4
Joined: December 25th, 2016, 12:27 pm
Contact:

mfe wrote: May 21st, 2024, 2:30 am Hi Eve, thanks for checking out the issue !

Here´s a project file and I marked two faulty items on the render queue.
Screenshot 2024-05-21 at 11.16.54.jpg

I am working on the latest version of after effects 24.4.0 my composition is set to 25fps but I could reproduce the problem with different frame rates (only the pattern of the errors is changing ...)
Hi again, Markus.

You might have already solved this, given up, or figured out what I'm about to share, but I wanted to circle back after spending a few hours on this issue. My strongest hypothesis is that AE truncates the timecode, which are floating-point numbers, and this compromises precision by a frame or two at some point. I changed the composition frame rate in your project file to 30fps and 24fps, repositioned the markers, and adjusted the layer endpoints to be exactly 1 frame. This frame rate seemed to work consistently for all 50 markers, but I’m not sure if it would hold up with larger iterations. At 25fps, it breaks more frequently.

I came across this article during my research: https://www.creativeimpatience.com/the- ... -timecode/. It turns out this is a longstanding issue. I’m curious whether the rendered video appears correct despite this problem. Another hypothesis I considered is that it might be an issue with how the Custom Time Span information is rendered in the AE interface since the "duration" appears correct regardless of the Time Span Start and End. However, this seems less likely because the inaccuracy in the timecode, due to floating-point precision, seems to be the root of the problem.
mfe
Posts: 7
Joined: July 29th, 2010, 3:04 am

Hi Eve,

Thanks a lot for investigating the issue! And thanks for the blog post you shared!

My rendered files were not correct, that’s how I noticed the issue in the first place.
After I realized that I won’t be able to solve the issue I wrote a script to move all Layer InPoints to a full second. That worked pretty well and only added one extra step to the workflow …

Anyway thanks again for your effort !!!
Cheers, Markus
Post Reply