Activity › Forums › Adobe After Effects Expressions › Time Remap controlled by SampleImage
-
Time Remap controlled by SampleImage
Posted by Jay Ingles on June 3, 2011 at 10:52 pmHow would i use sampleimage to change a layers “timeRemap” value from between 0 to 5?
I’ve precomposed a timeline that is 5 frames long and 400×400 pixels, each frame with a different shape. Duplicating that precomp to create a grid (image 1) i want the Black & White Luma matte (image 2) to control the time remap value. Ie Black = 0f, grey = 3f, White = 5f.
I’ve used sample image with affecting scale but can’t wrap my head around accomplishing it for this use.
In the past i’ve used the code below to do so with the Scale parameter.
Any help is appreciated, Thanks a lot!
size = thisComp.layer("luma").sampleImage([transform.position[0],transform.position[1]], [1,1] ,posteffect = true);transform.scale = [size[3]*100,size[3]*100,100];
Jay Ingles replied 8 years, 1 month ago 3 Members · 20 Replies -
20 Replies
-
Dan Ebberts
June 3, 2011 at 11:27 pmI haven’t tested this, but it’s probably going to look like this:
s = thisComp.layer(“luma”).sampleImage(transform.position,[.5,.5],true);
luma = rgbToHsl(s)[2];
maxFrame = 5;
f = Math.round(maxFrame*luma);
framesToTime(f)Dan
-
Jay Ingles
June 4, 2011 at 10:35 pmHi Dan,
Seems to work but i keep running into hundreds of “unsafe operation attempted” errors. I found this article that explains SampleImage has a flaw in it that can create this scenario.
https://forums.adobe.com/thread/693859
It suggest to add layer space transforms such as .toComp() for such operations. Likewise, when dealing with colors, always make sure to use the correct syntax to conatin all color components in arrays.
Adding that statement in creates an error and turns the expression off. I’m sure i’m doing it incorrectly but interested if you have experienced this.
Attempted this: framesToTime.toComp((f))
Thanks so much!
-
Dan Ebberts
June 4, 2011 at 10:56 pmTry it this way:
L = thisComp.layer(“luma”);
p = L.fromComp(toComp(transform.anchorPoint));
s = L.sampleImage(p,[.5,.5],true);
luma = rgbToHsl(s)[2];
maxFrame = 5;
f = Math.round(maxFrame*luma);
framesToTime(f)Dan
-
Arne Münch
July 8, 2012 at 3:46 pmHi Everybody
I am getting the same error and the whole world of google gives only 8 hits:
https://tinyurl.com/d36t5nzDan, your last script doesn´t seem to resolve the error, i am getting the same message like before.
Jay, Did you solve it someow?THanks for the great support here.
-
Dan Ebberts
July 8, 2012 at 5:11 pmI can’t generate that error, so I’m not sure how to fix it. One thing you want to avoid is using sampleImage() with time remapping in a way where the result of the expression can affect its own input. I don’t know if that applies to your case.
Dan
-
Arne Münch
July 9, 2012 at 1:01 pmHallo Dan
Thank you for your help.
I broke down my project to just two layers, and for every item I deleted, the error-message became more rarely, but it is still there.
I attached a very simple AE file. Have the layer FORM in MAIN selected, go into the FORM Comp, change the inpoint or the outpoint of the shapelayer, or the position of the rotation keyframe. Go Back to the main comp and change the color of the circle in the LUMA Layer. Repeat these steps, or change other things, and the error message will occur. I tested here on CS3 and with CS5 at work, several times.
And the more items are in the composition, the more often the error occurs. I get a little crazy I guess.
Here is the project-file:
4387_unbenanntesprojekt.aep.zip -
Arne Münch
July 9, 2012 at 1:15 pmChange the in and outpoints of the “Luma” layer also, and repeat the steps. The error will appear.
By the way: The problem isn´t this comp, I could easily live with that rarely appearing error message, but if I use this method to drive a grid of layers like in the first post, and have other things going on in the comp, it really gets annoying. -
Jay Ingles
July 9, 2012 at 1:22 pmHey All,
I ended up not resolving this issue and resorted to the Scale based SampleImage code pasted above.
Wish i could help more but not sure how to resolve it. Does precomposing the retimed footage help at all? Or is there any way to precomp it and point the remap to look inside the precomp?
Really not sure if this would work, but am throwing it out there incase it has to do with the order AE is doing it’s math.
Good luck! Please post here if you figure it out 🙂
-
Arne Münch
July 9, 2012 at 3:54 pmHi again
I couldn´t figure out how to avoid this nasty message. But I found a way to reproduce the error instantly in my example file.
Make a Ram Preview of MAIN. Go into FORM, grab and pull the In-point of the shape-layer forwards, got back to MAIN Comp and the Error will appear. If anyone could help here, It would be so great.
Reply to this Discussion! Login or Sign Up


