Skip to content

types

Re-export from ffmpeg_core.types.

Classes:

Name Description
Default

Represents a default value for an FFmpeg option.

LazyValue

Abstract base class for lazy evaluation of expressions.

Attributes:

Name Type Description
Boolean

This represents FFmpeg's boolean type. It can accept either a Python boolean value (True or False)

Color

It can be the name of a color as defined below (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, possibly followed by @ and a string representing the alpha component.

Double

This represents FFmpeg's double type. It can accept either a Python integer or float value

Duration

This represents FFmpeg's duration type. It can accept either a Python integer or float value

Flags

This represents FFmpeg's flags type. It accepts a string in the format "A+B",

Float

This represents FFmpeg's float type. It can accept either a Python integer or float value

Func

ref: OPT_TYPE_FUNC

Image_size

Specify the size of the sourced video, it may be a string of the form widthxheight, or the name of a size abbreviation.

Int

This represents FFmpeg's integer type. It can accept either a Python integer value

Int64

This represents FFmpeg's integer type. It can accept either a Python integer value

Pix_fmt

please see ffmpeg -pix_fmts for a list of supported pixel formats.

Rational

Specify the frame rate of a video, expressed as the number of frames generated per second. It has to be a string in the format frame_rate_num/frame_rate_den, an integer number, a float number or a valid video frame rate abbreviation.

String

This represents FFmpeg's string type. It can accept either a Python string value

Time

ref: OPT_TYPE_TIME

Video_rate

Specify the frame rate of a video, expressed as the number of frames generated per second. It has to be a string in the format frame_rate_num/frame_rate_den, an integer number, a float number or a valid video frame rate abbreviation.

Boolean module-attribute

Boolean = (
    bool
    | Literal["true", "false", "1", "0"]
    | Default
    | LazyValue
    | None
)

This represents FFmpeg's boolean type. It can accept either a Python boolean value (True or False) or a string that represents a boolean value ("true", "false", "1", or "0").

Color module-attribute

Color = str | Default | LazyValue | None

It can be the name of a color as defined below (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, possibly followed by @ and a string representing the alpha component. The alpha component may be a string composed by "0x" followed by an hexadecimal number or a decimal number between 0.0 and 1.0, which represents the opacity value (‘0x00’ or ‘0.0’ means completely transparent, ‘0xff’ or ‘1.0’ completely opaque). If the alpha component is not specified then ‘0xff’ is assumed. The string 'random' will result in a random color.

Note

Document

Double module-attribute

Double = str | int | float | Default | LazyValue | None

This represents FFmpeg's double type. It can accept either a Python integer or float value or a string that represents a double value.

Duration module-attribute

Duration = str | int | float | Default | LazyValue | None

This represents FFmpeg's duration type. It can accept either a Python integer or float value or a string that represents a duration value.

Note

Document

Flags module-attribute

Flags = str | Default | LazyValue | None

This represents FFmpeg's flags type. It accepts a string in the format "A+B", where "A" and "B" are individual flags. For example, "fast+bilinear" would represent two flags, "fast" and "bilinear", to be used in FFmpeg's command line.

Float module-attribute

Float = str | int | float | Default | LazyValue | None

This represents FFmpeg's float type. It can accept either a Python integer or float value or a string that represents a float value.

Func module-attribute

Func = str | int | float | Default | LazyValue | None

ref: OPT_TYPE_FUNC

Image_size module-attribute

Image_size = str | Default | LazyValue | None

Specify the size of the sourced video, it may be a string of the form widthxheight, or the name of a size abbreviation.

Note

Document

Int module-attribute

Int = str | int | Default | LazyValue | None

This represents FFmpeg's integer type. It can accept either a Python integer value or a string that represents a integer value.

Int64 module-attribute

Int64 = str | int | Default | LazyValue | None

This represents FFmpeg's integer type. It can accept either a Python integer value or a string that represents a integer value.

Pix_fmt module-attribute

Pix_fmt = str | Default | LazyValue | None

please see ffmpeg -pix_fmts for a list of supported pixel formats.

Rational module-attribute

Rational = str | Default | LazyValue | None

Specify the frame rate of a video, expressed as the number of frames generated per second. It has to be a string in the format frame_rate_num/frame_rate_den, an integer number, a float number or a valid video frame rate abbreviation.

Note

Document

String module-attribute

String = str | int | float | Default | LazyValue | None

This represents FFmpeg's string type. It can accept either a Python string value or a int/float that will be converted to a string.

Time module-attribute

Time = str | int | float | Default | LazyValue | None

ref: OPT_TYPE_TIME

Video_rate module-attribute

Video_rate = str | int | float | Default | LazyValue | None

Specify the frame rate of a video, expressed as the number of frames generated per second. It has to be a string in the format frame_rate_num/frame_rate_den, an integer number, a float number or a valid video frame rate abbreviation.

Note

Document

Default

Bases: str

Represents a default value for an FFmpeg option.

This class is used for annotation purposes only and indicates that a parameter should use its default value. When a parameter is marked with Default, it will not be explicitly passed to the FFmpeg command line, letting FFmpeg use its built-in default value instead.

Example
# This will use FFmpeg's default crf value
video.output("output.mp4", crf=Default("23"))

LazyValue

Bases: ABC

Abstract base class for lazy evaluation of expressions.

LazyValue represents an expression that can be evaluated at a later time, when all required values are available. It supports various arithmetic operations, allowing complex expressions to be built and evaluated lazily.

This class serves as the foundation for the lazy evaluation system, with concrete implementations like Symbol and LazyOperator providing specific functionality.

Methods:

Name Description
eval

Evaluate the lazy value with the given values.

keys

Get the keys that are required to evaluate the lazy value.

partial

Evaluate the lazy value with the given values.

ready

Check if the lazy value is ready to be evaluated.

eval

eval(**values: Any) -> Any

Evaluate the lazy value with the given values.

Parameters:

Name Type Description Default
**values Any

Values to be used for evaluation.

{}

Returns:

Name Type Description
Any Any

The evaluated value.

Raises:

Type Description
ValueError

If the lazy value is not ready to be evaluated.

keys abstractmethod

keys() -> set[str]

Get the keys that are required to evaluate the lazy value.

This method returns the set of symbol names that must be provided as values for the lazy value to be fully evaluated. For example, if the lazy value represents the expression 'width * height', this method would return {'width', 'height'}.

Returns:

Type Description
set[str]

A set of strings representing the required symbol names

partial abstractmethod

partial(**values: Any) -> Any

Evaluate the lazy value with the given values.

Parameters:

Name Type Description Default
**values Any

Values to be used for evaluation.

{}

Returns:

Name Type Description
Any Any

The partially evaluated value.

ready

ready() -> bool

Check if the lazy value is ready to be evaluated.

A lazy value is considered ready for evaluation when it doesn't require any additional values to be provided. This is determined by checking if the set of required keys is empty.

Returns:

Type Description
bool

True if the lazy value can be evaluated without additional values,

bool

False otherwise