variation on precomp to duration...

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
ScottG
Posts: 38
Joined: March 19th, 2006, 2:45 am

Hey Guys,

One thing that's always bugged me about precomping is that there are situations where the precomping isn't smart enough and I have to do some manual edits.

Eg, say I have an AV layer that's been trimmed. I precompose this trimmed layer, and I get a comp that's the same duration as the AV layer, but which has been trimmed to the same in/out points.

What I would prefer is that my new comp have the duration of the trimmed layer, not the duration of the source, and so that when i open this comp my trimmed layer fits neatly into the entire comp, with the ins/outs of the comp and layer corresponding.

I'm trying to do this with a script.
I can get the duration of the trim, but it appears I can't use the precompose method to precomp.

Would I be right in assuming I'm going to have to add a new comp which has the duration of the trimmed layer, somehow insert this trimmed layer into that comp, add that comp to my original comp at the correct ins/outs, and remove the original av layer from my original comp?
ie, in effect, recreate my own precomp method?
ScottG
Posts: 38
Joined: March 19th, 2006, 2:45 am

okay, i've got it working for the most part, except that i'm having trouble moving my trimmed layer to the beginning of the precomp, after having used copyToComp to paste it into a new comp etc etc.

if i use startTime = 0, it moves the start time of the source to time 0.
if i use inPoint = 0, it changes the inpoint, rather than moving the trimmed layer so it's inPoint lies at time 0.

so how do i move the trimmed layer so that it's inPoint is at time 0? stumped...

thanks!
Scott.
ScottG
Posts: 38
Joined: March 19th, 2006, 2:45 am

i'm gonna check out rd: Shifter too see how redefinery has shifted his layers. perhaps i shall find my answer there...
ScottG
Posts: 38
Joined: March 19th, 2006, 2:45 am

i figured it out. sorry for wasting electrons with this topic.
once i have the script all neat and tidy i'll post it in the appropriate place.
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

Ah, OK. I was going to work on a script for you, but glad you found a solution.

Jeff
ScottG
Posts: 38
Joined: March 19th, 2006, 2:45 am

Jeff,

I'd still appreciate any feedback you'd care to give once I get this script cleaned up and post it to AE Enhancers. :)

I've been looking at your scripts and they're quite clean and logical, whereas I suspect that in some cases I have superfluous code, or code that could have implemented a better way. I have the feeling that some tasks I approach in a brute-force manner, meaning that it may be difficult to adapt these scripts to anything other than the specific purposes I'm creating them for.

Well, we'll find out soon enough!
Thanks for taking an interest. :)
ScottG
Posts: 38
Joined: March 19th, 2006, 2:45 am

The script is here!
http://scott.geersen.com.au/aescripts/s ... ration.jsx

Keep in mind I've written this a) while learning, and b) to be part of a larger script I'm writing to help me automate a tedious task I have to do at work.

Because of this, the script currently only works on a single layer. It'd be pretty easy to get it to work on multiple layers, especially since you could cut and paste from either Dan's precomping script or the stuff from redefinery.com to complete the script.

I'll get around to updating it sooner or later, but in the meantime my main focus is getting my larger script to work. But if someone wants to update this themselves, please do so and post back. :P
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

Hi Scott,

In general, the script works in certain cases. However, if you need to make the script more robust so that it can handle other layer types or conditions, here are a few notes:

- [line 43] Need to use comparison operator: myLayers.length == 1

- [lines 51-53] Be sure to check different layer types (solid, text, camera, light, audio-only) as some of these attributes might not apply. This will cause line 93 (addComp()) to fail.

- [line 54] Although these are 0 right now, you're assuming an 8 bpc project (denominator of 255). If you intend to support colors other than black, be sure to pay attention to the project's bitsPerChannel attribute.

- [lines 80-82] These assume a layer stretch > 0. These need to be revised for negatively stretched layers.

- [line 90] Any particular reason you have this variable here?

- It might be more correct if the precomp layer was placed in the same position as the original layer, instead of at top of the comp.

There are several conditions to think about when developing a general purpose solution. I hope to cover these types of issues in some future article or something.

Hope this helps.

Jeff
ScottG
Posts: 38
Joined: March 19th, 2006, 2:45 am

Jeff,

Thanks for the advice, I hadn't even thought about some of those issues, especially the one about placing the layer in the correct position in the timeline stack! You've given me a lot to think about and research...

I shall try and fix my script, but it won't happen quickly, as I don't have much spare time, and it's taking a long time to figure things out. The Adobe Scripting Guide is good, but I'm finding it difficult to diagnose some of my errors (like the one I mention in my "precomp undefined" topic).

Can you recommend any javascript resources that aren't specific to the web? Every time I look for tutorials or reference, it's all about adding buttons to websites or mouseclicks etc. The only sites I can seem to find that mention AFX AND javascript are this one, creative cow, and your site.


Thanks!
Scott.
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

Scott,

Most of my JavaScript knowledge I learned as part of web development, either from books like the JavaScript: The Definitive Guide book by David Flannagan or what I could find on the web.

As for AE-specific scripting resources, I list the ones I'm aware of in the "additional scripting resources" section in the "ae scripts" section of my site (http://www.redefinery.com/ae/). Otherwise, us script heads try to help out when possible in forums such as this.

Jeff
Post Reply