Skip to content

color

Classes:

Attributes:

  • ColorRangeT (TypeAlias) –

    Type alias for values that can be used to initialize a :py:attr:ColorRange.

  • MatrixT (TypeAlias) –

    Type alias for values that can be used to initialize a :py:attr:Matrix.

  • PrimariesT (TypeAlias) –

    Type alias for values that can be used to initialize a :py:attr:Primaries.

  • TransferT (TypeAlias) –

    Type alias for values that can be used to initialize a :py:attr:Transfer.

ColorRangeT module-attribute

ColorRangeT: TypeAlias = Union[int, ColorRange, ColorRange, HoldsPropValueT]

Type alias for values that can be used to initialize a :py:attr:ColorRange.

MatrixT module-attribute

MatrixT: TypeAlias = Union[int, MatrixCoefficients, Matrix, HoldsPropValueT]

Type alias for values that can be used to initialize a :py:attr:Matrix.

PrimariesT module-attribute

PrimariesT: TypeAlias = Union[int, ColorPrimaries, Primaries, HoldsPropValueT]

Type alias for values that can be used to initialize a :py:attr:Primaries.

TransferT module-attribute

TransferT: TypeAlias = Union[
    int, TransferCharacteristics, Transfer, HoldsPropValueT
]

Type alias for values that can be used to initialize a :py:attr:Transfer.

ColorRange

Bases: _ColorRangeMeta

