Copy link to clipboard
Copied
Hello,
I'm fairly new in Adobe After Effects automation scripting but I was wondering if it's possible to open multiple WMV files (each file has the identical background color) and use an automated script to apply the same Color Key settings effects to all the files and then automatically rendering all the files as FLV, RGB+Alpha and selecting Audio Output to 96 Bitrate.
Any help would be appreciated. Thank you.
I actually got some down time and was able to put this together. There are a lot of comments to help explain what is doing what. You'll need to change a few things for your use.
Line #9 will need the file path to your Animation Preset file.
Line #12 will need the name of your OutputModule preset. It is case sensitive.
Line #31 can be changed if you want different file extensions. Right now it specifically is looking for the ".wmv" or ".WMV" strings in the file name.
...{
/*Choose a folder with WMV f
Copy link to clipboard
Copied
The process you describe sounds like a scriptable thing. Building the specific code would be more involved though.
Prep work would be to create an Animation preset for the Color Key settings and give it a logical name, and also create an OutputModule preset containing your FLV settings as well.
The general script breakdown would like this...
1) Import files (this could be choosing a folder with said files, or one by one choose the files, or the files are already in the project)
2a) Loop through chosen files
2b) Create a new composition for file.
2c) Add file as a layer.
2d) Apply Color Key Animation Preset to layer
2e) Add composition to render queue
3a) Loop through all render queue items set to "Queued" status
3b) Apply FLV output module template to item
3c) Set render out folder
4) Start render
If you are unfamiliar with ExtendScript, this could be overwhelming to create though. How much experience do you have with ExtendScript?
Copy link to clipboard
Copied
I actually got some down time and was able to put this together. There are a lot of comments to help explain what is doing what. You'll need to change a few things for your use.
Line #9 will need the file path to your Animation Preset file.
Line #12 will need the name of your OutputModule preset. It is case sensitive.
Line #31 can be changed if you want different file extensions. Right now it specifically is looking for the ".wmv" or ".WMV" strings in the file name.
{
/*Choose a folder with WMV files*/
var chooseFolder = Folder.selectDialog("Choose folder.");
/*Choose render to folder*/
var chooseRenderFolder = Folder.selectDialog("Choose folder to render to.");
/*Set your animation preset name here*/
var nameOfColorKeyPreset = File("/Users/gtm_osprey/Documents/Adobe/After Effects CC 2014/User Presets/MyColorKeyPreset.ffx");
/*Set your Output Module preset name here*/
var nameOfOutputModulePreset = "MyFLVOMPreset";
slash = ($.os.toString().indexOf("Windows") == (-1)) ? "/" : "\\"; /*Determines the slash format for files paths*/
/*Gather process into an undo group*/
app.beginUndoGroup("ImportKeyThenRender");
/*Validate folder object*/
if(chooseFolder != null && chooseRenderFolder != null){
/*Get files from folder*/
var files = chooseFolder.getFiles();
var filesLen = files.length;
/*Declare variables*/
var io, curFile, asset, myFiles;
/*Create an AE folder for files*/
var myWMVFiles = app.project.items.addFolder("WMVFiles");
/*Loop through files and import them*/
for(var f=0; f<filesLen; f++){
try{
curFile = files
; if(curFile.name.match(/.wmv|.WMV/g) != null){ /*Check file name for wmv WMV extension*/
io = new ImportOptions(curFile);
asset = app.project.importFile(io); /*Import file*/
asset.parentFolder = myWMVFiles; /*Place it in TEMP AE folder*/
}
}catch(err){
/*Kill import errors*/
}
}
myFiles = myWMVFiles.items;
myFilesLen = myFiles.length;
/*Declare more variables*/
var curFile, newComp, cName, cWidth, cHeight, cPAR, cDur, cFrameRate, myLayer, newRQItem, renderFile;
/*Loop through files and setup comps*/
for(var c=1; c<=myFilesLen; c++){
curFile = myFiles
; /*Get attributes for comp from file*/
cName = curFile.name.substring(0, curFile.name.length-4);
cWidth = curFile.width;
cHeight = curFile.height;
cPAR = curFile.pixelAspect;
cDur = curFile.duration;
cFrameRate = curFile.frameRate;
renderFile = chooseRenderFolder.toString() + slash + cName;
/*Create new comp with file specs*/
newComp = app.project.items.addComp(cName, cWidth, cHeight, cPAR, cDur, cFrameRate);
/*Add layer to comp*/
myLayer = newComp.layers.add(curFile);
/*Apply Animation preset to layer*/
myLayer.applyPreset(nameOfColorKeyPreset);
/*Add comp to render queue*/
newRQItem = app.project.renderQueue.items.add(newComp);
/*Set render queue item output module and render name & location*/
newRQItem.outputModule(1).applyTemplate(nameOfOutputModulePreset);
newRQItem.outputModule(1).file = File(renderFile);
}
}
app.endUndoGroup();
}
Copy link to clipboard
Copied
Thank you once again for your help David.
Is there a few lines of script which I could add to re-size the composition and position before adding it to the render queue?
Re-size = Height 2700 x Width 734
Position after it has been re-sized = 367.0, 500.0
Thank you.
Paul
Copy link to clipboard
Copied
If you want those specific sizes and position for all of the new comps, then you can replace these lines:
Line# 51 & 52 can be changed to this
cWidth = 734;
cHeight = 2700;
Line 61 can stay the same, just add a new line under it
myLayer = newComp.layers.add(curFile);
myLayer.property("ADBE Transform Group").property("ADBE Position").setValue([367.0, 500]);
Copy link to clipboard
Copied
Thank you once again David. The added script worked like a charm!
I've also been trying to remove 1 second from the end of each composition before it gets added to the render queue. I've searched online for any examples but I haven't found anything yet.
Do you know if this is possible?
Paul
Copy link to clipboard
Copied
All of the comp setting are setup between lines #50 - #55. The comp gets created at line #59. So you can alter those if you want different values.
So line #54 is setting the comp duration from the file's duration.
cDur = curFile.duration;
If you want a different value, you can type in a specified duration in seconds...
cDur = 10;
or you can subtract time from the incoming source. In your case, making the comp 1 sec shorter from the end.
cDur = curFile.duration - 1;
Copy link to clipboard
Copied
You are the best David. Thank you, thank you, thank you!
If there's anything I can do for you, just name it!
Paul
Copy link to clipboard
Copied
Send me a 1 million dollar check? lol
No problem Paul, glad to help.
Copy link to clipboard
Copied
It worked like a charm. Thank you!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now