Background Renderer Batch Creator

All things .jsx

Moderator: Paul Tuersley

Post Reply
maurky
Posts: 2
Joined: February 18th, 2006, 12:17 pm
Location: Italy
Contact:

Hi all,
I'm Maurky and this is my first post.
I came from flash action scripting and I'm really new to AEscript.
I hope this script can help people who want an easy access to aerender program.

This is the PC version because i haven't a Mac, but I'm open for suggestions for a Mac implementation.

bye
maurky

Code: Select all

/*
 * Chimp Background Renderer Batch Creator 
 * (PC version)
 * This script executes a rendering of a Composition by forking a batch
 * script in background (via aerender).
 * All the parameters are configurable on the script palette and all
 * the settings are saved in a config file. 
 *
 * Copyright (C) 2006 Maurky - Chimp s.r.l. - http://www.chimp.it
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
{// Configuration & default settings ///////////////////////////////
var aerender_path = "c:\\Program Files\\Adobe\\Adobe After Effects 7.0\\Support Files\\aerender.exe";
var settings_file = new File(Folder.current.absoluteURI+"/bgrender.cfg");
var outvideo = new File(Folder.current.absoluteURI+"/out.avi");
var outexec = new File(Folder.current.absoluteURI+"/ae_render.bat");
var rst = "Current Settings";
var omt = "Lossless";

// Functions ///////////////////////////////////////////////////////

// File ops
function load_settings() {
	settings_file.open("r"); 
	eval(settings_file.read()); 
	outvideo= new File(outvideo_name);
	outexec = new File(outexec_name);
	rst = render_setting;
	omt = output_module;
	settings_file.close();
}

function save_settings() {
	settings_file.open("w","TEXT","????"); 
	settings_file.writeln("outvideo_name='"+outvideo.fullName+"'"); 
	settings_file.writeln("outexec_name='"+outexec.fullName+"'"); 
	settings_file.writeln("render_setting='"+rst+"'"); 
	settings_file.writeln("output_module='"+omt+"'"); 
	settings_file.close();	
}

function save_dialog(file_string,file_mode) {
	var f = new File();
	f = filePutDialog("Choose the output file.",file_string,file_mode);
	return f;
}

// inteface utils
function win_add(type, str,w) {
	var tmp = win.add(type, [0,t,w,t+20], str);
	t+=20;
	if(type == 'edittext') {
		tmp.index = ebindex++;
		tmp.onChange = ebchange;
	}
	return tmp;
}
function win_right_butt(str,index) {
	var tmp = win.add("button", [200,t,300,t+20], str);
	tmp.index = index;
	tmp.onClick = extra_butt_click;
}

// Event Handlers 
function bclick() {
	save_settings();
	var f = new File(outexec.fullName);
	f.open("w","TEXT","????"); 
	f.writeln("\""+aerender_path+"\" -project \""+app.project.file.fsName+"\" -comp \""+this.name+"\" -RStemplate \""+rst+"\" -OMtemplate \""+omt+"\" -output \""+outvideo.fsName+"\"\n");
	f.close();
	f.execute();
}

function ebchange() {
		switch(this.index) {
		case 0:
			if(this.text == "") {
				this.text = rst;
			} else {
				rst = this.text;
			}
			break;
		case 1:
			if(this.text == "") {
				this.text = omt;
			} else {
				omt = this.text;
			}
			break;
	}
}

function extra_butt_click() {
	var f = new File();
	switch(this.index) {
		case 0:
			f=save_dialog("output","All Files:*.*");
			if(f != null) {
				outvideo = f;
				outvideo_box.text = outvideo.fsName;
			}
			break;
		case 1:
			f=save_dialog(outexec.name,"*.bat");
			if(f != null) {
				outexec = f;
				outexec_box.text = outexec.fsName;
			}
			break;
	}
}

// Main ////////////////////////////////////////////////////////////////////

var ebindex=0;

if ((app.preferences.getPrefAsLong("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY") != 1)) {
	alert ("This script requires the scripting security preference to be set.\n" +
			"Go to the \"General\" panel of your application preferences,\n" +
			"and make sure that \"Allow Scripts to Write Files and Access Network\" is checked.");
} else if (app.project.file == null) { 
	alert("No project file available\nPlease Save this project and re-run the script"); 
} else {
	if(settings_file.exists) {
		load_settings();
	} else {
		save_settings();
	}

	var win = new Window("palette", "background renderer", [100,100,400,400]);
	var t=0;

	win_add('statictext',"CHIMP Background Renderer Batch Creator",400);
	win_add('statictext',"Project info : "+app.project.file.fsName,400);
	t+=10;
	win_right_butt("browse...", 0);
	win_add('statictext',"Choose the VIDEO Output:",200);
	outvideo_box = win_add('statictext',outvideo.fsName,400);
	outvideo_box.readonly = true;
	t+=10;
	win_right_butt("browse...", 1);
	win_add('statictext',"Choose the SCRIPT Output:",200);
	outexec_box = win_add('statictext',outexec.fsName,400);
	t+=10;
	win_add('statictext',"Render Settings Template:",200);
	win_add('edittext',rst,400);
	t+=10;	
	win_add('statictext',"Output Module Template:",200);
	win_add('edittext',omt,400);
	t+=10;	
	win_add('statictext',"Save the project and Select the composition to bgrender:",400);
	var items = app.project.items;
	for (var i = 1; i <= items.length; i++) {
		if (items[i].typeName == "Composition") {
			var tmp_butt = win.add("button", [0,(t),300,(t+20)], items[i].name);
			tmp_butt.name = items[i].name;
			tmp_butt.onClick = bclick;
			t+=20;
		 } 
	} 
	win.bounds=[500,40,800,40+(t)];
	win.show();
} 
}/////////////////////////////////////////////////////////////////////////////
maurky | Studio Brutus
http://www.studiobrutus.com
Darkmoon_UK
Posts: 62
Joined: September 5th, 2006, 3:45 am
Location: Chiswick, London, UK
Contact:

Hi Maurky,

Welcome to the forum. I tried your script out.

Thats a really nice idea, to invoke the standalone renderer by script so that you can continue to use After Effects in the foreground.

The only thing that would make it more useful is more user friendly input of the settings to use, and maybe multiple composition selection. Can I suggest, then, to integrate your script with my own one here:

http://www.aenhancers.com/viewtopic.php?t=523

I can imagine both of these scripts complimenting each other rather well.

I could add a fourth button for "Background Render", of course I would credit you, how do you feel about this?

Thanks for sharing your idea,

Chris
maurky
Posts: 2
Joined: February 18th, 2006, 12:17 pm
Location: Italy
Contact:

Hi Darkmoon,

I'm working alot on my company that has changed name to Studio Brutus
http://www.studiobrutus.com and i've completely dropped AEscripting for a long while.

I'm happy you like this idea and i'll be glad to see "background render" button to the Multirender, thank you for your great work.

I would also suggest to you and to all readers another good implementation of the Background Render Batch Creator form Nab17 http://www.nabscripts.com
you can find it at the end of this page:
http://www.nabscripts.com/Downloads/downloads1.htm

bye,
maurky
maurky | Studio Brutus
http://www.studiobrutus.com
rola
Posts: 2
Joined: December 28th, 2007, 9:05 pm

Hi,maurky,
Thanks your code.I hope you can write a Mac version, which may be a good idea. very support you! :)
Post Reply