ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Import Footage and Create Comp with Extendscript

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Keenan Parry
Import Footage and Create Comp with Extendscript
on Sep 12, 2019 at 9:33:21 pm

Hey all, would love a little help here. So far I have a script that imports all the footage from a selected folder and creates comps with all the info I need. But I can't for the life of me figure out how to get said imported footage to actually show up in my comp. As of now this script just creates comps with the proper names and info but I can't figure out exactly how to get the footage to show up in the comp it creates- they all show up empty. Learning still and trying to get to grips with it and thought this would be a great little exercise. Any help would be appreciated.

var sourceFolder = Folder.selectDialog("Select folder with source files");

// Import source files into project
var files = sourceFolder.getFiles();
for (var i = 0; i &lt; files.length; i++) {
app.project.importFile(new ImportOptions(files[i]));
}

// Array holding source footage
var sourceList = new Array();
for (var i = 1; i &lt;= app.project.items.length; i++) {
sourceList[sourceList.length] = app.project.items[i];
}

// Generate Compositions
for (var i = 0; i &lt; sourceList.length; i++) {
var sourceFootage = sourceList[i];
var compName = sourceFootage.name.substring(0, sourceFootage.name.indexOf(".")) + "_" + i;
var newComp = app.project.items.addComp(compName, sourceFootage.width, sourceFootage.height, 1, sourceFootage.duration, sourceFootage.frameRate);
}


Return to posts index

Dan Ebberts
Re: Import Footage and Create Comp with Extendscript
on Sep 13, 2019 at 12:28:50 am

At the end of your Generate Compositions loop, add this:

newComp.layers.add(sourceFootage);


Dan



Return to posts index

Keenan Parry
Re: Import Footage and Create Comp with Extendscript
on Sep 16, 2019 at 7:57:32 pm
Last Edited By Keenan Parry on Sep 16, 2019 at 8:01:54 pm

Thank you so much Dan, I seriously love you. Do you mind if I pick your brain a little more? I've got it working mostly correct now but still running into little issues that are stumping me.

Expected behavior:
If there is an After Effects project opened with another comp (lets call this COMP_TEST) already inside, the script should ignore COMP_TEST, import the footage, create compositions, add to render queue, then start the queue.

What actually happens:
When COMP_TEST is already present in the project file, the script appears to treat this composition as if it's imported footage, creates a comp out of it, and adds to to the queue.

Any ideas how to make the script only make compositions out of the imported footage? I think my problem is here since it's clearly making compositions out of the entire project instead of the freshly imported footage:
// Array holding source footage
var sourceList = new Array();
for (var i = 1; i <= app.project.items.length; i++) {
sourceList[sourceList.length] = app.project.items[i];
}


Really can't be sure. What I'm attempted to eventually do is add COMP_TEST to the comps created from footage and have COMP_TEST starting at the end point of the footage contained. That's the next phase, but don't wanna get too ahead of myself.

Thanks so much Dan.

//Source Folder
//Manually select folder
var sourceFolder = Folder.selectDialog("Select folder with source files");

// Import source files into project
var sourceFiles = sourceFolder.getFiles();
for (var i = 0; i &lt; sourceFiles.length; i++) {
app.project.importFile(new ImportOptions(sourceFiles[i]));
}

// Array holding source footage
var sourceList = new Array();
for (var i = 1; i &lt;= app.project.items.length; i++) {
sourceList[sourceList.length] = app.project.items[i];
}

// Generate Compositions and add sequential number
for (var i = 0; i &lt; sourceList.length; i++) {
var sourceFootage = sourceList[i];
var compName = sourceFootage.name.substring(0, sourceFootage.name.indexOf(".")) + "_" + i;
var newComp = app.project.items.addComp(compName, sourceFootage.width, sourceFootage.height, 1, sourceFootage.duration, sourceFootage.frameRate);
newComp.layers.add(sourceFootage);

//Add comps to render queue
var renderQ = app.project.renderQueue.items.add(newComp);
var outputModule = renderQ.outputModule(1);
var outputFolder = "CUSTOM_PATH";


//Apply template (codec) and change output folder
outputModule.applyTemplate("ProRes");
outputModule.file = File(outputFolder + "/" + compName);
}

//Start Render
app.project.renderQueue.render();


Return to posts index


Dan Ebberts
Re: Import Footage and Create Comp with Extendscript
on Sep 16, 2019 at 8:21:27 pm

I haven't tested this, but try setting up your footage array this way:


//Source Folder
//Manually select folder
var sourceFolder = Folder.selectDialog("Select folder with source files");

// Array holding source footage
var sourceList = new Array();

// Import source files into project
var sourceFiles = sourceFolder.getFiles();
var footage;
for (var i = 0; i < sourceFiles.length; i++) {
footage = app.project.importFile(new ImportOptions(sourceFiles[i]));
sourceList.push(footage);
}



Dan



Return to posts index

Keenan Parry
Re: Import Footage and Create Comp with Extendscript
on Sep 16, 2019 at 8:35:00 pm

Much appreciated! It does indeed ignore the comp now, but seems to be importing the footage twice, though it only creates one set of comps for rendering. So everything is working as it should, besides there being two sets of footage in the project now.


Return to posts index

Keenan Parry
Re: Import Footage and Create Comp with Extendscript
on Sep 16, 2019 at 8:49:32 pm

Oh wait! Ignore that please, it's working perfectly. I was importing the files twice because I left legacy code in there. My bad


Return to posts index


Keenan Parry
Re: Import Footage and Create Comp with Extendscript
on Sep 16, 2019 at 10:44:13 pm

Got one more for ya.....

So, last thing I'm trying to get this script to do is to add a composition (bump) to the end of the newly created comps (newComp). I got this to work successfully by adding the variable var bump = app.project.item(1); at the beginning of my for loop and then newComp.layers.add(bump); at the end. I also added sourceFootage.duration+bump.duration to adjust for the duration of both comps. This works as expected, but I'm having trouble getting the bump layer to start at the end point of the footage, meaning it doesn't start at the beginning of the comp like default.

A better way to say it perhaps: how do I get the end point of bump to line up to the end of newComp?

// Generate Compositions - Add _00_Text_Bump to Comps - add sequential number to end of name
for (var i = 0; i &lt; sourceList.length; i++) {
var bump = app.project.item(1);
var sourceFootage = sourceList[i];
var compName = sourceFootage.name.substring(0, sourceFootage.name.indexOf(".")) + "_" + i;
var newComp = app.project.items.addComp(compName, sourceFootage.width, sourceFootage.height, 1, sourceFootage.duration+bump.duration, sourceFootage.frameRate);
newComp.layers.add(sourceFootage);
newComp.layers.add(bump);


Return to posts index

Keenan Parry
Re: Import Footage and Create Comp with Extendscript
on Sep 16, 2019 at 11:35:45 pm

So sorry once again, I figured it out!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]