ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression to link Shape data to position coordinates

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Max Wolkowitz
Expression to link Shape data to position coordinates
on Apr 25, 2017 at 9:42:46 pm

Here's my conundrum:

I'm trying to solve a lip sync problem I'm having. In the past I have set up rigs that link position coordinates on a grid to a time remapped precomp in order to speed up the process of lip syncing. However, I now want to do something similar with a shape layer so that there will be tweening as opposed to just still phoneme frames and it's a little trickier.

Is there a way to set keyframes on a reference shape layer and define that path keyframe data (i.e. the phoneme shape the mouth is at each keyframe) as a variable using expressions? I'd like to set up an if/else type of situation where that path keyframe data is the result of moving a null to positions on a grid. Not sure if this is even possible.

Can anyone help me out?


Return to posts index

Dan Ebberts
Re: Expression to link Shape data to position coordinates
on Apr 25, 2017 at 10:16:35 pm

Expressions don't have access to path vertex data.

You could create a script to do it though. Your workflow might be something like you get all the phoneme names set up on the time line where you want them (using marker comments) and then run the script to drop in the appropriate vertex keyframes at the markers.

One extreme expression solution might be to keyframe all possible phoneme transitions and then the expression could use valueAtTime() to provide the proper tweening. It might be a pain to set up the first time, but it should work.


Dan



Return to posts index

Liam Smith
Re: Expression to link Shape data to position coordinates
on May 31, 2017 at 5:47:36 am

Hi Dan,

Thanks for clearing this up 'expressions don't have access to vertex data' this makes a lot of sense. So i'm looking to make a script for this with limited scripting knowledge (I cringe typing that but very excited to start) and wondered what some of the frame work would look like. you mention the following..

[Dan Ebberts] "Your workflow might be something like you get all the phoneme names set up on the time line where you want them (using marker comments) and then run the script to drop in the appropriate vertex keyframes at the markers.
"


So these are my thoughts and for this example I will say there are 14 phonemes (mouth shapes).

So would you have one shape layer with a keyframed path. Every frame for 14 frames would have a keyframe and be a different mouth shape. For example frame 1 = A, frame 2 = E, frame 3 = O etc

Ideally the 'controller' would be a null where by numerical values linked to a expression slider controller determine which keyframe has been selected. By numerical values it could look something like 1 = A, 2 = E, 3 = O etc.

So aside from the scripting task ahead. Do you think it would be possible to interpolate between the mouth shapes mid shape? So in dialogue we don't usually go from a resting position to the full mouth shape to the resting position. It would be great to switch midway between on mouth shape and rest on another in a fluid manner.

Thanks
Liam


Return to posts index


Dan Ebberts
Re: Expression to link Shape data to position coordinates
on May 31, 2017 at 4:13:39 pm

