Skip to main content

Open-source video generation framework

Project description

Mosaico

License Python PyPI Downloads Stars

Mosaico is a Python library for programmatically creating and managing video compositions. It provides a high-level interface for working with media assets, positioning elements, applying effects, and generating video scripts.

Installation

pip install mosaico

Features

  • AI-powered script generation for videos
  • Rich media asset management (audio, images, text, subtitles)
  • Flexible positioning system (absolute, relative, region-based)
  • Built-in effects (pan, zoom) with extensible effect system
  • Text-to-speech synthesis integration
  • Integration with popular ML frameworks, such as Haystack and LangChain

Quick Start

Easily create and render a video project from a script generator:

from mosaico.audio_transcribers.assemblyai import AssemblyAIAudioTranscriber
from mosaico.script_generators.news import NewsVideoScriptGenerator
from mosaico.speech_synthesizers.elevenlabs import ElevenLabsSpeechSynthesizer
from mosaico.video.project import VideoProject
from mosaico.video.rendering import render_video


# Import your media
media = [
    Media.from_path("background.jpg", metadata={"description": "Background image"}),
    Media.from_path("image1.jpg", metadata={"description": "Image 1"}),
    Media.from_path("image2.jpg", metadata={"description": "Image 2"}),
    Media.from_path("image3.jpg", metadata={"description": "Image 3"}),
]

# Textual context for the video
context = "..."

# Create script generator
script_generator = NewsVideoScriptGenerator(
    context=context,
    language="pt",
    num_paragraphs=8,
)

# Create speech synthesizer
speech_synthesizer = ElevenLabsSpeechSynthesizer(
    voice_id="Xb7hH8MSUJpSbSDYk0k2",
    voice_stability=0.8,
    voice_similarity_boost=0.75,
    voice_speaker_boost=False,
)

# Create audio transcriber for captions
audio_transcriber = AssemblyAIAudioTranscriber()

# Create project
project = (
    VideoProject.from_script_generator(script_generator, media)
    .with_title("My Breaking News Video")
    .with_fps(30)
    .with_resolution((1920, 1080))
    .add_narration(speech_synthesizer)
    .add_captions_from_transcriber(audio_transcriber, overwrite=True)
)

# Render project
render_video(project, "My-Breaking-News-Video.mp4")

Or create a video project from scratch:

from mosaico.video.project import VideoProject
from mosaico.assets import ImageAsset, TextAsset, AudioAsset, AssetReference

# Import your media as production-ready assets
assets = [
    ImageAsset.from_path("background.jpg", metadata={"description": "Background image"}),
    ImageAsset.from_path("image1.jpg", metadata={"description": "Image 1"}),
    ImageAsset.from_path("image2.jpg", metadata={"description": "Image 2"}),
    ImageAsset.from_path("image3.jpg", metadata={"description": "Image 3"}),
    TextAsset.from_data("Subtitle 1"),
    TextAsset.from_data("Subtitle 2"),
    TextAsset.from_data("Subtitle 3"),
    AudioAsset.from_path("narration.mp3"),
]

asset_references = [
    AssetReference.from_asset(background, start_time=0, end_time=10),
    AssetReference.from_asset(image1, start_time=10, end_time=20),
    AssetReference.from_asset(image2, start_time=20, end_time=30),
    AssetReference.from_asset(image3, start_time=30, end_time=40),
    AssetReference.from_asset(subtitle1, start_time=40, end_time=50),
    AssetReference.from_asset(subtitle2, start_time=50, end_time=60),
    AssetReference.from_asset(subtitle3, start_time=60, end_time=70),
    AssetReference.from_asset(narration, start_time=70, end_time=80),
]

scene = Scene(description="My Scene").add_asset_references(asset_references)

project = (
    VideoProject()
    .with_title("My Breaking News Video")
    .with_fps(30)
    .with_resolution((1920, 1080))
    .add_assets(assets)
    # Add the asset references as scene events to the timeline
    .add_timeline_events(scene)
    # Or add asset references directly to the timeline
    # .add_timeline_events(asset_references)
)

# Render project
render_video(project, "My-Breaking-News-Video.mp4")

Cookbook

For common usage patterns and examples, see our Cookbook. Some examples include:

  • Creating basic videos with background and text
  • Building photo slideshows with music
  • Generating news videos from articles
  • Working with different asset types
  • Applying effects and animations
  • Using AI for script generation

Documentation

Comprehensive documentation is available here. Documentation includes:

  • Getting Started: Installation, setup, and basic usage
  • Concepts: Overview of key concepts and terminology
  • Cookbook: Examples and tutorials for common tasks
  • API Reference: Detailed reference for all classes and functions
  • Development: Information for contributors and developers
  • Roadmap: Future plans and features

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mosaico-0.1.0rc3.tar.gz (229.9 kB view details)

Uploaded Source

Built Distribution

mosaico-0.1.0rc3-py3-none-any.whl (77.7 kB view details)

Uploaded Python 3

File details

Details for the file mosaico-0.1.0rc3.tar.gz.

File metadata

  • Download URL: mosaico-0.1.0rc3.tar.gz
  • Upload date:
  • Size: 229.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for mosaico-0.1.0rc3.tar.gz
Algorithm Hash digest
SHA256 20681d621db5fac473683bf5754465c3f43d669bbcd6e8d86587735d94b74ad6
MD5 68f1a834da2fbabd8323482b9c45e1a4
BLAKE2b-256 608be1b8f651b9367b99d5bce28a34153ff96afa6ce4faccd99fad572d4e4e58

See more details on using hashes here.

File details

Details for the file mosaico-0.1.0rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for mosaico-0.1.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 933e0ed8a0b12cc1257731c66a41ffe763c976793d0cdea9b6d0e40716b0d93b
MD5 272cb83eae533d04a561c8fd477d5076
BLAKE2b-256 ac99c3ecefa55314ea536688fcffd824bd4be3a46c06319abac743124aeea26c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page