FORUMS: list search recent posts

real value to change comp duration

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rainier Raydán
real value to change comp duration
on Aug 30, 2017 at 7:56:17 pm

Hi guys! I'm working in a script to change the duration (and other things) of the or selected comps. The problem is that the value that I get when I use alert(selectedComps.duration) is very strange for me. In the timeline we can see fps and timecode (0:00:00:00) but the value I get from that alert is "x.yyy", I can see that x is the amount in seconds of the composition but after "." they are decimals that I cant figure it out how it works. I soupose is the fps divided by a number I dont know...

I'm thinking in a text box to get the first number (seconds), do praseFloat() and get a real number. Also other box to get the frames and apply a math function to it. Do you guys knows any math function I can use?

Thanks!


Return to posts index

Andrei Popa
Re: real value to change comp duration
on Aug 31, 2017 at 8:10:10 am

var compLength = selectedComps.duration;
var minutes = Math.floor(compLength / 60);
var seconds = Math.floor(compLength % 60);
var frames = Math.round((compLength - Math.floor(compLength))/selectedComps.frameDuration);
alert (minutes +":"+ seconds +":"+ frames);

I don't know if it works with multiple selected comps.

Andrei


Return to posts index

Rainier Raydán
Re: real value to change comp duration
on Aug 31, 2017 at 1:36:14 pm

Nice! Thanks Andrei!

But I need to change the duration of the comp with this values

I want to set the minutes, the seconds and the number of frames with this UI but I dont know how!


Return to posts index


Andrei Popa
Re: real value to change comp duration
on Aug 31, 2017 at 6:20:10 pm

You just reverse the process. Lets say the variables for the texts of this GUI are sec,min,fps,frames.

min*60 + sec + frames/fps

Andrei


Return to posts index

Rainier Raydán
Re: real value to change comp duration
on Sep 1, 2017 at 8:29:28 pm

Ok I have this

var compLength = app.project.activeItem.duration;
var minutes =2
var seconds = 15
var frames = 20;

minSec = (minutes*60)+seconds;

realFrames = frames /app.project.activeItem.frameDuration;

finalDuration = parseFloat (minSec +"."+realFrames);

app.project.activeItem.duration = finalDuration;


But the comp duration still wrong. It has to be 02:15:20 (it's a 25 frames comp) but the script result is 02:15:13...


Return to posts index

Andrei Popa
Re: real value to change comp duration
on Sep 2, 2017 at 6:09:51 am

That is because you used frameDuration instead of fps. Fps is 1/frameDuration, which makes your realFrames value frames*app.project.activeItem.frameDuration. The script would be like this
var compLength = app.project.activeItem.duration;
var minutes =2
var seconds = 15
var frames = 20;

minSec = (minutes*60)+seconds;

realFrames = frames *app.project.activeItem.frameDuration;

finalDuration = minSec +realFrames;

app.project.activeItem.duration = finalDuration;


Andrei


Return to posts index


Rainier Raydán
Re: real value to change comp duration
on Sep 3, 2017 at 12:44:32 pm

Wow! That help! It worked just fine but when the comp is 23.976 fps it doesnt work... when the minutes value its greater thant 0 the results in frame and in seconds doesnt match... minutes = 1, secondes = 10 and frames = 5 and the result is 0:01:10:03...


Return to posts index

Andrei Popa
Re: real value to change comp duration
on Sep 4, 2017 at 6:51:49 am

It seems that there is a problem with this framerate. Even if you put an integer as the duration, you get some frames.

Andrei


Return to posts index

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