Randomising footage import, and more...

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
iso
Posts: 2
Joined: September 17th, 2007, 4:44 am

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.
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

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
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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

iso
Posts: 2
Joined: September 17th, 2007, 4:44 am

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.
Post Reply