Page 1 of 1

Randomising footage import, and more...

Posted: September 17th, 2007, 6:22 am
by iso
Hi there.

I'm new to this scripting thing - I've dabbled with expressions, and I can generally program computers (ie. I generally understand it). But I'm trying to do something here which is driving me mental, because it should be simple.

I'm trying to create a script which will firstly, randomise the linking of footage from a pool of source footage. Then secondly, as the pool contains footage of different lengths, I want to enable time remapping for each layer and on the last keyframe of each, hold the keyframe until the end of the comp. The effect is to create a 5x5 grid of clips all running out and holding on the last frame at different times (reason why I'm scripting this is because I need to create thosands of these 'panes' of 5x5 and tile them up and pull a camera out to give the impression of zillions)

My lame code so far is as follows:

Code: Select all

myComp = app.project.item(2); // how do I refer to an item by name, not index?
for (j = 1; j <= 25; j++) {
myComp.layer(j).timeRemapEnabled.TRUE;
tDur = myComp.layer(j).source.duration;
tStart = Math.random()*tDur;
myComp.layer(j).inPoint = tStart;
myComp.layer(j).startTime = -1*tStart;
}
This handles the randomising offsetting, but the file stuff eludes me. I also am just not getting how the syntax works for a lot of this eg. how do I refer to an item by name, not index? Do I use app.project.item(index).replace(file) to change linking?

Also, I should say I'm using 6.5.

Any pointers would be much appreciated - thanks.

Regards,

Paul.

Posted: September 17th, 2007, 9:50 am
by Atomic
Check out the LogoSequencer scripy by Byron Nash

viewtopic.php?t=102

There is code in there for importing footage (stills and movies), setting the length of layers. If you know some programming, you may be able to mix your code into his code for a delicious breakfast!

Also,

I just wrote a variation on an import routine here:
http://www.aenhancers.com/viewtopic.php?t=758

Posted: September 17th, 2007, 10:09 am
by Paul Tuersley
This post dealt with finding a project item by name. You have to loop through app.project.numItems, checking for the name.
viewtopic.php?t=731

You can replace the file source of a footage item in the project window. But you can't replace a layer in a comp with a specific footage item. For that you need AE CS3 and the new AVLayer replaceSource() method.

Here's some code that asks for a folder of footage items, imports one of them randomly, and then replaces the footage with another random file.

Code: Select all

{
	var theFolder = folderGetDialog("choose source footage folder");

	if (theFolder != null) {

		var theFiles = theFolder.getFiles();
		var theFile = theFiles[Math.floor(Math.random() * theFiles.length)];
		var theFootage = app.project.importFile(new ImportOptions(theFile));
		alert(theFootage.name);
		theFile = theFiles[Math.floor(Math.random() * theFiles.length)];
		theFootage.replace(theFile);
		alert(theFootage.name);
	}
}


Posted: September 24th, 2007, 2:33 am
by iso
Hi again.

Never had the chance to say (been totally overwhelmed), thanks a lot for your help - I really appreciate it. You ever need any help in Director, contact me!

Regards, Paul.