Pixel Range (ITU-T H.265 Equations E-10 through E-20.

Methods:

  • apply

    Applies the property to the VideoNode.

  • ensure_presence

    Ensure the presence of the property in the VideoNode.

  • ensure_presences

    Ensure the presence of multiple PropEnums at once.

  • from_param

    Determine the ColorRange through a parameter.

  • from_param_or_video
  • from_res

    Guess the color range from the frame resolution.

  • from_video

    Obtain the color range of a clip from the frame properties.

  • is_unknown

    Whether the value represents an unknown value.

  • is_valid

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

  • prop_key

    The key used in props to store the enum.

Attributes:

  • FULL

    Full (PC) dynamic range, 0-255 in 8 bits.

  • LIMITED

    Studio (TV) legal range, 16-235 in 8 bits.

  • PC
  • TV
  • is_full (bool) –

    Check if ColorRange is full.

  • is_limited (bool) –

    Check if ColorRange is limited.

  • pretty_string (str) –

    Get a pretty, displayable string of the enum member.

  • string (str) –

    Get the string representation used in resize plugin/encoders.

  • value_vs (int) –

    VapourSynth (props) value.

  • value_zimg (int) –

    zimg (resize plugin) value.

FULL class-attribute instance-attribute

FULL = 0

Full (PC) dynamic range, 0-255 in 8 bits.

| Note that float clips should ALWAYS be FULL range! | RGB clips will ALWAYS be FULL range!

LIMITED class-attribute instance-attribute

LIMITED = 1

Studio (TV) legal range, 16-235 in 8 bits.

| This is primarily used with YUV integer formats.

PC class-attribute instance-attribute

PC = FULL

TV class-attribute instance-attribute

TV = LIMITED

is_full property

is_full: bool

Check if ColorRange is full.

is_limited property

is_limited: bool

Check if ColorRange is limited.

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.

value_vs property

value_vs: int

VapourSynth (props) value.

value_zimg property

value_zimg: int

zimg (resize plugin) value.

apply

apply(clip: VideoNodeT) -> VideoNodeT

Applies the property to the VideoNode.

Source code
127
128
129
130
def apply(self, clip: VideoNodeT) -> VideoNodeT:
    """Applies the property to the VideoNode."""

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

ensure_presence classmethod

ensure_presence(
    clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT

Ensure the presence of the property in the VideoNode.

Source code
117
118
119
120
121
122
123
124
125
@classmethod
def ensure_presence(
    cls, clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of the property in the VideoNode."""

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

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

ensure_presences staticmethod

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

Ensure the presence of multiple PropEnums at once.

Source code
132
133
134
135
136
137
138
139
140
141
142
143
144
@staticmethod
def ensure_presences(
    clip: VideoNodeT, prop_enums: Iterable[type[PropEnumT] | PropEnumT], func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of multiple PropEnums at once."""

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

from_param classmethod

from_param(value: None, func_except: FuncExceptT | None = None) -> None
from_param(
    value: int | ColorRange | ColorRangeT,
    func_except: FuncExceptT | None = None,
) -> Self
from_param(
    value: int | ColorRange | ColorRangeT | None,
    func_except: FuncExceptT | None = None,
) -> Self | None
from_param(value: Any, func_except: Any = None) -> Self | None

Determine the ColorRange through a parameter.

Parameters:

  • value

    (Any) –

    Value or ColorRange object.

  • func_except

    (Any, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • Self | None

    ColorRange object or None.

Source code
355
356
357
358
359
360
361
362
363
364
365
@classmethod
def from_param(cls, value: Any, func_except: Any = None) -> Self | None:
    """
    Determine the ColorRange through a parameter.

    :param value:           Value or ColorRange object.
    :param func_except:     Function returned for custom error handling.
                            This should only be set by VS package developers.

    :return:                ColorRange object or None.
    """

from_param_or_video classmethod

from_param_or_video(
    value: int | ColorRange | ColorRangeT | None,
    src: VideoNode | VideoFrame | FrameProps,
    strict: bool = False,
    func_except: FuncExceptT | None = None,
) -> ColorRange
Source code
367
368
369
370
371
372
373
@classmethod
def from_param_or_video(
    cls, value: int | ColorRange | ColorRangeT | None,
    src: vs.VideoNode | vs.VideoFrame | vs.FrameProps,
    strict: bool = False, func_except: FuncExceptT | None = None
) -> ColorRange:
    ...

from_res classmethod

from_res(frame: VideoNode | VideoFrame) -> ColorRange

Guess the color range from the frame resolution.

Source code
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
@classmethod
def from_res(cls, frame: vs.VideoNode | vs.VideoFrame) -> ColorRange:
    """Guess the color range from the frame resolution."""

    from ..utils import get_var_infos

    fmt, _, _ = get_var_infos(frame)

    if fmt.color_family == vs.RGB:
        return cls.FULL

    return cls.LIMITED

from_video classmethod

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

Obtain the color range of a clip from the frame properties.

Parameters:

  • src

    (VideoNode | VideoFrame | FrameProps) –

    Input clip, frame, or props.

  • strict

    (bool, default: False ) –

    Be strict about the frame properties. Sets the ColorRange as MISSING if prop is not there.

Returns:

Source code
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
@classmethod
def from_video(
    cls, src: vs.VideoNode | vs.VideoFrame | vs.FrameProps, strict: bool = False, func: FuncExceptT | None = None
) -> ColorRange:
    """
    Obtain the color range of a clip from the frame properties.

    :param src:                         Input clip, frame, or props.
    :param strict:                      Be strict about the frame properties.
                                        Sets the ColorRange as MISSING if prop is not there.

    :return:                            ColorRange object.
    """

    return _base_from_video(cls, src, UnsupportedColorRangeError, strict, func)

is_unknown classmethod

is_unknown(value: int | Self) -> bool

Whether the value represents an unknown value.

Source code
29
30
31
32
33
@classmethod
def is_unknown(cls, value: int | Self) -> 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
160
161
162
163
@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
35
36
37
38
39
@classproperty
def prop_key(cls) -> str:
    """The key used in props to store the enum."""

    return f'_{cls.__name__}'

Matrix

Bases: _MatrixMeta

Matrix coefficients (ITU-T H.265 Table E.5).

Methods:

  • apply

    Applies the property to the VideoNode.

  • ensure_presence

    Ensure the presence of the property in the VideoNode.

  • ensure_presences

    Ensure the presence of multiple PropEnums at once.

  • from_param

    Determine the Matrix through a parameter.

  • from_param_or_video
  • from_primaries

    Obtain the matrix from a Primaries object.

  • from_res

    Guess the matrix based on the clip's resolution.

  • from_transfer

    Obtain the matrix from a Transfer object.

  • from_video

    Obtain the matrix of a clip from the frame properties.

  • is_unknown

    Check if Matrix is Matrix.UNKNOWN.

  • is_valid

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

  • prop_key

    The key used in props to store the enum.

Attributes:

BT2020CL class-attribute instance-attribute

BT2020CL = 10

KR = 0.2627; KB = 0.0593
Rec. ITU-R BT.2020-2 constant luminance system See ITU-T H.265 Equations E-49 to E-58

BT2020NCL class-attribute instance-attribute

BT2020NCL = 9

KR = 0.2627; KB = 0.0593
Rec. ITU-R BT.2020-2 non-constant luminance system Rec. ITU-R BT.2100-2 Y′CbCr See ITU-T H.265 Equations E-28 to E-30

BT470BG class-attribute instance-attribute

BT470BG = 5

KR = 0.299; KB = 0.114
(Functionally the same as :py:attr:Matrix.SMPTE170M) Rec. ITU-R BT.470-6 System B, G (historical) Rec. ITU-R BT.601-7 625 Rec. ITU-R BT.1358-0 625 (historical) Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM IEC 61966-2-1 sYCC IEC 61966-2-4 xvYCC601 See ITU-T H.265 Equations E-28 to E-30

BT601_525 class-attribute instance-attribute

BT601_525 = SMPTE170M

BT601_625 class-attribute instance-attribute

BT601_625 = BT470BG

BT709 class-attribute instance-attribute

BT709 = 1

Kr = 0.2126; Kb = 0.0722
Rec. ITU-R BT.709-6 Rec. ITU-R BT.1361-0 conventional colour gamut system and extended colour gamut system (historical) IEC 61966-2-4 xvYCC709 SMPTE RP 177 (1993) Annex B

CHROMACL class-attribute instance-attribute

CHROMACL = 13

# See ITU-T H.265 Equations E-22 to E-27
Chromaticity-derived constant luminance system See ITU-T H.265 Equations E-49 to E-58

CHROMANCL class-attribute instance-attribute

CHROMANCL = 12

# See ITU-T H.265 Equations E-22 to E-27
Chromaticity-derived non-constant luminance system See ITU-T H.265 Equations E-28 to E-30

FCC class-attribute instance-attribute

FCC = 4

KR = 0.30; KB = 0.11
FCC Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) See ITU-T H.265 Equations E-28 to E-30

GBR class-attribute instance-attribute

GBR = RGB

ICTCP class-attribute instance-attribute

ICTCP = 14

ICtCp
Rec. ITU-R BT.2100-2 ICTCP See ITU-T H.265 Equations E-62 to E-64 for transfer_characteristics value 16 (PQ) See ITU-T H.265 Equations E-65 to E-67 for transfer_characteristics value 18 (HLG)

RGB class-attribute instance-attribute

RGB = 0

# Identity
The identity matrix. Typically used for GBR (often referred to as RGB); however, may also be used for YZX (often referred to as XYZ) IEC 61966-2-1 sRGB SMPTE ST 428-1 (2006) See ITU-T H.265 Equations E-31 to E-33

SMPTE170M class-attribute instance-attribute

SMPTE170M = 6

Kr = 0.299; Kb = 0.114
(Functionally the same as :py:attr:Matrix.BT470BG) Rec. ITU-R BT.601-7 525 Rec. ITU-R BT.1358-1 525 or 625 (historical) Rec. ITU-R BT.1700-0 NTSC SMPTE ST 170 (2004) See ITU-T H.265 Equations E-28 to E-30

SMPTE240M class-attribute instance-attribute

SMPTE240M = 7

KR = 0.212; KB = 0.087
SMPTE ST 240 (1999, historical) See ITU-T H.265 Equations E-28 to E-30

UNKNOWN class-attribute instance-attribute

UNKNOWN = 2

Image characteristics are unknown or are determined by the application.

YCGCO class-attribute instance-attribute

YCGCO = 8

KR = 0.2126; KB = 0.0722
See Implementation And Evaluation Of Residual Color Transform For 4:4:4 RGB Lossless Coding

pretty_string property

pretty_string: str

string property

string: str

apply

apply(clip: VideoNodeT) -> VideoNodeT

Applies the property to the VideoNode.

Source code
127
128
129
130
def apply(self, clip: VideoNodeT) -> VideoNodeT:
    """Applies the property to the VideoNode."""

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

ensure_presence classmethod

ensure_presence(
    clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT

Ensure the presence of the property in the VideoNode.

Source code
117
118
119
120
121
122
123
124
125
@classmethod
def ensure_presence(
    cls, clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of the property in the VideoNode."""

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

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

ensure_presences staticmethod

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

Ensure the presence of multiple PropEnums at once.

Source code
132
133
134
135
136
137
138
139
140
141
142
143
144
@staticmethod
def ensure_presences(
    clip: VideoNodeT, prop_enums: Iterable[type[PropEnumT] | PropEnumT], func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of multiple PropEnums at once."""

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

from_param classmethod

from_param(value: None, func_except: FuncExceptT | None = None) -> None
from_param(
    value: int | Matrix | MatrixT, func_except: FuncExceptT | None = None
) -> Self
from_param(
    value: int | Matrix | MatrixT | None, func_except: FuncExceptT | None = None
) -> Self | None
from_param(value: Any, func_except: Any = None) -> Self | None

Determine the Matrix through a parameter.

Parameters:

  • value

    (Any) –

    Value or Matrix object.

  • func_except

    (Any, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self | None

    Matrix object or None.

Source code
221
222
223
224
225
226
227
228
229
230
@classmethod
def from_param(cls, value: Any, func_except: Any = None) -> Self | None:
    """
    Determine the Matrix through a parameter.

    :param value:           Value or Matrix object.
    :param func_except:     Function returned for custom error handling.

    :return:                Matrix object or None.
    """

from_param_or_video classmethod

from_param_or_video(
    value: int | Matrix | MatrixT | None,
    src: VideoNode | VideoFrame | FrameProps,
    strict: bool = False,
    func_except: FuncExceptT | None = None,
) -> Matrix
Source code
232
233
234
235
236
237
238
@classmethod
def from_param_or_video(
    cls, value: int | Matrix | MatrixT | None,
    src: vs.VideoNode | vs.VideoFrame | vs.FrameProps,
    strict: bool = False, func_except: FuncExceptT | None = None
) -> Matrix:
    ...

from_primaries classmethod

from_primaries(primaries: Primaries, strict: bool = False) -> Matrix

Obtain the matrix from a Primaries object.

Parameters:

  • primaries

    (Primaries) –

    Primaries object.

  • strict

    (bool, default: False ) –

    Be strict about the primaries-matrix mapping. Will ALWAYS error with Primaries.UNKNOWN.

Returns:

Raises:

  • UnsupportedPrimariesError

    Primaries is not supported.

Source code
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
@classmethod
def from_primaries(cls, primaries: Primaries, strict: bool = False) -> Matrix:
    """
    Obtain the matrix from a Primaries object.

    :param primaries:                       Primaries object.
    :param strict:                          Be strict about the primaries-matrix mapping.
                                            Will ALWAYS error with Primaries.UNKNOWN.

    :return:                                Matrix object.

    :raises UnsupportedPrimariesError:      Primaries is not supported.
    """

    if primaries not in _primaries_matrix_map:
        if strict:
            raise UnsupportedPrimariesError(f'{primaries} is not supported!', cls.from_primaries)

        return cls(primaries.value)

    return _primaries_matrix_map[primaries]

from_res classmethod

from_res(frame: VideoNode | VideoFrame) -> Matrix

Guess the matrix based on the clip's resolution.

Parameters:

  • frame

    (VideoNode | VideoFrame) –

    Input clip or frame.

Returns:

Source code
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@classmethod
def from_res(cls, frame: vs.VideoNode | vs.VideoFrame) -> Matrix:
    """
    Guess the matrix based on the clip's resolution.

    :param frame:       Input clip or frame.

    :return:            Matrix object.
    """

    from ..utils import get_var_infos

    fmt, width, height = get_var_infos(frame)

    if fmt.color_family == vs.RGB:
        return Matrix.RGB

    if width <= 1024 and height <= 576:
        if height > 486:
            return Matrix.BT470BG

        return Matrix.SMPTE170M

    return Matrix.BT709

from_transfer classmethod

from_transfer(transfer: Transfer, strict: bool = False) -> Matrix

Obtain the matrix from a Transfer object.

Parameters:

  • transfer

    (Transfer) –

    Transfer object.

  • strict

    (bool, default: False ) –

    Be strict about the transfer-matrix mapping. Will ALWAYS error with Transfer.UNKNOWN.

Returns:

Raises:

  • UnsupportedTransferError

    Transfer is not supported.

Source code
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
@classmethod
def from_transfer(cls, transfer: Transfer, strict: bool = False) -> Matrix:
    """
    Obtain the matrix from a Transfer object.

    :param transfer:                        Transfer object.
    :param strict:                          Be strict about the transfer-matrix mapping.
                                            Will ALWAYS error with Transfer.UNKNOWN.

    :return:                                Matrix object.

    :raises UnsupportedTransferError:       Transfer is not supported.
    """

    if transfer not in _transfer_matrix_map:
        if strict:
            raise UnsupportedTransferError(f'{transfer} is not supported!', cls.from_transfer)

        return cls(transfer.value)

    return _transfer_matrix_map[transfer]

from_video classmethod

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

Obtain the matrix of a clip from the frame properties.

Parameters:

  • src

    (VideoNode | VideoFrame | FrameProps) –

    Input clip, frame, or props.

  • strict

    (bool, default: False ) –

    Be strict about the frame properties. Will ALWAYS error with Matrix.UNKNOWN.

Returns:

Raises:

  • UndefinedMatrixError

    Matrix is undefined.

  • UndefinedMatrixError

    Matrix can not be determined from the frameprops.

Source code
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@classmethod
def from_video(
    cls, src: vs.VideoNode | vs.VideoFrame | vs.FrameProps, strict: bool = False, func: FuncExceptT | None = None
) -> Matrix:
    """
    Obtain the matrix of a clip from the frame properties.

    :param src:                         Input clip, frame, or props.
    :param strict:                      Be strict about the frame properties.
                                        Will ALWAYS error with Matrix.UNKNOWN.

    :return:                            Matrix object.

    :raises UndefinedMatrixError:       Matrix is undefined.
    :raises UndefinedMatrixError:       Matrix can not be determined from the frameprops.
    """

    return _base_from_video(cls, src, UndefinedMatrixError, strict, func)

is_unknown classmethod

is_unknown(value: int | Matrix) -> bool

Check if Matrix is Matrix.UNKNOWN.

Source code
187
188
189
190
191
@classmethod
def is_unknown(cls, value: int | Matrix) -> bool:
    """Check if Matrix is Matrix.UNKNOWN."""

    return value == cls.UNKNOWN

is_valid classmethod

is_valid(value: int) -> bool

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

Source code
160
161
162
163
@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
35
36
37
38
39
@classproperty
def prop_key(cls) -> str:
    """The key used in props to store the enum."""

    return f'_{cls.__name__}'

MatrixCoefficients

Bases: NamedTuple

Class representing Linear <-> Gamma conversion matrix coefficients.

Methods:

  • BT2020

    Matrix Coefficients for BT2020.

  • BT709

    Matrix Coefficients for BT709.

  • SMPTE240M

    Matrix Coefficients for SMPTE240M.

  • SRGB

    Matrix Coefficients for SRGB.

  • from_matrix

    Matrix Coefficients from a Matrix object's value.

  • from_primaries

    Matrix Coefficients from a Primaries object's value.

  • from_transfer

    Matrix Coefficients from a Transfer object's value.

Attributes:

  • alpha (float) –

    Coefficient representing the non-linearity of the gamma curve.

  • gamma (float) –

    Coefficient representing the exponent of the gamma curve.

  • k0 (float) –

    Coefficient representing the offset of the linear value relative to the gamma value.

  • phi (float) –

    Coefficient representing the slope of the linear value relative to the gamma value.

alpha instance-attribute

alpha: float

Coefficient representing the non-linearity of the gamma curve.

gamma instance-attribute

gamma: float

Coefficient representing the exponent of the gamma curve.

k0 instance-attribute

k0: float

Coefficient representing the offset of the linear value relative to the gamma value.

phi instance-attribute

phi: float

Coefficient representing the slope of the linear value relative to the gamma value.

BT2020

BT2020() -> MatrixCoefficients

Matrix Coefficients for BT2020.

Source code
955
956
957
958
959
@classproperty
def BT2020(cls) -> MatrixCoefficients:
    """Matrix Coefficients for BT2020."""

    return MatrixCoefficients(0.08145, 4.5, 0.0993, 2.22222)

BT709

BT709() -> MatrixCoefficients

Matrix Coefficients for BT709.

Source code
943
944
945
946
947
@classproperty
def BT709(cls) -> MatrixCoefficients:
    """Matrix Coefficients for BT709."""

    return MatrixCoefficients(0.08145, 4.5, 0.0993, 2.22222)

SMPTE240M

SMPTE240M() -> MatrixCoefficients

Matrix Coefficients for SMPTE240M.

Source code
949
950
951
952
953
@classproperty
def SMPTE240M(cls) -> MatrixCoefficients:
    """Matrix Coefficients for SMPTE240M."""

    return MatrixCoefficients(0.0912, 4.0, 0.1115, 2.22222)

SRGB

Matrix Coefficients for SRGB.

Source code
937
938
939
940
941
@classproperty
def SRGB(cls) -> MatrixCoefficients:
    """Matrix Coefficients for SRGB."""

    return MatrixCoefficients(0.04045, 12.92, 0.055, 2.4)

from_matrix classmethod

from_matrix(matrix: Matrix) -> MatrixCoefficients

Matrix Coefficients from a Matrix object's value.

Source code
961
962
963
964
965
966
967
968
@classmethod
def from_matrix(cls, matrix: Matrix) -> MatrixCoefficients:
    """Matrix Coefficients from a Matrix object's value."""

    if matrix not in _matrix_matrixcoeff_map:
        raise UnsupportedMatrixError(f'{matrix} is not supported!', cls.from_matrix)

    return _matrix_matrixcoeff_map[matrix]

from_primaries classmethod

from_primaries(primaries: Primaries) -> MatrixCoefficients

Matrix Coefficients from a Primaries object's value.

Source code
979
980
981
982
983
984
985
986
@classmethod
def from_primaries(cls, primaries: Primaries) -> MatrixCoefficients:
    """Matrix Coefficients from a Primaries object's value."""

    if primaries not in _primaries_matrixcoeff_map:
        raise UnsupportedPrimariesError(f'{primaries} is not supported!', cls.from_primaries)

    return _primaries_matrixcoeff_map[primaries]

from_transfer classmethod

from_transfer(transfer: Transfer) -> MatrixCoefficients

Matrix Coefficients from a Transfer object's value.

Source code
970
971
972
973
974
975
976
977
@classmethod
def from_transfer(cls, transfer: Transfer) -> MatrixCoefficients:
    """Matrix Coefficients from a Transfer object's value."""

    if transfer not in _transfer_matrixcoeff_map:
        raise UnsupportedTransferError(f'{transfer} is not supported!', cls.from_transfer)

    return _transfer_matrixcoeff_map[transfer]

Primaries

Bases: _PrimariesMeta

Color primaries (ITU-T H.265 Table E.3).

Methods:

  • apply

    Applies the property to the VideoNode.

  • ensure_presence

    Ensure the presence of the property in the VideoNode.

  • ensure_presences

    Ensure the presence of multiple PropEnums at once.

  • from_libplacebo

    Obtain the primaries from libplacebo.

  • from_matrix

    Obtain the primaries from a Matrix object.

  • from_param

    Determine the Primaries through a parameter.

  • from_param_or_video
  • from_res

    Guess the primaries based on the clip's resolution.

  • from_transfer

    Obtain the primaries from a Transfer object.

  • from_video

    Obtain the primaries of a clip from the frame properties.

  • is_unknown

    Check if Primaries is unknown.

  • is_valid

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

  • prop_key

    The key used in props to store the enum.

Attributes:

ACES_0 class-attribute instance-attribute

ACES_0 = 116

ACES Primaries #0 (ultra wide)

ACES_1 class-attribute instance-attribute

ACES_1 = 117

ACES Primaries #1

ADOBE class-attribute instance-attribute

ADOBE = 108

Adobe RGB (1998).

APPLE class-attribute instance-attribute

APPLE = 107

Apple RGB.

BT2020 class-attribute instance-attribute

BT2020 = 9
Primary       x      y
Green     0.1700 0.7970
Blue      0.1310 0.0460
Red       0.7080 0.2920
White D65 0.3127 0.3290

Rec. ITU-R BT.2020-2 Rec. ITU-R BT.2100-2

BT470BG class-attribute instance-attribute

BT470BG = 5
Primary      x      y
Green     0.2900 0.6000
Blue      0.1500 0.0600
Red       0.6400 0.3300
White D65 0.3127 0.3290

Rec. ITU-R BT.470-6 System B, G (historical) Rec. ITU-R BT.601-7 625 Rec. ITU-R BT.1358-0 625 (historical) Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM

BT470M class-attribute instance-attribute

BT470M = 4
Primary     x      y
Green    0.2100 0.7100
Blue     0.1400 0.0800
Red      0.6700 0.3300
White C  0.3100 0.3160

Rec. ITU-R BT.470-6 System M (historical) NTSC Recommendation for transmission standards for colour television (1953) FCC Title 47 Code of Federal Regulations (2003) 73.682 (a) (20)

BT601_525 class-attribute instance-attribute

BT601_525 = SMPTE170M

BT601_625 class-attribute instance-attribute

BT601_625 = BT470BG

BT709 class-attribute instance-attribute

BT709 = 1
Primary      x      y
Green     0.3000 0.6000
Blue      0.1500 0.0600
Red       0.6400 0.3300
White D65 0.3127 0.3290

Rec. ITU-R BT.709-6 Rec. ITU-R BT.1361-0 conventional colour gamutsystem and extended colour gamut system (historical) IEC 61966-2-1 sRGB or sYCC IEC 61966-2-4 SMPTE RP 177 (1993) Annex B

CIE1931 class-attribute instance-attribute

CIE1931 = ST428

DCI_P3 class-attribute instance-attribute

DCI_P3 = ST431_2

DISPLAY_P3 class-attribute instance-attribute

DISPLAY_P3 = ST432_1

EBU3213 class-attribute instance-attribute

EBU3213 = JEDEC_P22

Primary characteristics from libplacebo

FILM class-attribute instance-attribute

FILM = 8
Primary    x      y
Green   0.2430 0.6920 #(Wratten 58)
Blue    0.1450 0.0490 #(Wratten 47)
Red     0.6810 0.3190 #(Wratten 25)
White C 0.3100 0.3160

Generic film (colour filters using Illuminant C)

JEDEC_P22 class-attribute instance-attribute

JEDEC_P22 = 22
Primary      x      y
Green     0.2950 0.6050
Blue      0.1550 0.0770
Red       0.6300 0.3400
White D65 0.3127 0.3290

EBU Tech. 3213-E (1975)

PROPHOTO class-attribute instance-attribute

PROPHOTO = 109

ProPhoto RGB (ROMM).

ROMM class-attribute instance-attribute

ROMM = PROPHOTO

SGAMUT class-attribute instance-attribute

SGAMUT = 114

Sony S-Gamut.

SMPTE170M class-attribute instance-attribute

SMPTE170M = 6

(Functionally the same as :py:attr:Primaries.SMPTE240M)

Primary      x      y
Green     0.3100 0.5950
Blue      0.1550 0.0700
Red       0.6300 0.3400
White D65 0.3127 0.3290

Rec. ITU-R BT.601-7 525 Rec. ITU-R BT.1358-1 525 or 625 (historical) Rec. ITU-R BT.1700-0 NTSC SMPTE ST 170 (2004)

SMPTE240M class-attribute instance-attribute

SMPTE240M = 7

(Functionally the same as :py:attr:Primaries.SMPTE170M)

Primary      x      y
Green     0.3100 0.5950
Blue      0.1550 0.0700
Red       0.6300 0.3400
White D65 0.3127 0.3290

SMPTE ST 240 (1999, historical)

ST428 class-attribute instance-attribute

ST428 = 10
Primary        x   y
Green    (Y)  0.0 1.0
Blue     (Z)  0.0 0.0
Red      (X)  1.0 0.0
Centre White  1/3 1/3

SMPTE ST 428-1 (2006) (CIE 1931 XYZ)

ST431_2 class-attribute instance-attribute

ST431_2 = 11
Primary    x      y
Green   0.2650 0.6900
Blue    0.1500 0.0600
Red     0.6800 0.3200
White   0.3140 0.3510

SMPTE RP 431-2 (2011) SMPTE ST 2113 (2019) "P3DCI"

ST432_1 class-attribute instance-attribute

ST432_1 = 12
Primary      x      y
Green     0.2650 0.6900
Blue      0.1500 0.0600
Red       0.6800 0.3200
White D65 0.3127 0.3290

SMPTE EG 432-1 (2010) SMPTE ST 2113 (2019) "P3D65"

UNKNOWN class-attribute instance-attribute

UNKNOWN = 2

Unspecified Image characteristics are unknown or are determined by the application.

VARICAM class-attribute instance-attribute

VARICAM = VGAMUT

VGAMUT class-attribute instance-attribute

VGAMUT = 113

Panasonic V-Gamut (VARICAM).

XYZ class-attribute instance-attribute

XYZ = ST428

pretty_string property

pretty_string: str

string property

string: str

value_libplacebo property

value_libplacebo: int

libplacebo value.

value_vs property

value_vs: int

VapourSynth value.

Raises:

  • ReservedPrimariesError

    Primaries are not an internal primaries, but a libplacebo one.

apply

apply(clip: VideoNodeT) -> VideoNodeT

Applies the property to the VideoNode.

Source code
127
128
129
130
def apply(self, clip: VideoNodeT) -> VideoNodeT:
    """Applies the property to the VideoNode."""

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

ensure_presence classmethod

ensure_presence(
    clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT

Ensure the presence of the property in the VideoNode.

Source code
117
118
119
120
121
122
123
124
125
@classmethod
def ensure_presence(
    cls, clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of the property in the VideoNode."""

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

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

ensure_presences staticmethod

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

Ensure the presence of multiple PropEnums at once.

Source code
132
133
134
135
136
137
138
139
140
141
142
143
144
@staticmethod
def ensure_presences(
    clip: VideoNodeT, prop_enums: Iterable[type[PropEnumT] | PropEnumT], func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of multiple PropEnums at once."""

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

from_libplacebo classmethod

from_libplacebo(val: int) -> int

Obtain the primaries from libplacebo.

Source code
885
886
887
888
889
@classmethod
def from_libplacebo(cls, val: int) -> int:
    """Obtain the primaries from libplacebo."""

    return _placebo_primaries_map[val]

from_matrix classmethod

from_matrix(matrix: Matrix, strict: bool = False) -> Primaries

Obtain the primaries from a Matrix object.

Parameters:

  • matrix

    (Matrix) –

    Matrix object.

  • strict

    (bool, default: False ) –

    Be strict about the matrix-primaries mapping. Will ALWAYS error with Matrix.UNKNOWN.

Returns:

Raises:

  • UnsupportedMatrixError

    Matrix is not supported.

Source code
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
@classmethod
def from_matrix(cls, matrix: Matrix, strict: bool = False) -> Primaries:
    """
    Obtain the primaries from a Matrix object.

    :param matrix:                          Matrix object.
    :param strict:                          Be strict about the matrix-primaries mapping.
                                            Will ALWAYS error with Matrix.UNKNOWN.

    :return:                                Primaries object.

    :raises UnsupportedMatrixError:         Matrix is not supported.
    """

    if matrix not in _matrix_primaries_map:
        if strict:
            raise UnsupportedMatrixError(f'{matrix} is not supported!', cls.from_matrix)

        return cls(matrix.value)

    return _matrix_primaries_map[matrix]

from_param classmethod

from_param(value: None, func_except: FuncExceptT | None = None) -> None
from_param(
    value: int | Primaries | PrimariesT, func_except: FuncExceptT | None = None
) -> Self
from_param(
    value: int | Primaries | PrimariesT | None,
    func_except: FuncExceptT | None = None,
) -> Self | None
from_param(value: Any, func_except: Any = None) -> Self | None

Determine the Primaries through a parameter.

Parameters:

  • value

    (Any) –

    Value or Primaries object.

  • func_except

    (Any, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • Self | None

    Primaries object or None.

Source code
310
311
312
313
314
315
316
317
318
319
320
@classmethod
def from_param(cls, value: Any, func_except: Any = None) -> Self | None:
    """
    Determine the Primaries through a parameter.

    :param value:           Value or Primaries object.
    :param func_except:     Function returned for custom error handling.
                            This should only be set by VS package developers.

    :return:                Primaries object or None.
    """

from_param_or_video classmethod

from_param_or_video(
    value: int | Primaries | PrimariesT | None,
    src: VideoNode | VideoFrame | FrameProps,
    strict: bool = False,
    func_except: FuncExceptT | None = None,
) -> Primaries
Source code
322
323
324
325
326
327
328
@classmethod
def from_param_or_video(
    cls, value: int | Primaries | PrimariesT | None,
    src: vs.VideoNode | vs.VideoFrame | vs.FrameProps,
    strict: bool = False, func_except: FuncExceptT | None = None
) -> Primaries:
    ...

from_res classmethod

from_res(frame: VideoNode | VideoFrame) -> Primaries

Guess the primaries based on the clip's resolution.

Parameters:

  • frame

    (VideoNode | VideoFrame) –

    Input clip or frame.

Returns:

Source code
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
@classmethod
def from_res(cls, frame: vs.VideoNode | vs.VideoFrame) -> Primaries:
    """
    Guess the primaries based on the clip's resolution.

    :param frame:       Input clip or frame.

    :return:            Primaries object.
    """

    from ..utils import get_var_infos

    fmt, width, height = get_var_infos(frame)

    if fmt.color_family == vs.RGB:
        return Primaries.BT709

    if width <= 1024 and height <= 576:
        if height > 486:
            return Primaries.BT470BG

        return Primaries.SMPTE170M

    return Primaries.BT709

from_transfer classmethod

from_transfer(transfer: Transfer, strict: bool = False) -> Primaries

Obtain the primaries from a Transfer object.

Parameters:

  • transfer

    (Transfer) –

    Transfer object.

  • strict

    (bool, default: False ) –

    Be strict about the transfer-primaries mapping. Will ALWAYS error with Transfer.UNKNOWN.

Returns:

Raises:

  • UnsupportedTransferError

    Transfer is not supported.

Source code
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
@classmethod
def from_transfer(cls, transfer: Transfer, strict: bool = False) -> Primaries:
    """
    Obtain the primaries from a Transfer object.

    :param transfer:                        Transfer object.
    :param strict:                          Be strict about the transfer-primaries mapping.
                                            Will ALWAYS error with Transfer.UNKNOWN.

    :return:                                Matrix object.

    :raises UnsupportedTransferError:       Transfer is not supported.
    """

    if transfer not in _transfer_primaries_map:
        if strict:
            raise UnsupportedTransferError(f'{transfer} is not supported!', cls.from_transfer)

        return cls(transfer.value)

    return _transfer_primaries_map[transfer]

from_video classmethod

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

Obtain the primaries of a clip from the frame properties.

Parameters:

  • src

    (VideoNode | VideoFrame | FrameProps) –

    Input clip, frame, or props.

  • strict

    (bool, default: False ) –

    Be strict about the frame properties. Will ALWAYS error with Primaries.UNKNOWN.

Returns:

Raises:

  • UndefinedPrimariesError

    Primaries is undefined.

  • UndefinedPrimariesError

    Primaries can not be determined from the frame properties.

Source code
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
@classmethod
def from_video(
    cls, src: vs.VideoNode | vs.VideoFrame | vs.FrameProps, strict: bool = False, func: FuncExceptT | None = None
) -> Primaries:
    """
    Obtain the primaries of a clip from the frame properties.

    :param src:                         Input clip, frame, or props.
    :param strict:                      Be strict about the frame properties.
                                        Will ALWAYS error with Primaries.UNKNOWN.

    :return:                            Primaries object.

    :raises UndefinedPrimariesError:    Primaries is undefined.
    :raises UndefinedPrimariesError:    Primaries can not be determined from the frame properties.
    """

    return _base_from_video(cls, src, UndefinedPrimariesError, strict, func)

is_unknown classmethod

is_unknown(value: int | Primaries) -> bool

Check if Primaries is unknown.

Source code
791
792
793
794
795
@classmethod
def is_unknown(cls, value: int | Primaries) -> bool:
    """Check if Primaries is unknown."""

    return value == cls.UNKNOWN

is_valid classmethod

is_valid(value: int) -> bool

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

Source code
160
161
162
163
@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
35
36
37
38
39
@classproperty
def prop_key(cls) -> str:
    """The key used in props to store the enum."""

    return f'_{cls.__name__}'

PropEnum

Bases: CustomIntEnum

Methods:

  • apply

    Applies the property to the VideoNode.

  • ensure_presence

    Ensure the presence of the property in the VideoNode.

  • ensure_presences

    Ensure the presence of multiple PropEnums at once.

  • from_param

    Get the enum member from its int representation.

  • from_param_or_video

    Get the enum member from a value that can be casted to this prop value

  • from_res

    Get an enum member from the video resolution with heuristics.

  • from_video

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

  • is_unknown

    Whether the value represents an unknown value.

  • is_valid

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

  • prop_key

    The key used in props to store the enum.

Attributes:

  • pretty_string (str) –

    Get a pretty, displayable string of the enum member.

  • string (str) –

    Get the string representation used in resize plugin/encoders.

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: VideoNodeT) -> VideoNodeT

Applies the property to the VideoNode.

Source code
127
128
129
130
def apply(self, clip: VideoNodeT) -> VideoNodeT:
    """Applies the property to the VideoNode."""

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

ensure_presence classmethod

ensure_presence(
    clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT

Ensure the presence of the property in the VideoNode.

Source code
117
118
119
120
121
122
123
124
125
@classmethod
def ensure_presence(
    cls, clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of the property in the VideoNode."""

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

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

ensure_presences staticmethod

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

Ensure the presence of multiple PropEnums at once.

Source code
132
133
134
135
136
137
138
139
140
141
142
143
144
@staticmethod
def ensure_presences(
    clip: VideoNodeT, prop_enums: Iterable[type[PropEnumT] | PropEnumT], func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of multiple PropEnums at once."""

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

from_param classmethod

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

Get the enum member from its int representation.

Source code
68
69
70
@classmethod
def from_param(cls, value: Any, func_except: Any = None) -> Self | 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,
) -> Self

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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@classmethod
def from_param_or_video(
    cls, value: Any,
    src: vs.VideoNode | vs.VideoFrame | vs.FrameProps,
    strict: bool = False, func_except: FuncExceptT | None = None
) -> Self:
    """
    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

    return cls.from_video(src, strict, func_except)

from_res classmethod

from_res(frame: VideoNode | VideoFrame) -> Self

Get an enum member from the video resolution with heuristics.

Source code
78
79
80
81
82
@classmethod
def from_res(cls, frame: vs.VideoNode | vs.VideoFrame) -> Self:
    """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,
) -> Self

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

Source code
84
85
86
87
88
89
90
91
@classmethod
def from_video(
    cls, src: vs.VideoNode | vs.VideoFrame | vs.FrameProps, strict: bool = False,
    func: FuncExceptT | None = None
) -> Self:
    """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 | Self) -> bool

Whether the value represents an unknown value.

Source code
29
30
31
32
33
@classmethod
def is_unknown(cls, value: int | Self) -> 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
160
161
162
163
@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
35
36
37
38
39
@classproperty
def prop_key(cls) -> str:
    """The key used in props to store the enum."""

    return f'_{cls.__name__}'

Transfer

Bases: _TransferMeta

Transfer characteristics (ITU-T H.265 Table E.4).

Methods:

  • apply

    Applies the property to the VideoNode.

  • ensure_presence

    Ensure the presence of the property in the VideoNode.

  • ensure_presences

    Ensure the presence of multiple PropEnums at once.

  • from_libplacebo

    Obtain the transfer from libplacebo.

  • from_matrix

    Obtain the transfer from a Matrix object.

  • from_param

    Determine the Transfer through a parameter.

  • from_param_or_video
  • from_primaries

    Obtain the transfer from a Primaries object.

  • from_res

    Guess the transfer based on the clip's resolution.

  • from_video

    Obtain the transfer of a clip from the frame properties.

  • is_unknown

    Check if Transfer is unknown.

  • is_valid

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

  • prop_key

    The key used in props to store the enum.

Attributes:

  • BT1886
  • BT2020_10

    (Functionally the same as :py:attr:Transfer.BT709, :py:attr:Transfer.BT601,

  • BT2020_12

    (Functionally the same as :py:attr:Transfer.BT709, :py:attr:Transfer.BT601,

  • BT470BG

    Rec. ITU-R BT.470-6 System B, G (historical)

  • BT470M

    Rec. ITU-R BT.470-6 System M (historical)

  • BT601

    (Functionally the same as :py:attr:Transfer.BT709, :py:attr:Transfer.BT2020_10,

  • BT709

    (Functionally the same as :py:attr:Transfer.BT601, :py:attr:Transfer.BT2020_10,

  • GAMMA18

    Pure power gamma 1.8

  • GAMMA20

    Pure power gamma 2.0

  • GAMMA22
  • GAMMA24
  • GAMMA26

    Pure power gamma 2.6

  • GAMMA28
  • HLG

    Transfer characteristics from libplacebo

  • LINEAR

    Linear transfer characteristics.

  • LOG100

    Logarithmic transfer characteristic (100:1 range).

  • LOG316

    Logarithmic transfer characteristic (100 * sqrt(10):1 range).

  • PQ
  • PROPHOTO

    ProPhoto RGB (ROMM)

  • ROMM
  • SLOG_1

    Sony S-Log1

  • SLOG_2

    Sony S-Log2

  • SMPTE240M

    SMPTE ST 240 (1999, historical).

  • SRGB

    IEC 61966-2-1 sRGB when matrix is equal to :py:attr:Matrix.RGB

  • ST2084

    SMPTE ST 2084 (2014) for 10, 12, 14, and 16-bit systems

  • ST428

    Digital Cinema Distribution Master (XYZ)

  • STD_B67

    Association of Radio Industries and Businesses (ARIB) STD-B67

  • UNKNOWN

    Image characteristics are unknown or are determined by the application.

  • VARICAM
  • VLOG

    Panasonic V-Log (VARICAM)

  • XVYCC

    IEC 61966-2-4.

  • XYZ
  • pretty_string (str) –
  • string (str) –
  • value_libplacebo (int) –

    libplacebo value.

  • value_vs (int) –

    VapourSynth value.

BT1886 class-attribute instance-attribute

BT1886 = BT709

BT2020_10 class-attribute instance-attribute

BT2020_10 = 14

(Functionally the same as :py:attr:Transfer.BT709, :py:attr:Transfer.BT601, and :py:attr:Transfer.BT2020_12) Rec. ITU-R BT.2020-2

BT2020_12 class-attribute instance-attribute

BT2020_12 = 15

(Functionally the same as :py:attr:Transfer.BT709, :py:attr:Transfer.BT601, and :py:attr:Transfer.BT2020_10) Rec. ITU-R BT.2020-2

BT470BG class-attribute instance-attribute

BT470BG = 5

Rec. ITU-R BT.470-6 System B, G (historical) Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM

BT470M class-attribute instance-attribute

BT470M = 4

Rec. ITU-R BT.470-6 System M (historical) NTSC Recommendation for transmission standards for colour television (1953) FCC, Title 47 Code of Federal Regulations (2003) 73.682 (a) (20)

BT601 class-attribute instance-attribute

BT601 = 6

(Functionally the same as :py:attr:Transfer.BT709, :py:attr:Transfer.BT2020_10, and :py:attr:Transfer.BT2020_12) Rec. ITU-R BT.601-7 525 or 625 Rec. ITU-R BT.1358-1 525 or 625 (historical) Rec. ITU-R BT.1700-0 NTSC SMPTE ST 170 (2004)

BT709 class-attribute instance-attribute

BT709 = 1

(Functionally the same as :py:attr:Transfer.BT601, :py:attr:Transfer.BT2020_10, and :py:attr:Transfer.BT2020_12) Rec. ITU-R BT.709-6 Rec. ITU-R BT.1361-0 conventional Colour gamut system (historical)

GAMMA18 class-attribute instance-attribute

GAMMA18 = 104

Pure power gamma 1.8

GAMMA20 class-attribute instance-attribute

GAMMA20 = 105

Pure power gamma 2.0

GAMMA22 class-attribute instance-attribute

GAMMA22 = BT470M

GAMMA24 class-attribute instance-attribute

GAMMA24 = BT709

GAMMA26 class-attribute instance-attribute

GAMMA26 = 108

Pure power gamma 2.6

GAMMA28 class-attribute instance-attribute

GAMMA28 = BT470BG

HLG class-attribute instance-attribute

HLG = STD_B67

Transfer characteristics from libplacebo

LINEAR class-attribute instance-attribute

LINEAR = 8

Linear transfer characteristics.

LOG100 class-attribute instance-attribute

LOG100 = 9

Logarithmic transfer characteristic (100:1 range).

LOG316 class-attribute instance-attribute

LOG316 = 10

Logarithmic transfer characteristic (100 * sqrt(10):1 range).

PQ class-attribute instance-attribute

PQ = ST2084

PROPHOTO class-attribute instance-attribute

PROPHOTO = 110

ProPhoto RGB (ROMM)

ROMM class-attribute instance-attribute

ROMM = PROPHOTO

SLOG_1 class-attribute instance-attribute

SLOG_1 = 115

Sony S-Log1

SLOG_2 class-attribute instance-attribute

SLOG_2 = 116

Sony S-Log2

SMPTE240M class-attribute instance-attribute

SMPTE240M = 7

SMPTE ST 240 (1999, historical).

SRGB class-attribute instance-attribute

SRGB = 13

IEC 61966-2-1 sRGB when matrix is equal to :py:attr:Matrix.RGB IEC 61966-2-1 sYCC when matrix is equal to :py:attr:Matrix.BT470BG

ST2084 class-attribute instance-attribute

ST2084 = 16

SMPTE ST 2084 (2014) for 10, 12, 14, and 16-bit systems Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system

ST428 class-attribute instance-attribute

ST428 = 111

Digital Cinema Distribution Master (XYZ)

STD_B67 class-attribute instance-attribute

STD_B67 = 18

Association of Radio Industries and Businesses (ARIB) STD-B67 Rec. ITU-R BT.2100-2 hybrid loggamma (HLG) system

UNKNOWN class-attribute instance-attribute

UNKNOWN = 2

Image characteristics are unknown or are determined by the application.

VARICAM class-attribute instance-attribute

VARICAM = VLOG

VLOG class-attribute instance-attribute

VLOG = 114

Panasonic V-Log (VARICAM)

XVYCC class-attribute instance-attribute

XVYCC = 11

IEC 61966-2-4.

XYZ class-attribute instance-attribute

XYZ = ST428

pretty_string property

pretty_string: str

string property

string: str

value_libplacebo property

value_libplacebo: int

libplacebo value.

value_vs property

value_vs: int

VapourSynth value.

Raises:

  • ReservedTransferError

    Transfer is not an internal transfer, but a libplacebo one.

apply

apply(clip: VideoNodeT) -> VideoNodeT

Applies the property to the VideoNode.

Source code
127
128
129
130
def apply(self, clip: VideoNodeT) -> VideoNodeT:
    """Applies the property to the VideoNode."""

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

ensure_presence classmethod

ensure_presence(
    clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT

Ensure the presence of the property in the VideoNode.

Source code
117
118
119
120
121
122
123
124
125
@classmethod
def ensure_presence(
    cls, clip: VideoNodeT, value: int | Self | None, func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of the property in the VideoNode."""

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

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

ensure_presences staticmethod

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

Ensure the presence of multiple PropEnums at once.

Source code
132
133
134
135
136
137
138
139
140
141
142
143
144
@staticmethod
def ensure_presences(
    clip: VideoNodeT, prop_enums: Iterable[type[PropEnumT] | PropEnumT], func: FuncExceptT | None = None
) -> VideoNodeT:
    """Ensure the presence of multiple PropEnums at once."""

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

from_libplacebo classmethod

from_libplacebo(val: int) -> int

Obtain the transfer from libplacebo.

Source code
527
528
529
530
531
@classmethod
def from_libplacebo(cls, val: int) -> int:
    """Obtain the transfer from libplacebo."""

    return _placebo_transfer_map[val]

from_matrix classmethod

from_matrix(matrix: Matrix, strict: bool = False) -> Transfer

Obtain the transfer from a Matrix object.

Parameters:

  • matrix

    (Matrix) –

    Matrix object.

  • strict

    (bool, default: False ) –

    Be strict about the matrix-transfer mapping. Will ALWAYS error with Matrix.UNKNOWN.

Returns:

Raises:

  • UnsupportedMatrixError

    Matrix is not supported.

Source code
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
@classmethod
def from_matrix(cls, matrix: Matrix, strict: bool = False) -> Transfer:
    """
    Obtain the transfer from a Matrix object.

    :param matrix:                          Matrix object.
    :param strict:                          Be strict about the matrix-transfer mapping.
                                            Will ALWAYS error with Matrix.UNKNOWN.

    :return:                                Transfer object.

    :raises UnsupportedMatrixError:         Matrix is not supported.
    """

    if matrix not in _matrix_transfer_map:
        if strict:
            raise UnsupportedMatrixError(f'{matrix} is not supported!', cls.from_matrix)

        return cls(matrix.value)

    return _matrix_transfer_map[matrix]

from_param classmethod

from_param(value: None, func_except: FuncExceptT | None = None) -> None
from_param(
    value: int | Transfer | TransferT, func_except: FuncExceptT | None = None
) -> Self
from_param(
    value: int | Transfer | TransferT | None,
    func_except: FuncExceptT | None = None,
) -> Self | None
from_param(value: Any, func_except: Any = None) -> Self | None

Determine the Transfer through a parameter.

Parameters:

  • value

    (Any) –

    Value or Transfer object.

  • func_except

    (Any, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • Self | None

    Transfer object or None.

Source code
265
266
267
268
269
270
271
272
273
274
275
@classmethod
def from_param(cls, value: Any, func_except: Any = None) -> Self | None:
    """
    Determine the Transfer through a parameter.

    :param value:           Value or Transfer object.
    :param func_except:     Function returned for custom error handling.
                            This should only be set by VS package developers.

    :return:                Transfer object or None.
    """

from_param_or_video classmethod

from_param_or_video(
    value: int | Transfer | TransferT | None,
    src: VideoNode | VideoFrame | FrameProps,
    strict: bool = False,
    func_except: FuncExceptT | None = None,
) -> Transfer
Source code
277
278
279
280
281
282
283
@classmethod
def from_param_or_video(
    cls, value: int | Transfer | TransferT | None,
    src: vs.VideoNode | vs.VideoFrame | vs.FrameProps,
    strict: bool = False, func_except: FuncExceptT | None = None
) -> Transfer:
    ...

from_primaries classmethod

from_primaries(primaries: Primaries, strict: bool = False) -> Transfer

Obtain the transfer from a Primaries object.

Parameters:

  • primaries

    (Primaries) –

    Primaries object.

  • strict

    (bool, default: False ) –

    Be strict about the primaries-transfer mapping. Will ALWAYS error with Primaries.UNKNOWN.

Returns:

Raises:

  • UnsupportedPrimariesError

    Primaries is not supported.

Source code
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
@classmethod
def from_primaries(cls, primaries: Primaries, strict: bool = False) -> Transfer:
    """
    Obtain the transfer from a Primaries object.

    :param primaries:                       Primaries object.
    :param strict:                          Be strict about the primaries-transfer mapping.
                                            Will ALWAYS error with Primaries.UNKNOWN.

    :return:                                Transfer object.

    :raises UnsupportedPrimariesError:      Primaries is not supported.
    """

    if primaries not in _primaries_transfer_map:
        if strict:
            raise UnsupportedPrimariesError(f'{primaries} is not supported!', cls.from_primaries)

        return cls(primaries.value)

    return _primaries_transfer_map[primaries]

from_res classmethod

from_res(frame: VideoNode | VideoFrame) -> Transfer

Guess the transfer based on the clip's resolution.

Parameters:

  • frame

    (VideoNode | VideoFrame) –

    Input clip or frame.

Returns:

Source code
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
@classmethod
def from_res(cls, frame: vs.VideoNode | vs.VideoFrame) -> Transfer:
    """
    Guess the transfer based on the clip's resolution.

    :param frame:       Input clip or frame.

    :return:            Transfer object.
    """

    from ..utils import get_var_infos

    fmt, width, height = get_var_infos(frame)

    if fmt.color_family == vs.RGB:
        return Transfer.SRGB

    if width <= 1024 and height <= 576:
        return Transfer.BT601

    return Transfer.BT709

from_video classmethod

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

Obtain the transfer of a clip from the frame properties.

Parameters:

  • src

    (VideoNode | VideoFrame | FrameProps) –

    Input clip, frame, or props.

  • strict

    (bool, default: False ) –

    Be strict about the properties. The result may NOT be Transfer.UNKNOWN.

Returns:

Raises:

  • UndefinedTransferError

    Transfer is undefined.

  • UndefinedTransferError

    Transfer can not be determined from the frameprops.

Source code
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
@classmethod
def from_video(
    cls, src: vs.VideoNode | vs.VideoFrame | vs.FrameProps, strict: bool = False, func: FuncExceptT | None = None
) -> Transfer:
    """
    Obtain the transfer of a clip from the frame properties.

    :param src:                         Input clip, frame, or props.
    :param strict:                      Be strict about the properties.
                                        The result may NOT be Transfer.UNKNOWN.

    :return:                            Transfer object.

    :raises UndefinedTransferError:     Transfer is undefined.
    :raises UndefinedTransferError:     Transfer can not be determined from the frameprops.
    """

    return _base_from_video(cls, src, UndefinedTransferError, strict, func)

is_unknown classmethod

is_unknown(value: int | Transfer) -> bool

Check if Transfer is unknown.

Source code
436
437
438
439
440
@classmethod
def is_unknown(cls, value: int | Transfer) -> bool:
    """Check if Transfer is unknown."""

    return value == cls.UNKNOWN

is_valid classmethod

is_valid(value: int) -> bool

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

Source code
160
161
162
163
@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
35
36
37
38
39
@classproperty
def prop_key(cls) -> str:
    """The key used in props to store the enum."""

    return f'_{cls.__name__}'