Quickstart
Get video generation and editing running in minutes.
Install
Section titled “Install”uv add lexigram-multimedia-video# Optional: local reference-server dependencies (torch)uv add "lexigram-multimedia-video[wan22-server]" # Wan2.2 serveruv add "lexigram-multimedia-video[cogvideox-server]" # CogVideoX serveruv add "lexigram-multimedia-video[svd-server]" # SVD server# Optional extras for hosted APIsuv add "lexigram-multimedia-video[runway]" # Runway APIuv add "lexigram-multimedia-video[openai]" # OpenAI video gatewaylexigram-multimedia-video depends on lexigram, lexigram-contracts, and aiohttp. The VideoProcessor (editing) additionally requires the ffmpeg binary on PATH — without it the processor simply is not registered.
The default backend is local-http against http://localhost:5004 — no API keys needed.
Minimal Video Generation
Section titled “Minimal Video Generation”import asyncio
from lexigram import Applicationfrom lexigram.di.module import Module, modulefrom lexigram.multimedia.video import VideoModulefrom lexigram.contracts.multimedia import VideoProvider, VideoRequest
@module(imports=[VideoModule.configure()])class AppModule(Module): pass
async def main() -> None: async with Application.boot(modules=[AppModule]) as app: video = await app.container.resolve(VideoProvider)
result = await video.generate( VideoRequest(prompt="a drone flying over misty mountains") ) if result.is_ok(): asset = result.unwrap() # MediaAsset — MP4 bytes or URI print("generated:", asset.provider, asset.mime_type)
if __name__ == "__main__": asyncio.run(main())With an application.yaml:
multimedia: video: backend: "local-http" local_http_base_url: "http://localhost:5004"Minimal Video Processing (needs ffmpeg)
Section titled “Minimal Video Processing (needs ffmpeg)”from lexigram.contracts.multimedia import MediaAsset, Trimfrom lexigram.contracts.multimedia.protocols import VideoProcessor
processor = await app.container.resolve(VideoProcessor)
result = await processor.process( Trim( asset=MediaAsset(mime_type="video/mp4", provider="local", bytes_data=mp4_bytes), start=1.0, end=4.0, ))if result.is_ok(): trimmed = result.unwrap() # MediaAsset(provider="ffmpeg", mime_type="video/mp4")VideoModule exports both VideoProvider (generation) and VideoProcessor (editing) when ffmpeg is available.
What Just Happened
Section titled “What Just Happened”VideoModule.configure()creates aDynamicModulewith aVideoGenerationProvider.Application.boot()runs registration:VideoConfigis bound in the container.- The configured generation backend is constructed (
LocalHttpVideoProviderby default) and bound asVideoProvider; aVideoGenerationTaskhandler wraps it. - If
ffmpegis found onPATH, anFFmpegVideoProcessoris built fromVideoProcessingConfigand bound asVideoProcessor, plus aVideoProcessingTask. - Optional
AsyncSecretStoreProtocol(API keys),RetryPolicyProtocol, andCircuitBreakerProtocolare picked up from the container.
generate(VideoRequest(prompt=...))POSTs the request to/generateand returnsOk(MediaAsset)— orErr(VideoGenerationError).process(VideoOperation)runs an ffmpeg subprocess and returns aMediaAssetin bytes.
Next Steps
Section titled “Next Steps”- Guide — mental model: generation, processing, operations
- How-Tos — task-oriented recipes (trim, concat, compose, subtitles, GIF, …)
- Configuration — every config key and env-var override
- Architecture — internal design and extension points