Skip to main content
vidjuheffex
Participating Frequently
September 6, 2014
Question

Extendscript Time Value / AEGP Time Values BUG

  • September 6, 2014
  • 1 reply
  • 1934 views

There is a fairly annoying bug (?) in Extendscript that I am hoping to rectify by starting to dig into the C++ SDK and hopefully solve using a hybrid extension.

Here is the bug:

I have manually set my frame count to start from 0 in my Project, as per my facilities specs. This is so our timecode from the client stays correct to theirs, however while we like to start the count from 0 we like to have our master comp set to start at frame 1;

So the comp is set to 1.

For reference this comp is set to 29.97

If I query currentComp.displayStartTime I get:

0.03336670003337

One frame in, in seconds.

If I query currentComp.frameDuration I get (drum roll):

0.03336670003337

One frames length in seconds.

So to programmatically set it in the future the code should be:

currentComp.displayStartTime = currentComp.frameDuration;
If I query displayStartTime after setting it, I get:
0.03336669877172

So, it seems the JavaScript doubles are becoming Floats somewhere where it talks to the AE engine.

Why this is a gnarly bug, sometimes running this sets the start time to 0 (depends on the frame rate, 29.97 goes to 0, 23.976 goes to 1)

I have seen fixes like add (1/1000) to the value to nudge it just over the edge. While this gets numbers I want it seriously breaks rendering. If I submit to royal render it will render from frame 0 (a grey frame) and then try and (usually crash) the remaining frame except for the last frame, all the while struggling to split the comp between machines. So I actually do need the setting to be as accurate as the getting WITH NO fudging. (why can't we script with INTEGER frames ffs!?)

I would love to fix this without C++ but have had no luck.

Why C++ seems to be answer:

It seems the floats are quantized to certain step values in the C++ side of things. (See time_scale and time_step)

Before I commit to having no life and woodshedding some C++, does anyone have a fix for this? Can I pre-quantize the floats in AE and set that? Can I X-Post to the scripting forum?

This topic has been closed for replies.

1 reply

Legend
September 6, 2014

TThis has been an issue for a long time in ExtendScript. The only work around, as heavy and annoying as it is, has been using a function I built that basically tests compObj.time value against the supposed frame value. The time attribute seams to work properly and lands on the whole frame. Corrects and incorrect float value basically. I then compare the values, if they don't match, I assume the compObj.time is the correct one and use that value instead. It becomes greatly annoying as setting this value forces the timeline cursor to move to that time, so I also saved the previous location so I could return it back as if nothing happened. It's an incredibly inconvenient process, but it does seem to work.

vidjuheffex
Participating Frequently
September 7, 2014

While interesting to note that compObj.time returns the correct value and lands on the whole frame I still do not see how this fixes my problem.

Take this simple code, comp is 29.97 and set to start at frame 1 manually when first run.

var currentComp = null;
var currentComp = app.project.activeItem;
$.writeln("######################################");
$.writeln("Current display start time: " + currentComp.displayStartTime);     //this is the result from Manually setting it
$.writeln("Current frame duration: " + currentComp.frameDuration );            //this is how long one frame lasts
$.writeln("Current comp time: " + currentComp.time);                                   //this is 0 since my cursur is at the start of the comp

currentComp.time = currentComp.frameDuration;                          //move the cursor one frame in capture the time value there

$.writeln("Current time 1 frame in: currentComp.time);                    //this is the value that comp.time returns at frame 1


currentComp.displayStartTime = currentComp.time;                    //set display start time to the value of currentComp,time
$.writeln("AFTER SWAP: " + currentComp.displayStartTime);     //#$@#@! happens here anyway


output:

Current display start time: 0.03336670003337

Current frame duration: 0.03336670003337

Current comp time: 0

Current time 1 frame in: 0.03336670003337

AFTER SWAP: 0.03336669877172     <--- until this returns the identical value not sure what to do.


It doesn't seem to me, unless I'm missing something, that it matters where I get an accurate number from, AE is unable to accept that value as an input for Comp Display Start Frame.

danielmarsh
Participant
December 24, 2014

I'm experiencing the same problem. Creating a pipeline tool for initial project setups and want the user to be able to choose the start frame number or infer it from footage in an elements library. No matter what I do, certain frame rates will produce a result that is 1 frame off.

For example, our default start frame is always 1001. But frame rates like 24fps will produce a start frame of 1000 when using either:

currentFormatToTime(startFrame, fps);

– or –

startTime = (startFrame / fps );

I even tried a really cheap hack just to see if it would work. I set the start frame to 0. Then got the frame duration as your script above did. Then, I used a loop to cycle through every frame. Then realized I'm an idiot because currentComp.time may be right but never evaluates correctly when set to the displayStartTime.

I'm assuming this all has to do with some kind of precision of the floating point numbers when they are used to do math, but can't find any way to increase their precision to calculate what's needed. There really should be a library that lets you access the timeline via frame values rather than seconds as most compositing needs are really frame based.

Anyone ever find any kind of solution for going to a specific frame in the timeline with precision or setting the display start time to a value other than 0 or 1?