• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Bug using dan eberts clock expression

Explorer ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

I've never seen this behavior before I've got after effects updated to 22.2.1

The buggy behavior is illustrated below. It happens on whole seconds for one frame.

I've set up the clock to display in tenths of a second. Below is the clock output for every frame.

1.9, 1.9 1.9, 1.0 ,2.0 ,2.0, 2.1, 2.1, 2.1, 2.2 ... 2.9, 2.9, 2.9, 2.0, 3.0, 3.0 etc

the error is in bold

 

the video ive been given is 30.303 fps

Here is the code I'm using

 

rate = 1.0101;
//tried making the rate 30.303/30
//ive tried 1 same behavior
clockStart = -10.06501006501007;

function padZero(n){
return (n < 10 ? "0" : "") + n;
}

clockTime = clockStart + rate*(time - inPoint)

// this is all to get the clock to start at 0 in a certain part of the clip
//clockTime = clockStart + rate*(time - inPoint); start frame was 5024 then divided by 30.303
// now i cliped it so clockstart will be at frame 5024 identified by wmh so 5024-4720 / 30.303 = 10.03201003201003
//still off by one frame so add 1/30.303

if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}

t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(1).substr(-1);
//sign + padZero(hr) + ":" + padZero(min) + ":" + padZero(sec) + "." + ms
sign + padZero(sec) + "." + ms

 

I wish I could post the file anyways thanks for taking a look.

TOPICS
Error or problem , Expressions , Scripting

Views

336

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Apr 14, 2022 Apr 14, 2022

 

Mylenium,

thanks for replying

Yes I have.

The problem is the clock actually appears to go backwards when using 1 decimal on whole seconds.

I don't know the functions well enough to understand.  where  do I find help on toFixed and substr?

Using the help pull down I  don't find it in scripting help... or expression reference...

The same behavior at 30fps  in a clean one piece of text composition.... with the following code.

rate = 1;
clockStart = 0;

function padZero(n){
return (n < 10 ? "0" : "") + n;
}

clo

...

Votes

Translate

Translate
Explorer ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

The line of code that I believe is giving me problems is

ms = clockTime.toFixed(1).substr(-1);

1 gives me tenths of a second if I use 2 it works as expected with going "backwards"

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Have you actually adjusted the comp framerate accordingly and/ or played around with the footage interpretation and enforced a different, more standardized framerate? Otherwise this looks perfectly normal in the sense that with your values you'll always have scenarios where two consecutive frames produce identical values do to internal rounding and quantization limits. In such a case one would rather multiply the values with a uniform value before doing the math, then divide them at the end again. I'm pretty sure there is no bug, you just reach the limits of the internal integer math.

 

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

 

Mylenium,

thanks for replying

Yes I have.

The problem is the clock actually appears to go backwards when using 1 decimal on whole seconds.

I don't know the functions well enough to understand.  where  do I find help on toFixed and substr?

Using the help pull down I  don't find it in scripting help... or expression reference...

The same behavior at 30fps  in a clean one piece of text composition.... with the following code.

rate = 1;
clockStart = 0;

function padZero(n){
return (n < 10 ? "0" : "") + n;
}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}

t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.

rate = 1;
clockStart = 0;

function padZero(n){
return (n < 10 ? "0" : "") + n;
}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}

t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(1).substr(-1);


sign + padZero(sec) + "." + ms

 

(1).substr(-1);


sign + padZero(sec) + "." + ms

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Try this and see if it helps:

rate = 1.0101;
clockStart = -10.06501006501007;

function padZero(n){
return (n < 10 ? "0" : "") + n;
}

clockTime = clockStart + rate*(time - inPoint)
if (clockTime < 0){
  sign = "-";
  clockTime = -clockTime;
}else{
  sign = "";
}

t = padZero(clockTime.toFixed(1));
(t != 0 ? sign : "") + t

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Dan,

Your the best!

Redefining t works like a charm

Many thanks.

Regards,

bn

t = padZero(clockTime.toFixed(1));
(t != 0 ? sign : "") + t

 

Here's the whole thing for others.

 

 

rate = 1;
clockStart = 0;

function padZero(n){
return (n < 10 ? "0" : "") + n;
}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}

t = padZero(clockTime.toFixed(1));
(t != 0 ? sign : "") + t
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(1).substr(-1);
sign + padZero(sec) + "." + ms

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Hmmm...  The code I posted for you was meant to be "the whole thing". I'm surprised it works at all with the stuff you added after 

(t != 0 ? sign : "") + t

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Sorry

Wow! No idea!

I just tried replaced with your last post and of course it works!

I didn't mean to mess with it I just thought it got truncated.

Regards

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

LATEST

Good that you could already solve the issue.

By the way, if you need an easy to customize counter expression and don't want to write any code, there is one included in iExpressions:

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines