Skip to main content

Minimal video generation and processing library.

Project description

videopython

PyPI Python License

Minimal, LLM-friendly Python library for programmatic video editing, processing, and AI video workflows.

Full documentation: videopython.com

Disclaimer: This project started as a hand-written hobby project, but most of the code is now produced by LLM agents. Humans still drive direction, approve changes, and own design decisions.

Installation

# Install FFmpeg first (macOS: brew install ffmpeg | Debian: apt-get install ffmpeg)
pip install videopython          # core video/audio editing
pip install "videopython[ai]"    # + local AI features (GPU recommended)

Python >=3.10, <3.14. AI features run locally — no cloud API keys required, but model weights are downloaded on first use.

Quick Start

JSON editing plans

A VideoEdit is a multi-segment plan, defined as a dict (or JSON), validated and executed against the source files:

from videopython.editing import VideoEdit

edit = VideoEdit.from_dict({
    "segments": [{
        "source": "raw.mp4",
        "start": 10.0,
        "end": 20.0,
        "operations": [
            {"op": "resize", "width": 1080, "height": 1920},
            {"op": "color_adjust", "saturation": 1.15, "contrast": 1.05},
            {"op": "fade", "mode": "in", "duration": 0.5},
        ],
    }],
})
edit.validate()                  # dry-run via metadata, no frames loaded
edit.run_to_file("output.mp4")   # streams ffmpeg decode → effects → encode

run_to_file() streams ffmpeg decode → per-frame effects → encode, so memory stays bounded even for hour-long sources. Use edit.run() to get a Video back in memory instead.

AI generation

from videopython.ai import TextToImage, ImageToVideo, TextToSpeech

image = TextToImage().generate_image("A cinematic mountain sunrise")
video = ImageToVideo().generate_video(image=image)
audio = TextToSpeech().generate_audio("Welcome to videopython.")
video.add_audio(audio).save("ai_video.mp4")

LLM & AI Agent Integration

Every operation is a Pydantic model whose fields ARE the JSON wire format. VideoEdit.json_schema() returns a JSON Schema with a discriminated union over every registered Operation — pass it straight to Anthropic tool use, OpenAI function calling, or any structured-output API. Then edit.validate() dry-runs the plan via metadata before any frames are loaded, so a failed LLM output can be fed back as an error and retried cheaply.

See the LLM Integration Guide for end-to-end examples, validation error loops, and operation discovery patterns.

Features

  • videopython.baseVideo, VideoMetadata, FrameIterator, ImageText, Transcription, and shared result types (BoundingBox, FaceTrack, SceneBoundary, ...). No AI dependencies.
  • videopython.audioAudio with overlay, concat, normalize, time-stretch, silence detection, segment classification.
  • videopython.editingOperation/Effect foundation, VideoEdit plan runner with JSON Schema + streaming execution. Transforms (cut, resize, crop, fps, speed, reverse, freeze, silence removal) and effects (blur, zoom, color grading, vignette, Ken Burns, fade, overlays, animated subtitles).
  • videopython.ai (install with [ai]) — generation (TextToVideo, ImageToVideo, TextToImage, TextToSpeech, TextToMusic), understanding (AudioToText, AudioClassifier, SceneVLM, FaceTracker, SemanticSceneDetector), FaceTrackingCrop transform, and the full-pipeline VideoAnalyzer.
  • videopython.ai.dubbingVideoDubber for voice-cloned revoicing with timing sync.

Examples

Development

See DEVELOPMENT.md for local setup, testing, and contribution workflow.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

videopython-0.34.1.tar.gz (538.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

videopython-0.34.1-py3-none-any.whl (562.9 kB view details)

Uploaded Python 3

File details

Details for the file videopython-0.34.1.tar.gz.

File metadata

  • Download URL: videopython-0.34.1.tar.gz
  • Upload date:
  • Size: 538.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for videopython-0.34.1.tar.gz
Algorithm Hash digest
SHA256 e48c7838d9270ceaf2cedec9cd9000823a28e9bf4a3b68323de7295f709593e7
MD5 12ffb8b61b5f3822a95ae1d007cc5f03
BLAKE2b-256 978c7ef2280ba65f3aa7f695fe3cf11ef841bd8c9a7cbb7c414e1b6306d21606

See more details on using hashes here.

Provenance

The following attestation bundles were made for videopython-0.34.1.tar.gz:

Publisher: publish.yml on BartWojtowicz/videopython

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file videopython-0.34.1-py3-none-any.whl.

File metadata

  • Download URL: videopython-0.34.1-py3-none-any.whl
  • Upload date:
  • Size: 562.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for videopython-0.34.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f3223bb5b8a803a410992443b1685a319e955971bfa590dd97a0086a1161a11
MD5 e69d84a5abc091121eeee81f9d4c5d63
BLAKE2b-256 9b19f30ff6df7658e171e028b9833ea717887a20cf77267c652bb69c603af00f

See more details on using hashes here.

Provenance

The following attestation bundles were made for videopython-0.34.1-py3-none-any.whl:

Publisher: publish.yml on BartWojtowicz/videopython

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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