ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Global time variable in time remapped compositions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Peter Nepp
Global time variable in time remapped compositions
on Dec 5, 2019 at 4:14:18 pm

Hi,

I've an issue with accessing the 'time' attribute globally.

I want to access the 'time' attribute from a expression within a time-remapped composition. Sadly the
value I am getting from 'time' doesn't represent the actual global time, instead it is also remapped.

Is there a workaround for this situation?

Thanks a lot,
Peter


Return to posts index

Alex Printz
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 3:39:00 pm

'time' is not really a global attribute that is the same across all comps; time is the attribute to which frame the playhead is on in the current comp.

If you nest a comp, it's always dependent on where the playhead is in the the main comp relative to it's own inPoint and where the footage is trimmed.

A potential hack-y workaround I can see is to make the nested comp look to the the parent comp, look for the layer that is itself inside that parent comp, and then search frame-by-frame forward through keyframes on a timeRemap on itself and compare until the timeRemap value is equal to it's current time, and then you can grab that keyframe's time in the parent comp. This will only work if you never repeat timeRemap values; you could try to filter by inPoints as well, but it might be a mess.

something like this for the hacky code inside the nested comp (not tested):

var targetComp = comp("parentComp");
var targetLayer = targetComp.layer(thisComp.name);

var i = timeToFrames(targetLayer.inPoint)

while(true){
if (i == timeToFrames(targetLayer.outPoint) || i == timeToFrames(targetComp.duration)){ i=0; break;} //runs out of timeRemap;
if (time == targetLayer.timeRemap.valueAtTime(framesToTime(i))) break; //finds the corresponding time
i++; //else
}

parentGlobalTime = framesToTime(i);


Alex Printz
Mograph Designer


Return to posts index

Alex Printz
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 4:03:02 pm

I had to make one minor tweak, I had to round them both time values to the nearest whole frame and compare them; I was getting sub-frames when stretching the time remap. Again, this works so long as you are not repeating the same sections over and over:

var targetComp = comp("parentComp");
var targetLayer = targetComp.layer(thisComp.name);

var i = timeToFrames(targetLayer.inPoint)

while(true){
if (i == timeToFrames(targetLayer.outPoint) || i == timeToFrames(targetComp.duration)){ i=0; break;} //runs out of timeRemap;

targetTime = timeToFrames(targetLayer.timeRemap.valueAtTime(framesToTime(i)));
roundedTime = Math.round(timeToFrames(time));

if ( roundedTime == targetTime ) break; //finds the corresponding time
i++; //else
}

parentGlobalTime = framesToTime(i);


Alex Printz
Mograph Designer


Return to posts index


Alex Printz
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 4:13:52 pm

Also one final note, if you stretch the sub-comp's time-remap so that it's frame duration becomes longer than the main comp's frame duration, you're going to get slightly staggered effects where the subComps cannot read/react in a short enough time span and will bleed across. Weird effect.

Alex Printz
Mograph Designer


Return to posts index

Peter Nepp
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 4:12:08 pm

Hi Alex,

thank you very much for your help.

Sadly your approach won't work, because the time remapping is controlled by another expression not by keyframes and secondly I definitely need to repeat time remapping values to create loops with the remapped comps. ☹

I already tried to store the 'time' value of the parent composition via $.setenv(), and grabbing it in the sub comp via $.getenv(). But this approach won't work either, because AE seems to have some issues, maybe with threading or something else with accessing the environment. It's partially working, but at some unspecific point, the values are absolutely wrong.

I'm trying to wrap my head around this issue for the last couple of days. I can't figure it out yet.

Peter


Return to posts index

Alex Printz
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 4:16:42 pm

Okay, well without knowing what specifically you're looking for then I can't be of much help, occasionally the essential graphics panel will help with doing some concepts that would otherwise break dependency loops. Perhaps look to some of the stuff you can do there?

Alex Printz
Mograph Designer


Return to posts index


Alex Printz
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 4:19:18 pm

You could always try pushing a slider called "master time" into the essential graphics, plug all of your sub-comp expressions into that master time, use that master time for calling whatever properties you need, and then inside your parent comp link the essential properties to the parent's time value? That way it pushes it into the comp and can repeat loops.

Alex Printz
Mograph Designer


Return to posts index

Peter Nepp
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 5:01:11 pm

Hi Alex,

I tried a similar thing with a slider expression control. I stored the master comp time there and tried to access this time via expression in a time remapped ( and looped at certain point in time) composition. But I've to access the master time slider via 'valueAtTime(time)' (do I?), but since 'time' is the 'local time' I won't get the right results. Or did I miss something here?

Sorry, I didn't use AE for a long time, so I don't know exactly what the Essential Graphics stuff is. 😉 What is the difference with the approach you described to the one I tried with the master time slider?

Peter


Return to posts index

Alex Printz
Re: Global time variable in time remapped compositions
on Dec 6, 2019 at 5:59:57 pm

Yeah it's not going to work, I forgot master properties still need to be moving in the time dimension to re-render frames; if you pause, rewind, etc. it won't work because they've already been calculated so won't change. I just tested it and it failed.

Sorry, out of ideas. You're going to need to get creative with duplicating content instead of looping it.

Alex Printz
Mograph Designer


Return to posts index


Peter Nepp
Re: Global time variable in time remapped compositions
on Jan 15, 2020 at 3:07:59 pm

Hi Alex,

I'm sorry for the delay. Many thanks again for all your support.

I didn't find a solution yet, I also had a close look into the SDK of After Effects, but sadly due to certain limitations of the SDK I couldn't write a plug-in to workaround this issue.

I'm going to start with a scripting solution to have multiple layers as instances instead a single time-remapped one.

Thanks,
Peter

PS: Happy new year. :)


Return to posts index

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