Skip to content

stubs

SelfPropEnum module-attribute

SelfPropEnum = TypeVar('SelfPropEnum', bound=PropEnum)

PropEnum

Bases: CustomIntEnum

pretty_string property

pretty_string: str

Get a pretty, displayable string of the enum member.

string property

string: str

Get the string representation used in resize plugin/encoders.

apply

apply(clip: VideoNode) -> VideoNode

Applies the property to the VideoNode.

Source code
122
123
124
125
def apply(self: SelfPropEnum, clip: vs.VideoNode) -> vs.VideoNode:
    """Applies the property to the VideoNode."""

    return clip.std.SetFrameProp(self.prop_key, self.value)

ensure_presence classmethod

ensure_presence(
    clip: VideoNode,
    value: int | SelfPropEnum | None,
    func: FuncExceptT | None = None,
) -> VideoNode

Ensure the presence of the property in the VideoNode.

Source code
112
113
114
115
116
117
118
119
120
@classmethod
def ensure_presence(
    cls: type[SelfPropEnum], clip: vs.VideoNode, value: int | SelfPropEnum | None, func: FuncExceptT | None = None
) -> vs.VideoNode:
    """Ensure the presence of the property in the VideoNode."""

    enum_value = cls.from_param_or_video(value, clip, True, func)

    return clip.std.SetFrameProp(enum_value.prop_key, enum_value.value)

ensure_presences staticmethod

ensure_presences(
    clip: VideoNode,
    prop_enums: Iterable[type[SelfPropEnum] | SelfPropEnum],
    func: FuncExceptT | None = None,
) -> VideoNode

Ensure the presence of multiple PropEnums at once.

Source code
127
128
129
130
131
132
133
134
135
136
137
138
139
@staticmethod
def ensure_presences(
    clip: vs.VideoNode, prop_enums: Iterable[type[SelfPropEnum] | SelfPropEnum], func: FuncExceptT | None = None
) -> vs.VideoNode:
    """Ensure the presence of multiple PropEnums at once."""

    return clip.std.SetFrameProps(**{
        value.prop_key: value.value  # type: ignore
        for value in [
            cls if isinstance(cls, PropEnum) else cls.from_video(clip, True)
            for cls in prop_enums
        ]
    })

from_param classmethod

from_param(value: None, func_except: FuncExceptT | None = None) -> None
from_param(
    value: int | SelfPropEnum, func_except: FuncExceptT | None = None
) -> SelfPropEnum
from_param(
    value: int | SelfPropEnum | None, func_except: FuncExceptT | None = None
) -> SelfPropEnum | None
from_param(value: Any, func_except: Any = None) -> SelfPropEnum | None

Get the enum member from its int representation.

Source code
63
64
65
@classmethod
def from_param(cls: Any, value: Any, func_except: Any = None) -> SelfPropEnum | None:
    """Get the enum member from its int representation."""

from_param_or_video classmethod

from_param_or_video(
    value: Any,
    src: VideoNode | VideoFrame | FrameProps,
    strict: bool = False,
    func_except: FuncExceptT | None = None,
) -> SelfPropEnum

Get the enum member from a value that can be casted to this prop value or grab it from frame properties.

If strict=False, gather the heuristics using the clip's size or format.

Parameters:

  • value

    (Any) –

    Value to cast.

  • src

    (VideoNode | VideoFrame | FrameProps) –

    Clip to get prop from.

  • strict

    (bool, default: False ) –

    Be strict about the frame properties. Default: False.

  • func_except

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling.

Source code
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
@classmethod
def from_param_or_video(
    cls: type[SelfPropEnum], value: Any,
    src: vs.VideoNode | vs.VideoFrame | vs.FrameProps,
    strict: bool = False, func_except: FuncExceptT | None = None
) -> SelfPropEnum:
    """
    Get the enum member from a value that can be casted to this prop value
    or grab it from frame properties.

    If `strict=False`, gather the heuristics using the clip's size or format.

    :param value:           Value to cast.
    :param src:             Clip to get prop from.
    :param strict:          Be strict about the frame properties. Default: False.
    :param func_except:     Function returned for custom error handling.
    """
    value = cls.from_param(value, func_except)

    if value is not None:
        return value  # type: ignore

    return cls.from_video(src, strict, func_except)

from_res classmethod

from_res(frame: VideoNode | VideoFrame) -> SelfPropEnum

Get an enum member from the video resolution with heuristics.

Source code
73
74
75
76
77
@classmethod
def from_res(cls: type[SelfPropEnum], frame: vs.VideoNode | vs.VideoFrame) -> SelfPropEnum:
    """Get an enum member from the video resolution with heuristics."""

    raise NotImplementedError

from_video classmethod

from_video(
    src: VideoNode | VideoFrame | FrameProps,
    strict: bool = False,
    func: FuncExceptT | None = None,
) -> SelfPropEnum

Get an enum member from the frame properties or optionally fall back to resolution when strict=False.

Source code
79
80
81
82
83
84
85
86
@classmethod
def from_video(
    cls: type[SelfPropEnum], src: vs.VideoNode | vs.VideoFrame | vs.FrameProps, strict: bool = False,
    func: FuncExceptT | None = None
) -> SelfPropEnum:
    """Get an enum member from the frame properties or optionally fall back to resolution when strict=False."""

    raise NotImplementedError

is_unknown classmethod

is_unknown(value: int | SelfPropEnum) -> bool

Whether the value represents an unknown value.

Source code
24
25
26
27
28
@classmethod
def is_unknown(cls: type[SelfPropEnum], value: int | SelfPropEnum) -> bool:
    """Whether the value represents an unknown value."""

    return False

is_valid classmethod

is_valid(value: int) -> bool

Check if the given value is a valid int value of this enum.

Source code
153
154
155
156
@classmethod
def is_valid(cls, value: int) -> bool:
    """Check if the given value is a valid int value of this enum."""
    return int(value) in map(int, cls.__members__.values())

prop_key

prop_key() -> str

The key used in props to store the enum.

Source code
30
31
32
33
34
@classproperty
def prop_key(cls: type[SelfPropEnum]) -> str:  # type: ignore
    """The key used in props to store the enum."""

    return f'_{cls.__name__}'