I think so (if I understand what you're suggesting). I was thinking you would use markers to set the timing of the phonemes, but I guess a keyframed slider would work as well. Your script would drop a keyframe for the appropriate vertex data matching the phoneme at each marker/keyframe. The tweening would happen automatically. Is that what you meant?


Dan



Return to posts index

Liam Smith
Re: Expression to link Shape data to position coordinates
on Jun 2, 2017 at 12:19:18 am

Hi Dan,

Yes thats what I'm thinking. I understand my issue but struggle to articulate it that well.

I have used your very helpful tutorials for expressions and started to delve into https://www.codecademy.com/learn and this PDF https://blogs.adobe.com/creativecloud/files/2012/06/After-Effects-CS6-Scrip.... Are there any resources or starting points that you would suggest to start making scripts. I feel a little lost with no place to start from.

Thanks again for your time!

Liam


Return to posts index

Dan Ebberts
Re: Expression to link Shape data to position coordinates
on Jun 2, 2017 at 1:28:00 am

Here maybe:

https://www.provideocoalition.com/after-effects-extendscript-training-compl...

Dan



Return to posts index


Liam Smith
Re: Expression to link Shape data to position coordinates
on Jun 2, 2017 at 3:29:49 am

Thanks Dan, thats great.


Return to posts index

Steve Sierra
Re: Expression to link Shape data to position coordinates
on Apr 26, 2017 at 5:21:59 am

Hi,

I am also working on a shape lipsync, here's my workflow :

1. I use papagayo (http://www.lostmarble.com/papagayo/) and lipsync v1 (http://www.dubon.fr/dubon-developpe/lipsync/) to get a time remapped keyframes of my mouthshapes.

2. I create a "Mouths" shape layer with all the phonemes keyframed in the same order and same times as in the timeremapped comp. So you'de have somthing like "A" keyed on frame 0, "E" keyed on frame 1, "O" keyed on frame 3, etc... It HAS to be same order and same times.

3. This is where my script starts, but you can do it manually:
- create the "Final Mouth" shape layer
- put this expression in the "Final Mouth" path property, it translates the timeremapped time keys to frame keys :

finalMouthPath.expression = 'timeToFrames(thisComp.layer("TimeRemappedLayer").timeRemap.valueAtTime(time))';

- bake the expression in script using (or do it manually : Animation/KeyFrame assistant/convert expression to keyframes):

finalMouthPath.selected = true;
app.executeCommand(app.findMenuCommandId("Convert Expression to Keyframes"));

- remove keyframes where time remapped layer does not have keyframes (check out a previous post of mine where Xavier Gomez helps me out to find 2 solutions for this)

You should now have a keyframed shape layer !

To go a bit further, I copy the final Mouth path to a solid layer's mask path, apply mask interpolation to it and copy the keys back to the final mouth layer.

Hope this is clear enough... and helps you out.

Cheers !


Return to posts index

Edward Chow
Re: Expression to link Shape data to position coordinates
on Apr 26, 2017 at 7:00:27 pm

11300_screenshot20170426at2.56.15pm.png.zip

Sorry! I was lost after step 3. I made a new shape layer and then added the expression but I am receiving an error. Do i need to copy the Path data from the original Mouths layer for it to work? is the first part supposed to correspond to the layer name? Final Mouth Path.expression or is it still finalMouthPath.expression ?

finalMouthPath.expression = 'timeToFrames(thisComp.layer("TimeRemappedLayer").timeRemap.valueAtTime(time))';


Return to posts index


Steve Sierra
Re: Expression to link Shape data to position coordinates
on Apr 27, 2017 at 4:05:27 am

Hi,

Sorry for not beeing clear enough...
You have to change ("TimeRemappedLayer") by the name of your time remapped layer between quotes and parenthesis. If the layer's name is myMouths, the expression would be :

finalMouthPath.expression = 'timeToFrames(thisComp.layer("myMouths").timeRemap.valueAtTime(time))';

Does this fix it ?

Cheers !


Return to posts index

Edward Chow
Re: Expression to link Shape data to position coordinates
on Apr 27, 2017 at 4:13:24 am

Yes I tried copying that in and renaming the name . It doesn't recognize finalMouthPath.expression . I included a screenshot . Do I apply the expression on a fresh shape layer or on a duplicate of the phenomes?

Thanks so much
Ed


Return to posts index

Steve Sierra
Re: Expression to link Shape data to position coordinates
on Apr 27, 2017 at 4:40:57 am

Sorry,

I didn't see your screenshot.
What I wrote was for a script.
For the expression, you just have to put this on the path property :

timeToFrames(thisComp.layer("myMouths").timeRemap.valueAtTime(time));

Does that work for you ?

Cheers !


Return to posts index


Edward Chow
Re: Expression to link Shape data to position coordinates
on Apr 27, 2017 at 9:19:53 pm



Hi, Thanks for the response!
I still can't manage to get the expression to work.
it says an object of type 0 found where a property is needed. I don't understand how the expression is linking time remap data from the lipsyncV1.0 pre comp to the new shape layer.

as your instructions stated I imported my DATA file from papagayo and i see the timeremap keyframes on the pre comp.
so far so good

so then i create a set of shape layer phonemes exactly like the ones inside the pre comp and in the same order as well.

this is where i get a little confused.

now you say to make a new shape layer. do i copy those phonemes into this new shape layer? I then add the expression you gave me to the path and it just gives me an error. I don't think the shape layer likes taking time remap information.

Thanks a lot for taking a look, I am just super confused. I hope I am not totally screwing this up. I can collect an after effects project if I am being confusing.

Thanks again,
Ed


Return to posts index

Steve Sierra
Re: Expression to link Shape data to position coordinates
on Apr 28, 2017 at 3:41:48 am

Hi Ed,

This is where my if/else statement comes to work 😉 I had forgotten the reason, but here it is :
Keys start at 1, time starts at 0. So when the time remap hits 0, you have to tell it to go to one of your mouth shapes (8 is the rest mouth in my case). That's why the error says it has 0 when it needs a property (that starts at 1 in this case).

So the expression has to be :

var a = timeToFrames(thisComp.layer("1 - Mouth 1").timeRemap.valueAtTime(time));

if(a==0){
thisComp.layer("Mouths").content("Shape 1").content("Path 1").path.key(8);
}else{
thisComp.layer("Mouths").content("Shape 1").content("Path 1").path.key(a);
}

Does that fix it for you ?

Cheers !


Return to posts index

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