Ir para o conteúdo

Script Generators

ScriptGenerator

Bases: Protocol

A protocol for generating a shooting script from a list of media files.

This protocol defines the interface for generating a shooting script for a project from a list of media objects. The generate method should be implemented by concrete classes and should fullfill the contract of this protocol by returning a shooting script containing the shots generated from the media files.

Concrete implementations of the ScriptGenerator protocol can be used by the VideoProjectBuilder class to automatically generate a shooting script for a project, avoiding the need of a manually defined timeline.

Note

This is a runtime checkable protocol, which means isinstance() and issubclass() checks can be performed against it.

Example:

class MyScriptGenerator:
    def generate(self, media: Sequence[Media], **kwargs: Any) -> ShootingScript:
        # Implement script generation logic here
        ...

generator: ScriptGenerator = MyScriptGenerator()
script = generator.generate(my_media_files)

generate

generate(
    media: Sequence[Media], **kwargs: Any
) -> ShootingScript

Generate a shooting script from a list of media files.

Parameters:

Name Type Description Default
media Sequence[Media]

The list of media objects.

required
kwargs Any

Additional context for the script generation.

{}

Returns:

Type Description
ShootingScript

The shooting script generated from the media files.

Source code in src/mosaico/script_generators/protocol.py
def generate(self, media: Sequence[Media], **kwargs: Any) -> ShootingScript:
    """
    Generate a shooting script from a list of media files.

    :param media: The list of media objects.
    :param kwargs: Additional context for the script generation.
    :return: The shooting script generated from the media files.
    """
    ...