ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Is it possible to change multiple comps start frame with a script?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Christian EvansIs it possible to change multiple comps start frame with a script?
by on May 1, 2014 at 7:17:32 pm

Here's the issue:

We get a lot of footage from overseas and out of FCP with a one hour start on the time code. I need to change all the comps to a start frame of 1. Currently I have to do it one by one. I've been trying to find a solution that would let me batch change several comp's start frame.

I've already searched around for a solution to this problem and tried using CRGreen's Selected Comps Changer first but it doesn't have start frame as an option. I tried modifying some other scripts I found for changing length or size to change start frame but it didn't work. My scripting knowledge is juvenile and limited.

I tried taking this script for changing frame rate:

var myItems = app.project.selection;
for (var i = 0; i < myItems.length; i++) {
if (myItems[i] instanceof CompItem) {
myItems[i].frameRate = 11;
}
}


and changing it to this:

var myItems = app.project.selection;
for (var i = 0; i < myItems.length; i++) {
if (myItems[i] instanceof CompItem) {
myItems[i].startFrame = 1;
}
}


But it didn't work.

Any help? Thanks!


Return to posts index

Walter SoykaRe: Is it possible to change multiple comps start frame with a script?
by on May 1, 2014 at 7:39:27 pm
Last Edited By Walter Soyka on May 1, 2014 at 7:47:36 pm

You have two issues here.

1. Comps do not have a "startFrame" attribute; they have a "displayStartTime" attribute.

2. displayStartTime is measured in seconds, not in frames. We can't pass it the number "1", we have to pass it a fraction of time.

A little testing shows that simply passing it frameDuration yields 0, not 1, so I'm assuming it's looking at this as still the end of frame 0, not the beginning of frame 1. Thus, we need to send one more frame's worth of time than the number we want to get (i.e., 2 frames instead of 1).

Try this:

var myItems = app.project.selection;
for (var i = 0; i < myItems.length; i++) {
if (myItems[i] instanceof CompItem) {
myItems[i].displayStartTime = myItems[i].frameDuration*2;
}
}


Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events


Return to posts index

Christian EvansRe: Is it possible to change multiple comps start frame with a script?
by on May 1, 2014 at 8:00:37 pm
Last Edited By Christian Evans on May 1, 2014 at 8:06:46 pm

Thanks a lot for explaining why my approach didn't work.

I tried what you did but got various results. Frame Duration alone got me start frame of 2, doubling it got me a start frame of 3. Guessing it has to do with the overall length of the comp being different?

I tried just doing displayStartTime = 1 and got a start frame of 24. So I tried 1/24 and got 1. I'm guessing this only works for a comp with a frame rate of 24 but since I work in animation and we do everything at 24 this works:

var myItems = app.project.selection;
for (var i = 0; i < myItems.length; i++) {
if (myItems[i] instanceof CompItem) {
myItems[i].displayStartTime = 1/24;
}
}


Return to posts index


Christian EvansRe: Is it possible to change multiple comps start frame with a script?
by on May 1, 2014 at 8:11:51 pm

I changed the fraction to 1/40 and it seems to work with 2997 and 30 comps as well. Rounds up to 1.


Return to posts index

Walter SoykaRe: Is it possible to change multiple comps start frame with a script?
by on May 1, 2014 at 8:38:06 pm

you could probably do frameDuration*1.1 (which pushes it just into the first frame). This should work on all frame rates.

I'm not sure if using a "partial frame" start time like this will ever throw off a timecode calculation by a frame. With 24.0 fps I'd think it wouldn't matter, but it's conceivable that it could for a fractional frame rate.

Regardless, it looks like there's a bug here.

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events


Return to posts index

Walter SoykaRe: Is it possible to change multiple comps start frame with a script?
by on May 1, 2014 at 8:14:59 pm

[Christian Evans] "I tried just doing displayStartTime = 1 and got a start frame of 24. So I tried 1/24 and got 1. I'm guessing this only works for a comp with a frame rate of 24 but since I work in animation and we do everything at 24 this works:"

Hmm... that's interesting. For a 24 fps comp, frameDuration should be returning precisely 1/24. I'll try to look into this a little more to see what's up later, but I'm glad you've got a solution working now.

Isn't it somewhat unusual to start frame counts on 1 instead of 0?

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events


Return to posts index


Bryan WoodsRe: Is it possible to change multiple comps start frame with a script?
by on May 28, 2014 at 1:33:24 am

I wanted to add to this thread with a minor tweak that allows for the user when they run the script to put in the frame rate they are currently at. The modded code is below.

This saved me today! Thank you!




For those who just stumbled upon this thread in search of something like this. The code is below. Copy and paste the code into a text document, and make sure its plain text (not .rtf or any other extension). Save it out with the extension .jsx, and put it in your scripts folder in AE. Restart after effects and give it a try!


{

//Set Undo Group
app.beginUndoGroup("Reset_StartFrame");

frameRate = parseFloat(prompt("What is the frame rate?"));

var myItems = app.project.selection;
for (var i = 0; i < myItems.length; i++) {
if (myItems[i] instanceof CompItem) {
myItems[i].displayStartTime = 1/frameRate;
}
}


app.endUndoGroup();
}


Return to posts index

Paul RoperRe: Is it possible to change multiple comps start frame with a script?
by on Jul 31, 2015 at 2:15:50 pm

Having experienced a bug in AE where it changes a comp's start frame from 1 to 2, I searched around and found this script. It works perfectly for 29.97fps comps, but does nothing for 30fps comps, which is odd. Running the script on a 30fps comp with a start frame of 2 achieves nothing.

Unfortunately I do not have anything constructive to add; there seems to be no reason why setting the displayStartTime to 1/30 (in a 30fps comp) would not work just as well as setting it to 1/29.97 (in a 29.97fps comp). I have a personal loathing of 29.97fps and think the world would be a much better place if we abolished it completely!


Return to posts index

Paul RoperRe: Is it possible to change multiple comps start frame with a script?
by on May 23, 2016 at 8:53:48 am

Well that's an amusing coincidence - a search brought me to this page, only to see that I'd already commented on it last year!

I tried that script again, and found that to change the start frame number of a bunch of 29.97fps comps, entering "29.97" in the framerate field made no difference, but entering "25" successfully changed the start frame numbers to "1". Odd.

(And I still cannot see the point of 29.97fps in the 21st century!)


Return to posts index

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