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();
}
}/////////////////////////////////////////////////////////////////////////////