Skip to content

Types

Introspection

Bases: Dynamic

Introspection holds internal media information and technical details from media resources. The media introspection may vary based on the media type and underlying library.

Usage:

# Introspect from ffprobe video info or PIL.Image, etc.
video = Introspection(**ffprobe)
image = Introspection(**PIL.Image)

# Introspection dynamically receives all the metadata from the underlying library output.
# The "WARNING" here is that based on the media type,
# the introspection content could change and requires an extra review.

File

Bases: Media[Path]

Local media file representation. This class is used to represent any media stored in local host.

Usage:

# Introspect from ffprobe video info or PIL.Image, etc.
video_meta = Introspection(**ffprobe)

# create a local file with metadata information
file = File(Path("local_video.mp4"), video_meta)

Engine(lib)

Bases: ABC

Engine implements a media engine adapter. It uses an underlying library as an interface to process media files. It produce output based on the provided settings.

Initialize a new instance with bound library

Parameters:

Name Type Description Default
lib Any

Any underlying lib

required
Source code in nucleus/sdk/processing/types.py
58
59
60
61
62
63
64
def __init__(self, lib: Any):
    """Initialize a new instance with bound library

    :param lib: Any underlying lib
    """
    self._library = lib
    self._settings = []

compile()

Compile engine settings into an map of arguments

Returns:

Type Description
Iterator[Tuple[str, Any]]

A new map of compiled arguments based on settings

Source code in nucleus/sdk/processing/types.py
66
67
68
69
70
71
72
def compile(self) -> Iterator[Tuple[str, Any]]:
    """Compile engine settings into an map of arguments

    :return: A new map of compiled arguments based on settings
    """
    for preset in self._settings:
        yield type(preset).__name__, dict(preset)

configure(setting)

Add setting to media processing context

Parameters:

Name Type Description Default
setting Settings

The setting to apply to the engine output.

required

Returns:

Type Description
Engine

Engine object

Source code in nucleus/sdk/processing/types.py
74
75
76
77
78
79
80
81
82
def configure(self, setting: Settings) -> Engine:
    """Add setting to media processing context

    :param setting: The setting to apply to the engine output.
    :return: Engine object
    """

    self._settings.append(setting)
    return self

introspect(path) abstractmethod

Return technical information of the input media.

Parameters:

Name Type Description Default
path Path

The media path

required

Returns:

Type Description
Introspection

Any technical information collected from media.

Source code in nucleus/sdk/processing/types.py
84
85
86
87
88
89
90
91
@abstractmethod
def introspect(self, path: Path) -> Introspection:
    """Return technical information of the input media.

    :param path: The media path
    :return: Any technical information collected from media.
    """
    ...

save(path) abstractmethod

Store the new media based on settings and bound library.

Parameters:

Name Type Description Default
path Path

The output path

required

Returns:

Type Description
File

File object

Raises:

Type Description
ProcessingEngineError

If any exception is captured during processing

Source code in nucleus/sdk/processing/types.py
 93
 94
 95
 96
 97
 98
 99
100
101
@abstractmethod
def save(self, path: Path) -> File:
    """Store the new media based on settings and bound library.

    :param path: The output path
    :return: File object
    :raises ProcessingEngineError: If any exception is captured during processing
    """
    ...