Skip to content

Keyframe

Keyframe

The Keyframe object represents a keyframe of a property.

Example
from py_aep import parse

app = parse("project.aep")
comp = app.project.compositions[0]
position = comp.layers[0].transform.property("ADBE Position")
keyframe = position.keyframes[0]
print(keyframe.time)
Warning

Keyframe object does not exist in ExtendScript API. It has been added for convenience.

Attributes

frame_time

frame_time: int

Time of the keyframe, in whole composition frames.

A rounded view of time. After Effects places keyframes off the frame grid freely, so this is lossy for those - read time when precision matters.

in_interpolation_type

in_interpolation_type = enum(
    KeyframeInterpolationType,
    "_ldat_item",
    "in_interpolation_type",
    validate=_validate_interpolation_type,
)

The "in" interpolation type for the keyframe. Read / Write.

Raises ValueError if the type is not valid for the owning property (see is_interpolation_type_valid).

in_spatial_tangent

in_spatial_tangent: list[float] | None

The incoming spatial tangent for the keyframe, if the named property is spatial (that is, the value type is TwoD_SPATIAL or ThreeD_SPATIAL).

  • If the property value type is PropertyValueType.TwoD_SPATIAL, the list contains 2 floating-point values.
  • If the property value type is PropertyValueType.ThreeD_SPATIAL, the list contains 3 floating-point values.
  • If the property value type is neither of these types, returns None.

in_temporal_ease

in_temporal_ease: list[KeyframeEase]

The incoming temporal ease for the keyframe.

Array of KeyframeEase objects: - If the property value type is PropertyValueType.TwoD, the list contains 2 objects. - If the property value type is PropertyValueType.ThreeD, the list contains 3 objects. - For any other value type, the list contains 1 object.

label

label = enum(Label, '_ldat_item', 'label')

The label color. Colors are represented by their number (0 for None, or 1 to 16 for one of the preset colors in the Labels preferences). Read / Write.

out_interpolation_type

out_interpolation_type = enum(
    KeyframeInterpolationType,
    "_ldat_item",
    "out_interpolation_type",
    validate=_validate_interpolation_type,
)

The "out" interpolation type for the keyframe. Read / Write.

Raises ValueError if the type is not valid for the owning property (see is_interpolation_type_valid).

out_spatial_tangent

out_spatial_tangent: list[float] | None

The outgoing spatial tangent for the keyframe, if the named property is spatial (that is, the value type is TwoD_SPATIAL or ThreeD_SPATIAL).

  • If the property value type is PropertyValueType.TwoD_SPATIAL, the list contains 2 floating-point values.
  • If the property value type is PropertyValueType.ThreeD_SPATIAL, the list contains 3 floating-point values.
  • If the property value type is neither of these types, returns None.

out_temporal_ease

out_temporal_ease: list[KeyframeEase]

The outgoing temporal ease for the keyframe.

Array of KeyframeEase objects: - If the property value type is PropertyValueType.TwoD, the list contains 2 objects. - If the property value type is PropertyValueType.ThreeD, the list contains 3 objects. - For any other value type, the list contains 1 object.

roving

roving = bool(
    "_ldat_item",
    "roving",
    validate=_validate_roving,
    post_set="_on_roving_set",
)

True if the keyframe is roving. The first and last keyframe in a property cannot rove. Read / Write.

spatial_auto_bezier

spatial_auto_bezier: bool

True if the keyframe has spatial auto-Bezier interpolation. This type of interpolation affects this keyframe only if spatial_continuous is also True. If the property value type is neither TwoD_SPATIAL nor ThreeD_SPATIAL, the value is False.

spatial_continuous

spatial_continuous: bool

True if the keyframe has spatial continuity. If the property value type is neither TwoD_SPATIAL nor ThreeD_SPATIAL, the value is False.

temporal_auto_bezier

temporal_auto_bezier = bool(
    "_ldat_item",
    "temporal_auto_bezier",
    post_set="_on_temporal_auto_bezier_set",
)

True if the keyframe has temporal auto-Bezier interpolation. Temporal auto-Bezier interpolation affects this keyframe only if the keyframe interpolation type is KeyframeInterpolationType.BEZIER for both in_interpolation_type and out_interpolation_type. Read / Write.

temporal_continuous

temporal_continuous = bool(
    "_ldat_item",
    "temporal_continuous",
    post_set="_on_temporal_continuous_set",
)

True if the keyframe has temporal continuity. Temporal continuity affects this keyframe only if the keyframe interpolation type is KeyframeInterpolationType.BEZIER for both in_interpolation_type and out_interpolation_type. Read / Write.

time

time: float

Time of the keyframe, in seconds.

Exact: the binary stores an integer count of composition timebase units relative to the layer's start, and AE places keyframes between frames freely - setValueAtTime(1.5) in a 25 fps comp lands on frame 37.5, and every roving keyframe is positioned by arc length rather than snapped to the grid.

Writable: moving a keyframe past a neighbour re-sorts the property's keyframes (and their backing chunks). Spatial/temporal tangents are left as-is, like dragging a keyframe in AE's timeline.

Raises:

  • ValueError

    When another keyframe already sits at the target time.

time_units

time_units: int

Raw keyframe time, as the binary stores it.

An integer count of composition timebase units, relative to the owning layer's start. Read-only; assign to time instead.

value

value: _ValueType

The value of the keyframe. For a 1D property (e.g. Opacity, Rotation), this is a single float. For a multi-dimensional property (e.g. Position, Scale), this is a list[float]. For shape/mask path properties, this is a Shape. For text properties, this is a TextDocument. For marker properties, this is a MarkerValue. For properties that carry no value, this is None.