movis.ops.insert#

movis.ops.insert(source: BasicLayer, target: BasicLayer, time: float, size: tuple[int, int] | None = None) Composition[source]#

Insert a target layer into a source layer at a specified time.

For instance, consider inserting a brief eye-catch scene to indicate a change in chapters within a long interview video. mv.insert() is used for such purposes, to insert a short scene into a longer one:

|------------------------|    |------------|----------|------------|
|    Source layer        | -> |   Source   |  target  |   Source   |
|------------------------|    |------------|----------|------------|
Examples:
>>> import movis as mv
>>> source = mv.layer.Image("source.png", duration=5.0)
>>> target = mv.layer.Image("target.png", duration=1.0)
>>> composition = mv.insert(source, target, time=2.0)
>>> composition.duration
6.0
>>> composition(0.0)  # source layer
>>> composition(2.0)  # target layer
>>> composition(3.0)  # source layer
Args:
source:

The layer to insert the target layer into.

target:

The layer to insert.

time:

The time to insert the target layer.

size:

Size of the returned composition. If None, the size of the source layer is used.

Returns:

Composition with the target layer inserted.