Skip to main content
Participating Frequently
July 21, 2022
Question

How to create a mask by specifying a frame

  • July 21, 2022
  • 2 replies
  • 408 views

 

I'm looking for a way to create a frame-based mask from a script (jsx).

 

I can create a mask based on time (seconds) with addKey (), but I don't know how to mask based on the frame.

keyIndex1 = newMask.property(1).addKey(frame * frameDuration);
newMask.property(1).setInterpolationTypeAtKey(keyIndex1, KeyframeInterpolationType.HOLD);

 

If anyone knows how to create a mask based on a frame without using addkey (), please let me know.

This topic has been closed for replies.

2 replies

Mathias Moehl
Community Expert
Community Expert
July 21, 2022

Not sur ewhat your question is. You already have the answer how to convert number of frames to a time in seconds in your example:

frame * frameDuration
Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Participating Frequently
July 26, 2022

In the official addKey () function description, the addKey argument specifies the number of seconds.
Basically, there is no problem with specifying the number of seconds.
But,In the case of a long movie (after about 8 minutes), problems such as the mask collapsing, the rotobeje not being applied, and an unrelated mask appearing will occur.

 

https://community.adobe.com/t5/after-effects-discussions/unable-to-create-rotobezier-mask-on-long-video/m-p/12950419#M200819 

 

While investigating the cause of the problem, I suspect that the cause is that the number of digits in the value of frame * frameDuration becomes large.
On the other hand, if you reduce the number of digits in frame * frameDuration, the frame will deviate from the frame you want to mask, so you cannot reduce the number of digits poorly.
Therefore, this time I was looking for a method that can be set on a frame-by-frame basis.

Mylenium
Legend
July 21, 2022

Time conversion methods such as frameToTime() are available both in scripts and expressions. That's all you need.

 

Mylenium

Participating Frequently
July 26, 2022

The frameToTime () function was not recognized as a function in the script.
By the way, is there any other way to convert to frame unit?