Page 1 of 1

Possible to send individual frames to Render Queue?

Posted: January 27th, 2005, 5:02 pm
by Jason Leach
I'm interested in rendering large numbers of frames I've set markers on (with the frame number included in the filename) for processing in Photoshop. Manually, I can just step through with the "k" key to jump to the next marker and hit "Ctrl+Alt+S" to send that frame to the render queue, but I'm wondering if its possible to script this. I think I know how to work with markers in scripts, but I can't find a way to send individual frames (rather than comps) to the render queue. All I can find in the manual is:

app.project.renderQueue.items.add(curItem);

but "curItem" is a comp. I tried replacing it with things like

app.project.item(1).layer(1).property("marker")

but AE says that's not the correct type.

Posted: January 27th, 2005, 5:58 pm
by Shinjipierre
That's not a bad idea, yeah we should be able to do something like that, I'll try to create it tomorrow :)

Posted: January 28th, 2005, 2:19 pm
by Shinjipierre

Code: Select all

{
	var activeItem = app.project.activeItem;																												//selects the active composition
	
	/* if the composition exists... */
	if (activeItem == null || !(activeItem instanceof CompItem)){
		alert("You need to select a layer first.");
	} else {
		var selectedLayers = activeItem.selectedLayers;																								//I grab the selected layers
		
		/* If there are selected layers... */
		if (activeItem.selectedLayers.length < 1 ) {
			alert("You need to select at least one layer.");
		} else {
			app.beginUndoGroup("Render marked frames");																									//I begin the undo group
			var Location = folderGetDialog("Select a destination..."); 																	//The user selects a render location
			
			/* I  remove all the itemqueues, Don't want to render other things than the marked frames */
			while(app.project.renderQueue.numItems >= 1) {
				app.project.renderQueue.item(1).remove();
			}
			
			for (i=0; i < selectedLayers.length; i++) {  																								//For all the selected layers
			
				
				currentLayer = selectedLayers[i];																													//I select the layer
				Markers = currentLayer.property("Marker");																								//I select the markers of this layer	
				//For all the markers on this layer																												//selects the active composition
				for (j=1; j <= Markers.numKeys; j++) {
					Frame = Markers.keyTime(j);																								//marker
					app.project.renderQueue.items.add(activeItem);														//I add an item to teh renderqueue
					app.project.renderQueue.item(j).timeSpanStart = Frame;										//starttime of the render = frame
					app.project.renderQueue.item(j).timeSpanDuration = 0;											//duration of the render = 0, only 1 frame to render
					OutputMO = app.project.renderQueue.item(j).outputModules[1];							//output module
					OutputMO.applyTemplate("Photoshop 32 bits");															//set to Photoshop 32 bits
					OutputMO.file = new File(Location.toString() + "/[compName] frame : [startTimecode] [#] .psd"); //Buggy name, I don't know why...
				}
			}
			
			
			app.project.renderQueue.render();  // Buggiest function ever :D, I don't fucking know why I get all these errors when I try to render the items O_o
			
			/* I  remove all the itemqueues, no need to see them */
			while(app.project.renderQueue.numItems >= 1) {
				app.project.renderQueue.item(1).remove();
			} 
		}
	}
}

Ok, I did that, it seems to work... but I wonder if the render() function has a bug or if it's only my comp, I get weird errors O_o

1 ) sometimes it doesn't render the files
2 ) sometimes it adds the frame number at the end of the filename
3 ) sometimes I get an error but the frames are rendered

And that depends on the name I set to the file :?

Posted: January 31st, 2005, 5:06 pm
by Jason Leach
Wow, thanks for writing this. :shock: There was more to it than I realized. I got the same 3 maddening errors and more, so its not just your comp. I also spent many hours testing variations of many parts of the script, but couldn't fix the bugs either. But as long as I comment out the line that sets the output module file (& of course the buggy renderer), it works perfectly as far I can see. I can just set the default file name manually before running the script & hit the Render button afterward.
:D

Just for the sake of interest, I noticed in the "Output Module" menu (under "Custom...") that setting:

timeSpanDuration = 0

sets the "End" frame of each output module to be frame before--rather than after--the "Start" frame, which seems like it has the potential to cause errors. I tried replacing it with:

timeSpanDuration = (1/frameRate)

but it didn't seem to solve any problems. I mention it because these values may be used in calculations done in setting the output module filename.

And I had more problems setting the output module filename than I did with the render function, which I soon commented out, hoping I could at least get the right filenames to show up. I noticed that the renderer seemed to crash AE because of the output module file command. One of the most frequent problems I had was multiple items in the render queue would end up with the same "Output To:" field, like

"[compName]_[#####].[fileExtension]"

The default name AE generates when you add the same comp to the render queue multiple times (& when you use Ctrl+Alt+S) has unique numbers appended to the filename & setting your own output module filename would get rid of them. As long as all the filenames were unique, I think the worst the render function in the script ever did was give me messages about "grouping" problems that it attempted to--and always seemed to--resolve.

Posted: May 9th, 2007, 6:30 pm
by mdelrossi
I took the liberty of adjusting this script.
I do have one problem though, It will not set the timespanstart if there are items in the render que.
I like to keep items in the que so i have a history of what I did. Is there a work around for this?
here is the script as it is:
Code:

{
var activeItem = app.project.activeItem; //selects the active composition

/* if the composition exists... */
if (activeItem == null || !(activeItem instanceof CompItem)){
alert("You need to select a layer first.");
} else {
var selectedLayers = activeItem.selectedLayers; //I grab the selected layers

/* If there are selected layers... */
if (activeItem.selectedLayers.length < 1 ) {
alert("You need to select at least one layer.");
} else {
app.beginUndoGroup("Render marked frames"); //I begin the undo group
var Location = folderGetDialog("Select a destination..."); //The user selects a render location



for (i=0; i < selectedLayers.length; i++) { //For all the selected layers


currentLayer = selectedLayers; //I select the layer
Markers = currentLayer.property("Marker"); //I select the markers of this layer
//For all the markers on this layer //selects the active composition
for (j=1; j <= Markers.numKeys; j++) {
Frame = Markers.keyTime(j); //marker framerate = (1/thisComp.frameDuration)
app.project.renderQueue.items.add(activeItem); //I add an item to teh renderqueue

app.project.renderQueue.item(j).timeSpanStart = Frame; //starttime of the render = frame
app.project.renderQueue.item(j).timeSpanDuration = activeItem.frameDuration; //duration of the render = 0, only 1 frame to render
OutputMO = app.project.renderQueue.item(j).outputModules[1]; //output module
OutputMO.applyTemplate("Jpeg"); //set to Photoshop 32 bits
OutputMO.file = new File(Location.toString() + "/[compName][startTimecode].jpg"); //Buggy name, I don't know why...
}
}


app.project.renderQueue.render(); // Buggiest function ever :D, I don't fucking know why I get all these errors when I try to render the items O_o



}
}

}

Thanks
mdr