Project
VideoProjectConfig
Bases: BaseModel
A dictionary representing the configuration of a project.
title
class-attribute
instance-attribute
title: str = 'Untitled Project'
The title of the project. Defaults to "Untitled Project".
version
class-attribute
instance-attribute
version: int = 1
The version of the project. Defaults to 1.
resolution
class-attribute
instance-attribute
The resolution of the project in pixels. Defaults to 1920x1080.
fps
class-attribute
instance-attribute
fps: PositiveInt = 30
The frames per second of the project. Defaults to 30.
VideoProject
Bases: BaseModel
Represents a project with various properties and methods to manipulate its data.
config
class-attribute
instance-attribute
config: VideoProjectConfig = Field(
default_factory=VideoProjectConfig
)
The configuration of the project.
assets
class-attribute
instance-attribute
A dictionary mapping assets keys to Asset objects.
timeline
class-attribute
instance-attribute
timeline: Timeline = Field(default_factory=Timeline)
The timeline of assets and scenes of the video.
from_dict
classmethod
from_dict(data: dict[str, Any]) -> VideoProject
Create a Project object from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict[str, Any]
|
The dictionary containing the project data. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
A Project object instance. |
Source code in src/mosaico/video/project.py
from_file
classmethod
from_file(path: PathLike) -> VideoProject
Create a Project object from a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
PathLike
|
The path to the YAML file. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
A Project object instance. |
Source code in src/mosaico/video/project.py
from_script_generator
classmethod
from_script_generator(
script_generator: ScriptGenerator,
media: Sequence[Media],
*,
config: VideoProjectConfig | None = None,
**kwargs: Any
) -> VideoProject
Create a Project object from a script generator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
generator |
The script generator to use. |
required | |
media |
Sequence[Media]
|
The media files to use. |
required |
config |
VideoProjectConfig | None
|
The configuration of the project. |
None
|
kwargs |
Any
|
Additional keyword arguments to pass to the script generator. |
{}
|
Returns:
Type | Description |
---|---|
VideoProject
|
A Project object instance. |
Source code in src/mosaico/video/project.py
to_file
Write the Project object to a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
PathLike
|
The path to the YAML file. |
required |
Source code in src/mosaico/video/project.py
add_assets
add_assets(assets: AssetInputType) -> VideoProject
Add one or more assets to the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
assets |
AssetInputType
|
The asset or list of assets to add. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
Source code in src/mosaico/video/project.py
add_timeline_events
add_timeline_events(
events: EventOrEventSequence,
) -> VideoProject
Add one or more events to the timeline.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
events |
EventOrEventSequence
|
The event or list of events to add. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
Raises:
Type | Description |
---|---|
ValueError
|
If an asset referenced in the events does not exist in the project. |
Source code in src/mosaico/video/project.py
add_narration
add_narration(
speech_synthesizer: SpeechSynthesizer,
) -> VideoProject
Add narration to subtitles inside Scene objects by generating speech audio from subtitle text.
Updates asset timings within each Scene to match narration duration, dividing time equally between multiple images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
speech_synthesizer |
SpeechSynthesizer
|
The speech synthesizer to use for generating narration audio |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project with narration added |
Source code in src/mosaico/video/project.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
add_captions
add_captions(
transcription: Transcription,
*,
max_duration: int = 5,
params: TextAssetParams | None = None,
scene_index: int | None = None,
overwrite: bool = False
) -> VideoProject
Add subtitles to the project from a transcription.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transcription |
Transcription
|
The transcription to add subtitles from. |
required |
max_duration |
int
|
The maximum duration of each subtitle. |
5
|
params |
TextAssetParams | None
|
The parameters for the subtitle assets. |
None
|
scene_index |
int | None
|
The index of the scene to add the subtitles to. |
None
|
overwrite |
bool
|
Whether to overwrite existing subtitles in the scene. |
False
|
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
Source code in src/mosaico/video/project.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
add_captions_from_transcriber
add_captions_from_transcriber(
audio_transcriber: AudioTranscriber,
*,
max_duration: int = 5,
params: TextAssetParams | None = None,
overwrite: bool = False
) -> VideoProject
Add subtitles to the project from audio assets using an audio transcriber.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio_transcriber |
AudioTranscriber
|
The audio transcriber to use for transcribing audio assets. |
required |
max_duration |
int
|
The maximum duration of each subtitle. |
5
|
params |
TextAssetParams | None
|
The parameters for the subtitle assets. |
None
|
overwrite |
bool
|
Whether to overwrite existing subtitles in the scene. |
False
|
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
Source code in src/mosaico/video/project.py
with_subtitle_params
with_subtitle_params(
params: TextAssetParams | Mapping[str, Any]
) -> VideoProject
Override the subtitle parameters for the assets in the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
TextAssetParams | Mapping[str, Any]
|
The subtitle parameters to set. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
Source code in src/mosaico/video/project.py
with_title
with_title(title: str) -> VideoProject
Override the title of the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The title to set. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
with_version
with_version(version: int) -> VideoProject
Override the project version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
int
|
The version to set. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
with_fps
with_fps(fps: int) -> VideoProject
Override the FPS of the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fps |
int
|
The FPS to set. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
with_resolution
with_resolution(resolution: FrameSize) -> VideoProject
Override the resolution of the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resolution |
FrameSize
|
The resolution to set. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
Source code in src/mosaico/video/project.py
get_asset
Get an asset by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
asset_id |
str
|
The ID of the asset. |
required |
Returns:
Type | Description |
---|---|
Asset
|
The Asset object. |
Raises:
Type | Description |
---|---|
ValueError
|
If the asset is not found in the project assets. |
Source code in src/mosaico/video/project.py
get_timeline_event
get_timeline_event(index: int) -> TimelineEvent
Get a timeline event by its index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
The index of the timeline event. |
required |
Returns:
Type | Description |
---|---|
TimelineEvent
|
The TimelineEvent object. |
Raises:
Type | Description |
---|---|
ValueError
|
If the index is out of range. |
Source code in src/mosaico/video/project.py
remove_asset
remove_asset(asset_id: str) -> VideoProject
Remove an asset from the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
asset_id |
str
|
The ID of the asset to remove. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |
Source code in src/mosaico/video/project.py
remove_timeline_event
remove_timeline_event(index: int) -> VideoProject
Remove a timeline event from the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
The index of the timeline event to remove. |
required |
Returns:
Type | Description |
---|---|
VideoProject
|
The updated project. |