Minimal video generation and processing library.
Project description
videopython
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]" # + ALL local AI features (GPU recommended)
Python >=3.11, <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. If you need the frames back in memory, load the rendered file: Video.from_path(str(edit.run_to_file("output.mp4"))).
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 LLM-exposed Operation (server-only ops like image_overlay are excluded by default) — pass it straight to Anthropic tool use, OpenAI function calling, or any structured-output API. Pass strict=True for a provider strict-mode grammar that prevents simple bound violations at decode time.
The plan parses permissively (shape only) and owns numeric bounds at validation, so a refine loop converges fast: edit.check(meta) collects every structured PlanError in one pass, edit.repair(meta) auto-clamps the mechanical violations (window/timestamp overruns, negatives) with a reported changelog, and edit.normalize_dimensions(meta, target) makes heterogeneous segments concat-compatible by construction. edit.validate() still raises a typed PlanValidationError (a ValueError with structured .errors) for the single-error path.
See the LLM Integration Guide for end-to-end examples, the collect/repair/normalize refine loop, and operation discovery patterns.
Features
videopython.base—Video,VideoMetadata,FrameIterator,Transcription, and shared result types (BoundingBox,FaceTrack,SceneBoundary, ...). No AI dependencies.videopython.audio—Audiowith overlay, concat, normalize, time-stretch, silence detection, segment classification.videopython.editing—Operation/Effectfoundation,VideoEditplan runner with JSON Schema + streaming execution. Transforms (resize, crop, fps, speed, freeze, silence removal; cutting is the segment's own start/end) 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,ObjectDetector,SemanticSceneDetector), theFaceTrackingCroptransform, theObjectDetectionOverlayeffect (per-frame bounding boxes + labels), and the full-pipelineVideoAnalyzer.videopython.ai.dubbing—VideoDubberfor 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file videopython-0.49.0.tar.gz.
File metadata
- Download URL: videopython-0.49.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e108ff0ab5b77365f11ef6c9de0f650baa4f7589a3057feff56ec85171b2bb51
|
|
| MD5 |
4dac8666a05001e6f8d5baca7dd0a7fb
|
|
| BLAKE2b-256 |
4e33d5618112c859c5dab5a8afffc011dd7c7eaea53d20328cdd98c5b1c9c9b2
|
Provenance
The following attestation bundles were made for videopython-0.49.0.tar.gz:
Publisher:
publish.yml on BartWojtowicz/videopython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
videopython-0.49.0.tar.gz -
Subject digest:
e108ff0ab5b77365f11ef6c9de0f650baa4f7589a3057feff56ec85171b2bb51 - Sigstore transparency entry: 1899317466
- Sigstore integration time:
-
Permalink:
BartWojtowicz/videopython@e74b654b27daded22a990f76a3d92a0e56270349 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BartWojtowicz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e74b654b27daded22a990f76a3d92a0e56270349 -
Trigger Event:
push
-
Statement type:
File details
Details for the file videopython-0.49.0-py3-none-any.whl.
File metadata
- Download URL: videopython-0.49.0-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b7bbae2711b593ae5735f3dd9df1f6fef28b81d0db1e7a518826b55b7fc27dc
|
|
| MD5 |
4f48d59a8a45e3bf264e1e00fdb8217b
|
|
| BLAKE2b-256 |
a3f371337b4efb040d91f38faa12603376a51ed8d9f65a8988b8f24def8cc30c
|
Provenance
The following attestation bundles were made for videopython-0.49.0-py3-none-any.whl:
Publisher:
publish.yml on BartWojtowicz/videopython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
videopython-0.49.0-py3-none-any.whl -
Subject digest:
0b7bbae2711b593ae5735f3dd9df1f6fef28b81d0db1e7a518826b55b7fc27dc - Sigstore transparency entry: 1899317561
- Sigstore integration time:
-
Permalink:
BartWojtowicz/videopython@e74b654b27daded22a990f76a3d92a0e56270349 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BartWojtowicz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e74b654b27daded22a990f76a3d92a0e56270349 -
Trigger Event:
push
-
Statement type: