videopython 0.55.4__tar.gz → 0.57.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. {videopython-0.55.4 → videopython-0.57.0}/.gitignore +1 -1
  2. {videopython-0.55.4 → videopython-0.57.0}/PKG-INFO +50 -17
  3. {videopython-0.55.4 → videopython-0.57.0}/README.md +39 -14
  4. {videopython-0.55.4 → videopython-0.57.0}/pyproject.toml +24 -4
  5. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/_revisions.py +1 -1
  6. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/audio_ops.py +1 -1
  7. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/models.py +1 -3
  8. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/pipeline.py +1 -2
  9. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/transforms.py +4 -6
  10. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/audio.py +3 -2
  11. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/temporal.py +0 -8
  12. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/audio/audio.py +0 -12
  13. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/_dimensions.py +0 -8
  14. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/_ffmpeg.py +1 -2
  15. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/effects.py +2 -5
  16. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/transcription_overlay.py +1 -1
  17. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/video_edit.py +8 -10
  18. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/mcp/__init__.py +1 -1
  19. videopython-0.57.0/src/videopython/mcp/_models.py +83 -0
  20. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/mcp/server.py +68 -49
  21. {videopython-0.55.4 → videopython-0.57.0}/LICENSE +0 -0
  22. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/__init__.py +0 -0
  23. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/__init__.py +0 -0
  24. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/_device.py +0 -0
  25. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/_ollama.py +0 -0
  26. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/_optional.py +0 -0
  27. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/_predictor.py +0 -0
  28. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/auto_edit/__init__.py +0 -0
  29. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/auto_edit/backend.py +0 -0
  30. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/auto_edit/catalog.py +0 -0
  31. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/auto_edit/editor.py +0 -0
  32. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/auto_edit/local.py +0 -0
  33. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/auto_edit/models.py +0 -0
  34. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/auto_edit/resolve.py +0 -0
  35. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/__init__.py +0 -0
  36. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/_tts_backend.py +0 -0
  37. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/config.py +0 -0
  38. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/dubber.py +0 -0
  39. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/quality.py +0 -0
  40. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/remux.py +0 -0
  41. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/separation.py +0 -0
  42. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/timing.py +0 -0
  43. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/translation.py +0 -0
  44. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/dubbing/voice_sample.py +0 -0
  45. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/effects.py +0 -0
  46. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/errors.py +0 -0
  47. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/generation/__init__.py +0 -0
  48. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/generation/audio.py +0 -0
  49. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/generation/image.py +0 -0
  50. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/generation/video.py +0 -0
  51. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/keyframe.py +0 -0
  52. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/ops.py +0 -0
  53. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/__init__.py +0 -0
  54. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/_detector.py +0 -0
  55. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/classification.py +0 -0
  56. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/faces.py +0 -0
  57. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/image.py +0 -0
  58. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/understanding/objects.py +0 -0
  59. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/video_analysis/__init__.py +0 -0
  60. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/video_analysis/analyzer.py +0 -0
  61. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/video_analysis/detectors.py +0 -0
  62. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/video_analysis/models.py +0 -0
  63. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/video_analysis/sampling.py +0 -0
  64. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/ai/video_analysis/source_metadata.py +0 -0
  65. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/audio/__init__.py +0 -0
  66. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/audio/analysis.py +0 -0
  67. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/__init__.py +0 -0
  68. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/_video_io.py +0 -0
  69. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/description.py +0 -0
  70. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/draw_detections.py +0 -0
  71. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/exceptions.py +0 -0
  72. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/Anton-OFL.txt +0 -0
  73. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/Anton-Regular.ttf +0 -0
  74. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/BebasNeue-OFL.txt +0 -0
  75. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/BebasNeue-Regular.ttf +0 -0
  76. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/DejaVuSans.ttf +0 -0
  77. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/LICENSE_DEJAVU +0 -0
  78. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/Lato-Bold.ttf +0 -0
  79. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/Lato-OFL.txt +0 -0
  80. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/Poppins-Bold.ttf +0 -0
  81. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/Poppins-OFL.txt +0 -0
  82. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/fonts/__init__.py +0 -0
  83. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/transcription.py +0 -0
  84. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/base/video.py +0 -0
  85. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/__init__.py +0 -0
  86. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/_ass.py +0 -0
  87. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/_easing.py +0 -0
  88. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/_schema.py +0 -0
  89. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/audio_ops.py +0 -0
  90. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/operation.py +0 -0
  91. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/streaming.py +0 -0
  92. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/editing/transforms.py +0 -0
  93. {videopython-0.55.4 → videopython-0.57.0}/src/videopython/py.typed +0 -0
@@ -151,7 +151,7 @@ data/exported/*.mp4
151
151
  # Sample / working videos (keep them out of the repo root)
152
152
  *.mp4
153
153
  !data/exported/example.mp4
154
+ !docs/assets/agent-edit-demo.mp4
154
155
 
155
156
  # Local scratch / sign-off artifacts
156
157
  libass_signoff/
157
-
@@ -1,14 +1,14 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: videopython
3
- Version: 0.55.4
4
- Summary: Minimal video generation and processing library.
3
+ Version: 0.57.0
4
+ Summary: LLM-friendly Python video editing with JSON plans, local AI, and MCP tools.
5
5
  Project-URL: Homepage, https://videopython.com
6
6
  Project-URL: Repository, https://github.com/bartwojtowicz/videopython/
7
7
  Project-URL: Documentation, https://videopython.com
8
8
  Author-email: Bartosz Wójtowicz <bartoszwojtowicz@outlook.com>, Bartosz Rudnikowicz <bartoszrudnikowicz840@gmail.com>, Piotr Pukisz <piotr.pukisz@gmail.com>
9
9
  License: Apache-2.0
10
10
  License-File: LICENSE
11
- Keywords: ai,editing,generation,movie,opencv,python,shorts,video,videopython
11
+ Keywords: ai,ai-agents,editing,ffmpeg,generation,llm,mcp,movie,ollama,opencv,python,shorts,video,video-editing,videopython
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3
@@ -43,7 +43,15 @@ Requires-Dist: transformers>=5.2.0; extra == 'ai'
43
43
  Requires-Dist: transnetv2-pytorch>=1.0.5; extra == 'ai'
44
44
  Requires-Dist: videopython-chatterbox>=0.1.7.post1; extra == 'ai'
45
45
  Provides-Extra: mcp
46
+ Requires-Dist: imagehash>=4.3; extra == 'mcp'
46
47
  Requires-Dist: mcp<2,>=1.27; extra == 'mcp'
48
+ Requires-Dist: numba>=0.62; extra == 'mcp'
49
+ Requires-Dist: ollama>=0.5.0; extra == 'mcp'
50
+ Requires-Dist: openai-whisper>=20240930; extra == 'mcp'
51
+ Requires-Dist: torch>=2.8.0; extra == 'mcp'
52
+ Requires-Dist: torchvision>=0.23.0; extra == 'mcp'
53
+ Requires-Dist: transformers>=5.2.0; extra == 'mcp'
54
+ Requires-Dist: transnetv2-pytorch>=1.0.5; extra == 'mcp'
47
55
  Description-Content-Type: text/markdown
48
56
 
49
57
  # videopython
@@ -51,23 +59,34 @@ Description-Content-Type: text/markdown
51
59
  [![PyPI](https://img.shields.io/pypi/v/videopython)](https://pypi.org/project/videopython/)
52
60
  [![Python](https://img.shields.io/pypi/pyversions/videopython)](https://pypi.org/project/videopython/)
53
61
  [![License](https://img.shields.io/github/license/BartWojtowicz/videopython)](LICENSE)
62
+ [![CI](https://github.com/BartWojtowicz/videopython/actions/workflows/ci.yml/badge.svg)](https://github.com/BartWojtowicz/videopython/actions/workflows/ci.yml)
54
63
 
55
- Minimal, LLM-friendly Python library for programmatic video editing, processing, and AI video workflows.
64
+ Python library for structured, local-first video editing, processing, and AI workflows.
65
+ Build edits as validated Python models or JSON plans, then render them through a
66
+ bounded-memory streaming engine.
56
67
 
57
68
  Full documentation: [videopython.com](https://videopython.com)
58
69
 
59
- > **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.
60
-
61
70
  ## Installation
62
71
 
63
72
  ```bash
64
73
  # Install FFmpeg first (macOS: brew install ffmpeg | Debian: apt-get install ffmpeg)
65
74
  pip install videopython # core video/audio editing
66
- pip install "videopython[ai]" # + ALL local AI features (GPU recommended)
67
- pip install "videopython[ai,mcp]" # + MCP server for agent-driven editing
75
+ pip install "videopython[ai]" # + all local AI features
76
+ pip install "videopython[mcp]" # + MCP and its focused analysis/editing stack
68
77
  ```
69
78
 
70
- Python `>=3.11, <3.14`. AI features run locally — no cloud API keys required, but model weights are downloaded on first use. LLM-driven editing and scene captioning use a local [Ollama](https://ollama.com) server (`ollama pull qwen3.6:27b`). See the [install guide](https://videopython.com/install/) for FFmpeg, Ollama, and hardware details.
79
+ `[ai]` and `[mcp]` are independent. Use `[ai,mcp]` when one environment needs every AI
80
+ capability and the MCP server.
81
+
82
+ Python `>=3.11, <3.14`. AI features run locally without cloud inference APIs, but model
83
+ weights are downloaded on first use. LLM-driven editing and scene captioning use a local
84
+ [Ollama](https://ollama.com) server (`ollama pull qwen3.6:27b`). Image and video
85
+ generation require an NVIDIA CUDA GPU. See the [install guide](https://videopython.com/install/)
86
+ for FFmpeg, Ollama, model downloads, and hardware details.
87
+
88
+ Videopython is pre-1.0. Public interfaces can still change before the stable release;
89
+ see the [roadmap](ROADMAP.md) for the stability criteria.
71
90
 
72
91
  ## Quick start
73
92
 
@@ -94,6 +113,11 @@ edit.run_to_file("output.mp4") # streams ffmpeg decode → effects → encode
94
113
 
95
114
  `run_to_file()` streams, so memory stays bounded even for hour-long sources. Walk through it in [Tutorial 1](https://videopython.com/tutorials/first-edit/).
96
115
 
116
+ [![A vertical clip rendered from a videopython JSON plan](https://videopython.com/assets/edit-plan-demo-poster.jpg)](https://videopython.com/how-to/agent-edit-demo/)
117
+
118
+ *A reproducible eight-second edit rendered from a JSON plan. View the plan, source, and
119
+ replay script in the [demo](https://videopython.com/how-to/agent-edit-demo/).*
120
+
97
121
  ### Automatic editing (local LLM)
98
122
 
99
123
  Give `AutoEditor` your clips and a brief; a local Ollama vision model selects and orders the shots, and you get back a runnable `VideoEdit`:
@@ -113,6 +137,9 @@ The model picks scenes **by id** from a catalog built from scene detection + cap
113
137
 
114
138
  ### AI generation
115
139
 
140
+ Image and video generation use large CUDA-only models. Speech generation can run on CPU
141
+ or CUDA.
142
+
116
143
  ```python
117
144
  from videopython.ai import TextToImage, ImageToVideo, TextToSpeech
118
145
 
@@ -122,15 +149,20 @@ audio = TextToSpeech().generate_audio("Welcome to videopython.")
122
149
  video.add_audio(audio).save("ai_video.mp4")
123
150
  ```
124
151
 
125
- ## LLM & AI agent integration
152
+ ## Structured plans and automation
126
153
 
127
- Putting an LLM in the loop works three ways, differing in who owns the model:
154
+ The same validation and rendering path works whether a plan is written directly, loaded
155
+ from JSON, produced by a model, or submitted through MCP:
128
156
 
129
- 1. **Bring your own LLM** — videopython gives your model the JSON Schema and a structured refine loop; your model authors the plans. [Guide](https://videopython.com/how-to/llm-plans/)
130
- 2. **`AutoEditor`** — a local Ollama vision model is the planner. [Guide](https://videopython.com/how-to/auto-editing/)
131
- 3. **MCP server** — `videopython-mcp` exposes the pipeline as [Model Context Protocol](https://modelcontextprotocol.io) tools, so an agent like Claude drives editing with its own model. [Guide](https://videopython.com/how-to/mcp-server/)
157
+ 1. **Python or JSON** — construct `VideoEdit` directly, as in the quick start.
158
+ 2. **Your own LLM** — use the generated JSON Schema and structured refine loop. [Guide](https://videopython.com/how-to/llm-plans/)
159
+ 3. **`AutoEditor`** — use a local Ollama vision model to select and order scenes. [Guide](https://videopython.com/how-to/auto-editing/)
160
+ 4. **MCP** — expose analysis, planning, validation, and rendering tools to any compatible client. [Guide](https://videopython.com/how-to/mcp-server/)
132
161
 
133
- Mode 1 in brief: every operation is a Pydantic model whose fields *are* the JSON wire format, so `VideoEdit.json_schema()` hands your model a ready-made tool schema — a discriminated union over every LLM-exposed op (pass `strict=True` for provider grammar modes). Plans parse permissively and own their numeric bounds at validation, so a refine loop converges fast:
162
+ For schema-driven integrations, every operation is a Pydantic model whose fields are the
163
+ JSON wire format. `VideoEdit.json_schema()` returns a discriminated union over every
164
+ exposed operation; pass `strict=True` for provider grammar modes. Plans parse
165
+ permissively and report numeric bounds during validation, so a refine loop can use:
134
166
 
135
167
  - **`edit.check(meta)`** — collect *every* structured error in one pass, not just the first
136
168
  - **`edit.repair(meta)`** — auto-clamp mechanical violations (overruns, negatives) with a changelog
@@ -143,10 +175,10 @@ Why it is built this way: [LLM-first design](https://videopython.com/explanation
143
175
  - **`videopython.base`** — `Video`, `VideoMetadata`, `FrameIterator`, `Transcription`, and shared result types (`BoundingBox`, `FaceTrack`, `SceneBoundary`, ...). No AI dependencies.
144
176
  - **`videopython.audio`** — `Audio` with overlay, concat, normalize, time-stretch, silence detection, segment classification.
145
177
  - **`videopython.editing`** — `Operation`/`Effect` foundation, `VideoEdit` plan 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).
146
- - **`videopython.ai`** *(install with `[ai]`)* — generation (`TextToVideo`, `ImageToVideo`, `TextToImage`, `TextToSpeech`, `TextToMusic`), understanding (`AudioToText`, `AudioClassifier`, `SceneVLM`, `FaceTracker`, `ObjectDetector`, `SemanticSceneDetector`), the `FaceTrackingCrop` transform, the `ObjectDetectionOverlay` effect, and the full-pipeline `VideoAnalyzer`. Scene captioning and dubbing translation run on a local [Ollama](https://ollama.com) model.
178
+ - **`videopython.ai`** *(install with `[ai]`)* — generation (`TextToVideo`, `ImageToVideo`, `TextToImage`, `TextToSpeech`, `TextToMusic`), understanding (`AudioToText`, `AudioClassifier`, `SceneVLM`, `FaceShotTracker`, `FaceSmoothingTracker`, `ObjectDetector`, `SemanticSceneDetector`), the `FaceTrackingCrop` transform, the `ObjectDetectionOverlay` effect, and the full-pipeline `VideoAnalyzer`. Scene captioning and dubbing translation run on a local [Ollama](https://ollama.com) model.
147
179
  - **`videopython.ai.auto_edit`** — `AutoEditor` + `OllamaVisionLLM`: plan and render an edit from sources + a one-line brief.
148
180
  - **`videopython.ai.dubbing`** — `VideoDubber` for voice-cloned revoicing with timing sync.
149
- - **`videopython.mcp`** *(install with `[ai,mcp]`)* — `videopython-mcp`, an MCP stdio server exposing the auto-edit pipeline so an agent drives editing.
181
+ - **`videopython.mcp`** *(install with `[mcp]`)* — `videopython-mcp`, an MCP stdio server exposing the auto-edit pipeline to compatible clients. The extra includes the analysis and AI editing dependencies, but not generation, dubbing, diarization, source separation, or TTS.
150
182
 
151
183
  ## Documentation
152
184
 
@@ -162,3 +194,4 @@ The docs follow [Diátaxis](https://diataxis.fr): four sections, each answering
162
194
  ## Development
163
195
 
164
196
  See [`DEVELOPMENT.md`](DEVELOPMENT.md) for local setup, testing, docs, and the release workflow.
197
+ See [`ROADMAP.md`](ROADMAP.md) for project direction and the criteria for 1.0.
@@ -3,23 +3,34 @@
3
3
  [![PyPI](https://img.shields.io/pypi/v/videopython)](https://pypi.org/project/videopython/)
4
4
  [![Python](https://img.shields.io/pypi/pyversions/videopython)](https://pypi.org/project/videopython/)
5
5
  [![License](https://img.shields.io/github/license/BartWojtowicz/videopython)](LICENSE)
6
+ [![CI](https://github.com/BartWojtowicz/videopython/actions/workflows/ci.yml/badge.svg)](https://github.com/BartWojtowicz/videopython/actions/workflows/ci.yml)
6
7
 
7
- Minimal, LLM-friendly Python library for programmatic video editing, processing, and AI video workflows.
8
+ Python library for structured, local-first video editing, processing, and AI workflows.
9
+ Build edits as validated Python models or JSON plans, then render them through a
10
+ bounded-memory streaming engine.
8
11
 
9
12
  Full documentation: [videopython.com](https://videopython.com)
10
13
 
11
- > **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.
12
-
13
14
  ## Installation
14
15
 
15
16
  ```bash
16
17
  # Install FFmpeg first (macOS: brew install ffmpeg | Debian: apt-get install ffmpeg)
17
18
  pip install videopython # core video/audio editing
18
- pip install "videopython[ai]" # + ALL local AI features (GPU recommended)
19
- pip install "videopython[ai,mcp]" # + MCP server for agent-driven editing
19
+ pip install "videopython[ai]" # + all local AI features
20
+ pip install "videopython[mcp]" # + MCP and its focused analysis/editing stack
20
21
  ```
21
22
 
22
- Python `>=3.11, <3.14`. AI features run locally — no cloud API keys required, but model weights are downloaded on first use. LLM-driven editing and scene captioning use a local [Ollama](https://ollama.com) server (`ollama pull qwen3.6:27b`). See the [install guide](https://videopython.com/install/) for FFmpeg, Ollama, and hardware details.
23
+ `[ai]` and `[mcp]` are independent. Use `[ai,mcp]` when one environment needs every AI
24
+ capability and the MCP server.
25
+
26
+ Python `>=3.11, <3.14`. AI features run locally without cloud inference APIs, but model
27
+ weights are downloaded on first use. LLM-driven editing and scene captioning use a local
28
+ [Ollama](https://ollama.com) server (`ollama pull qwen3.6:27b`). Image and video
29
+ generation require an NVIDIA CUDA GPU. See the [install guide](https://videopython.com/install/)
30
+ for FFmpeg, Ollama, model downloads, and hardware details.
31
+
32
+ Videopython is pre-1.0. Public interfaces can still change before the stable release;
33
+ see the [roadmap](ROADMAP.md) for the stability criteria.
23
34
 
24
35
  ## Quick start
25
36
 
@@ -46,6 +57,11 @@ edit.run_to_file("output.mp4") # streams ffmpeg decode → effects → encode
46
57
 
47
58
  `run_to_file()` streams, so memory stays bounded even for hour-long sources. Walk through it in [Tutorial 1](https://videopython.com/tutorials/first-edit/).
48
59
 
60
+ [![A vertical clip rendered from a videopython JSON plan](https://videopython.com/assets/edit-plan-demo-poster.jpg)](https://videopython.com/how-to/agent-edit-demo/)
61
+
62
+ *A reproducible eight-second edit rendered from a JSON plan. View the plan, source, and
63
+ replay script in the [demo](https://videopython.com/how-to/agent-edit-demo/).*
64
+
49
65
  ### Automatic editing (local LLM)
50
66
 
51
67
  Give `AutoEditor` your clips and a brief; a local Ollama vision model selects and orders the shots, and you get back a runnable `VideoEdit`:
@@ -65,6 +81,9 @@ The model picks scenes **by id** from a catalog built from scene detection + cap
65
81
 
66
82
  ### AI generation
67
83
 
84
+ Image and video generation use large CUDA-only models. Speech generation can run on CPU
85
+ or CUDA.
86
+
68
87
  ```python
69
88
  from videopython.ai import TextToImage, ImageToVideo, TextToSpeech
70
89
 
@@ -74,15 +93,20 @@ audio = TextToSpeech().generate_audio("Welcome to videopython.")
74
93
  video.add_audio(audio).save("ai_video.mp4")
75
94
  ```
76
95
 
77
- ## LLM & AI agent integration
96
+ ## Structured plans and automation
78
97
 
79
- Putting an LLM in the loop works three ways, differing in who owns the model:
98
+ The same validation and rendering path works whether a plan is written directly, loaded
99
+ from JSON, produced by a model, or submitted through MCP:
80
100
 
81
- 1. **Bring your own LLM** — videopython gives your model the JSON Schema and a structured refine loop; your model authors the plans. [Guide](https://videopython.com/how-to/llm-plans/)
82
- 2. **`AutoEditor`** — a local Ollama vision model is the planner. [Guide](https://videopython.com/how-to/auto-editing/)
83
- 3. **MCP server** — `videopython-mcp` exposes the pipeline as [Model Context Protocol](https://modelcontextprotocol.io) tools, so an agent like Claude drives editing with its own model. [Guide](https://videopython.com/how-to/mcp-server/)
101
+ 1. **Python or JSON** — construct `VideoEdit` directly, as in the quick start.
102
+ 2. **Your own LLM** — use the generated JSON Schema and structured refine loop. [Guide](https://videopython.com/how-to/llm-plans/)
103
+ 3. **`AutoEditor`** — use a local Ollama vision model to select and order scenes. [Guide](https://videopython.com/how-to/auto-editing/)
104
+ 4. **MCP** — expose analysis, planning, validation, and rendering tools to any compatible client. [Guide](https://videopython.com/how-to/mcp-server/)
84
105
 
85
- Mode 1 in brief: every operation is a Pydantic model whose fields *are* the JSON wire format, so `VideoEdit.json_schema()` hands your model a ready-made tool schema — a discriminated union over every LLM-exposed op (pass `strict=True` for provider grammar modes). Plans parse permissively and own their numeric bounds at validation, so a refine loop converges fast:
106
+ For schema-driven integrations, every operation is a Pydantic model whose fields are the
107
+ JSON wire format. `VideoEdit.json_schema()` returns a discriminated union over every
108
+ exposed operation; pass `strict=True` for provider grammar modes. Plans parse
109
+ permissively and report numeric bounds during validation, so a refine loop can use:
86
110
 
87
111
  - **`edit.check(meta)`** — collect *every* structured error in one pass, not just the first
88
112
  - **`edit.repair(meta)`** — auto-clamp mechanical violations (overruns, negatives) with a changelog
@@ -95,10 +119,10 @@ Why it is built this way: [LLM-first design](https://videopython.com/explanation
95
119
  - **`videopython.base`** — `Video`, `VideoMetadata`, `FrameIterator`, `Transcription`, and shared result types (`BoundingBox`, `FaceTrack`, `SceneBoundary`, ...). No AI dependencies.
96
120
  - **`videopython.audio`** — `Audio` with overlay, concat, normalize, time-stretch, silence detection, segment classification.
97
121
  - **`videopython.editing`** — `Operation`/`Effect` foundation, `VideoEdit` plan 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).
98
- - **`videopython.ai`** *(install with `[ai]`)* — generation (`TextToVideo`, `ImageToVideo`, `TextToImage`, `TextToSpeech`, `TextToMusic`), understanding (`AudioToText`, `AudioClassifier`, `SceneVLM`, `FaceTracker`, `ObjectDetector`, `SemanticSceneDetector`), the `FaceTrackingCrop` transform, the `ObjectDetectionOverlay` effect, and the full-pipeline `VideoAnalyzer`. Scene captioning and dubbing translation run on a local [Ollama](https://ollama.com) model.
122
+ - **`videopython.ai`** *(install with `[ai]`)* — generation (`TextToVideo`, `ImageToVideo`, `TextToImage`, `TextToSpeech`, `TextToMusic`), understanding (`AudioToText`, `AudioClassifier`, `SceneVLM`, `FaceShotTracker`, `FaceSmoothingTracker`, `ObjectDetector`, `SemanticSceneDetector`), the `FaceTrackingCrop` transform, the `ObjectDetectionOverlay` effect, and the full-pipeline `VideoAnalyzer`. Scene captioning and dubbing translation run on a local [Ollama](https://ollama.com) model.
99
123
  - **`videopython.ai.auto_edit`** — `AutoEditor` + `OllamaVisionLLM`: plan and render an edit from sources + a one-line brief.
100
124
  - **`videopython.ai.dubbing`** — `VideoDubber` for voice-cloned revoicing with timing sync.
101
- - **`videopython.mcp`** *(install with `[ai,mcp]`)* — `videopython-mcp`, an MCP stdio server exposing the auto-edit pipeline so an agent drives editing.
125
+ - **`videopython.mcp`** *(install with `[mcp]`)* — `videopython-mcp`, an MCP stdio server exposing the auto-edit pipeline to compatible clients. The extra includes the analysis and AI editing dependencies, but not generation, dubbing, diarization, source separation, or TTS.
102
126
 
103
127
  ## Documentation
104
128
 
@@ -114,3 +138,4 @@ The docs follow [Diátaxis](https://diataxis.fr): four sections, each answering
114
138
  ## Development
115
139
 
116
140
  See [`DEVELOPMENT.md`](DEVELOPMENT.md) for local setup, testing, docs, and the release workflow.
141
+ See [`ROADMAP.md`](ROADMAP.md) for project direction and the criteria for 1.0.
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "videopython"
3
- version = "0.55.4"
4
- description = "Minimal video generation and processing library."
3
+ version = "0.57.0"
4
+ description = "LLM-friendly Python video editing with JSON plans, local AI, and MCP tools."
5
5
  authors = [
6
6
  { name = "Bartosz Wójtowicz", email = "bartoszwojtowicz@outlook.com" },
7
7
  { name = "Bartosz Rudnikowicz", email = "bartoszrudnikowicz840@gmail.com" },
@@ -19,7 +19,13 @@ keywords = [
19
19
  "generation",
20
20
  "editing",
21
21
  "ai",
22
+ "ai-agents",
23
+ "ffmpeg",
24
+ "llm",
25
+ "mcp",
26
+ "ollama",
22
27
  "shorts",
28
+ "video-editing",
23
29
  ]
24
30
  classifiers = [
25
31
  "License :: OSI Approved :: Apache Software License",
@@ -42,7 +48,10 @@ dependencies = [
42
48
 
43
49
  [dependency-groups]
44
50
  dev = [
51
+ "imagehash>=4.3",
52
+ "mcp>=1.27,<2",
45
53
  "pre-commit>=3.8.0",
54
+ "pyloudnorm>=0.1.1",
46
55
  "ruff>=0.1.14",
47
56
  "mypy>=1.8.0",
48
57
  "pytest>=7.4.0",
@@ -108,8 +117,19 @@ ai = [
108
117
  # save()/load() through it and it is ABI-coupled to torch.
109
118
  "torchcodec>=0.7.0",
110
119
  ]
111
- # MCP server (videopython/mcp/). Pin <2 — v2 is pre-release/breaking.
112
- mcp = ["mcp>=1.27,<2"]
120
+ # Agent-editing pipeline: analysis + AI editing operations, without generation,
121
+ # dubbing, diarization, source separation, or TTS. Pin MCP <2 — v2 is breaking.
122
+ mcp = [
123
+ "mcp>=1.27,<2",
124
+ "openai-whisper>=20240930",
125
+ "numba>=0.62",
126
+ "transnetv2-pytorch>=1.0.5",
127
+ "transformers>=5.2.0",
128
+ "imagehash>=4.3",
129
+ "ollama>=0.5.0",
130
+ "torch>=2.8.0",
131
+ "torchvision>=0.23.0",
132
+ ]
113
133
 
114
134
  [project.scripts]
115
135
  videopython-mcp = "videopython.mcp.server:main"
@@ -12,7 +12,7 @@ model API (``https://huggingface.co/api/models/<repo_id>``), i.e. the latest
12
12
  commit on the repo's ``main`` branch at the time it was captured.
13
13
 
14
14
  Refreshing SHAs:
15
- For each ``model_id`` in ``MODEL_REVISIONS`` (and the TODO list, if any),
15
+ For each ``model_id`` in ``MODEL_REVISIONS`` and the unpinned list below,
16
16
  fetch ``https://huggingface.co/api/models/<model_id>`` and copy the JSON
17
17
  ``sha`` field into the dict. Bump deliberately -- the whole point of a pin
18
18
  is that it does not move on its own. After editing, re-run the AI suite
@@ -30,7 +30,7 @@ def rms(data: np.ndarray) -> float:
30
30
  # --- Source-prosody-driven expressiveness (Chatterbox TTS knobs) -----------
31
31
  # Source-segment RMS / whole-vocals RMS below CALM lands in the calm bucket;
32
32
  # above DRAMATIC in the dramatic bucket; in between gets Chatterbox's defaults.
33
- # Knob values picked by-ear on cam1_1min.mp4 -- see RELEASE_NOTES 0.29.0.
33
+ # These thresholds were tuned against a representative speech clip.
34
34
  CALM_RATIO_THRESHOLD = 0.7
35
35
  DRAMATIC_RATIO_THRESHOLD = 1.3
36
36
  _CALM = Expressiveness(exaggeration=0.3, cfg_weight=0.7)
@@ -120,9 +120,7 @@ class TranslatedSegment(BaseModel):
120
120
 
121
121
  @model_validator(mode="after")
122
122
  def _default_timing_from_segment(self) -> TranslatedSegment:
123
- # ``start == end == 0.0`` is the dataclass-era sentinel for "use the
124
- # original segment's timing." Preserved so legacy callers (and the
125
- # dub cache wire format) keep working.
123
+ # Cached records use zero start and end to request the source segment timing.
126
124
  if self.start == 0.0 and self.end == 0.0:
127
125
  self.start = self.original_segment.start
128
126
  self.end = self.original_segment.end
@@ -40,8 +40,7 @@ class LocalDubbingPipeline:
40
40
  tts_backend: SpeechBackend | None = None,
41
41
  **kwargs: Any,
42
42
  ):
43
- # ``DubbingConfig`` consolidates the knobs that used to be constructor
44
- # kwargs. Either ``config=`` or the flat kwargs are accepted (not both).
43
+ # Either ``config=`` or flat configuration fields are accepted, not both.
45
44
  self.config = DubbingConfig.from_args(config, **kwargs)
46
45
  # Injected speech backend (a SpeechBackend, e.g. a remote/out-of-process
47
46
  # synthesizer). When None, _init_tts lazily constructs the local
@@ -52,13 +52,11 @@ class FaceTrackingCrop(Operation):
52
52
  )
53
53
  face_index: int = Field(0, ge=0, description='Index of face to track when using ``face_selection="index"``.')
54
54
  padding: float = Field(0.3, ge=0, description="Extra space around face (0.3 = 30% padding on each side).")
55
- vertical_offset: float = Field(
56
- -0.1, description='Legacy vertical position offset used by ``framing_rule="offset"``.'
57
- )
55
+ vertical_offset: float = Field(-0.1, description='Vertical position offset used by ``framing_rule="offset"``.')
58
56
  framing_rule: Literal["offset", "center", "headroom", "thirds", "dynamic"] = Field(
59
57
  "offset",
60
58
  description=(
61
- 'Subject framing strategy. "offset": legacy ``vertical_offset`` behavior; '
59
+ 'Subject framing strategy. "offset": apply ``vertical_offset``; '
62
60
  '"center": keep face centered; "headroom": extra room above the face; '
63
61
  '"thirds": face near the upper-third line; "dynamic": currently same as "headroom".'
64
62
  ),
@@ -70,7 +68,7 @@ class FaceTrackingCrop(Operation):
70
68
  "last_position",
71
69
  description=(
72
70
  'Behavior when no face detected. "center" and "full_frame" both center the crop '
73
- '("full_frame" kept for plan compatibility); "last_position" holds the last tracked crop.'
71
+ 'while "last_position" holds the last tracked crop.'
74
72
  ),
75
73
  )
76
74
  detection_interval: int = Field(3, ge=1, description="Frames between face detections.")
@@ -156,7 +154,7 @@ class FaceTrackingCrop(Operation):
156
154
  positions.append((x, y))
157
155
  elif self.fallback == "last_position":
158
156
  positions.append(last)
159
- else: # "center" / "full_frame" (the latter kept for plan compat)
157
+ else: # "center" / "full_frame"
160
158
  positions.append(default)
161
159
  return positions
162
160
 
@@ -83,7 +83,7 @@ def _attach_confidence_by_overlap(
83
83
  """Stamp Whisper confidence (avg_logprob, no_speech_prob, compression_ratio)
84
84
  onto ``target_segments`` from the ``source_segments`` they overlap most with.
85
85
 
86
- Used to re-attach per-segment confidence after diarization rebuilds segments
86
+ Re-attaches per-segment confidence after diarization rebuilds segments
87
87
  from words and drops the original Whisper-segment metadata. Whisper's
88
88
  confidence is window-level, not phoneme-level, so overlap-by-time is the
89
89
  right granularity — re-deriving per-word and re-aggregating wouldn't be
@@ -114,7 +114,8 @@ class AudioToText(ManagedPredictor):
114
114
  runs before Whisper to gate language detection on a 30s window built from
115
115
  voiced regions only — fixes Whisper's tendency to lock onto the wrong
116
116
  language when the file opens with silence, music, or non-vocal credits.
117
- Disable with ``enable_vad=False`` to reproduce pre-0.27 behaviour.
117
+ Set ``enable_vad=False`` to detect language from the leading audio without
118
+ voice-activity gating.
118
119
 
119
120
  Three Whisper decoder kwargs are surfaced for anti-hallucination tuning:
120
121
 
@@ -1,9 +1,3 @@
1
- """Temporal understanding for video analysis.
2
-
3
- Provides ML-based scene detection (TransNetV2). Action recognition was
4
- removed in 0.29.0 -- it was never wired into ``VideoAnalyzer``.
5
- """
6
-
7
1
  from __future__ import annotations
8
2
 
9
3
  from pathlib import Path
@@ -101,7 +95,6 @@ class SemanticSceneDetector(ManagedPredictor):
101
95
  if len(video.frames) == 1:
102
96
  return [SceneBoundary(start=0.0, end=video.total_seconds, start_frame=0, end_frame=1)]
103
97
 
104
- # Save video to temp file for TransNetV2 processing
105
98
  with tempfile.NamedTemporaryFile(suffix=".mp4", delete=True) as tmp:
106
99
  video.save(tmp.name)
107
100
  return self.detect_streaming(tmp.name)
@@ -120,7 +113,6 @@ class SemanticSceneDetector(ManagedPredictor):
120
113
  """
121
114
  self._init_local()
122
115
 
123
- # Use TransNetV2's detect_scenes which handles everything internally
124
116
  raw_scenes = self._model.detect_scenes(str(path), threshold=self.threshold)
125
117
 
126
118
  # Convert to SceneBoundary objects
@@ -302,18 +302,6 @@ class Audio:
302
302
 
303
303
  return cls(data, metadata)
304
304
 
305
- @classmethod
306
- def from_file(cls, file_path: str | Path) -> Audio:
307
- """Deprecated: Use from_path() instead."""
308
- import warnings
309
-
310
- warnings.warn(
311
- "Audio.from_file() is deprecated, use Audio.from_path() instead",
312
- DeprecationWarning,
313
- stacklevel=2,
314
- )
315
- return cls.from_path(file_path)
316
-
317
305
  @classmethod
318
306
  def silence(
319
307
  cls,
@@ -1,11 +1,3 @@
1
- """Pure helpers for video dimension math.
2
-
3
- Centralises the libx264+yuv420p even-dimension constraint and the
4
- two "round to even" calculations that previously lived (with subtly
5
- different semantics) in ``base/video.py``, ``ai/transforms.py``, and
6
- ``editing/transforms.py``.
7
- """
8
-
9
1
  from __future__ import annotations
10
2
 
11
3
 
@@ -50,8 +50,7 @@ def probe(path: str | Path, *, extra_args: Sequence[str] | None = None) -> dict[
50
50
  Args:
51
51
  path: Path to the media file.
52
52
  extra_args: Optional extra ffprobe flags inserted before ``-print_format``.
53
- Defaults to ``("-show_streams", "-show_format")`` when omitted,
54
- which mirrors the historical "everything" probe used by Audio.
53
+ Defaults to ``("-show_streams", "-show_format")`` when omitted.
55
54
 
56
55
  Returns:
57
56
  The decoded ffprobe JSON payload.
@@ -646,8 +646,7 @@ class _AnchoredOverlay(Effect):
646
646
  """Shared base for anchored RGBA overlays (:class:`TextOverlay`, :class:`ImageOverlay`).
647
647
 
648
648
  Owns anchored placement, off-frame clipping, and alpha blending in one
649
- ``_blend_params`` source of truth (consolidated when the eager/streaming
650
- parity-hole class of bug was fixed in 0.34.1). Subclasses declare their own
649
+ ``_blend_params`` source of truth. Subclasses declare their own
651
650
  ``position``/``anchor`` field defaults and implement
652
651
  :meth:`_overlay_for_frame` to produce the RGBA bitmap; everything
653
652
  downstream is shared. It declares no ``op`` ``Literal``, so it is an
@@ -712,9 +711,7 @@ class _AnchoredOverlay(Effect):
712
711
  ) -> tuple[np.ndarray, np.ndarray, tuple[int, int, int, int]] | None:
713
712
  """Placement + blend inputs for the streaming path.
714
713
 
715
- Single source of truth for placement and blending (consolidated when the
716
- eager/stream parity-hole class of bug was fixed in 0.34.1). Returns
717
- ``None`` when the overlay lands fully off-frame (the effect is a no-op).
714
+ Returns ``None`` when the overlay lands fully off-frame.
718
715
  """
719
716
  overlay = self._overlay_for_frame(frame_w, frame_h)
720
717
  oh, ow = overlay.shape[:2]
@@ -265,7 +265,7 @@ class TranscriptionOverlay(Effect):
265
265
  font_px = self.font_size if self.font_size is not None else max(1, round(self.font_scale * height))
266
266
  # libass interprets Fontsize as the GDI cell height (ascender +
267
267
  # descender) while PIL sizes the em square; scale by the font's
268
- # cell/em ratio so font_scale keeps its historical apparent size
268
+ # cell/em ratio so font_scale has the same apparent size in both paths
269
269
  # (1.5x divergence for a tall display font like Anton without this).
270
270
  metrics_font = load_font(self.font_filename or self.font, 100)
271
271
  if isinstance(metrics_font, ImageFont.FreeTypeFont):
@@ -153,7 +153,7 @@ def _resolve_source_context(context: dict[str, Any] | None, source: str) -> dict
153
153
  ``source`` is absent the key is dropped so the consuming op raises its own
154
154
  clear "requires ..." error (or surfaces as ``CONTEXT_SOURCE_MISSING`` in
155
155
  :meth:`VideoEdit.check`). Any non-dict value is a broadcast value shared by
156
- every segment and passes through unchanged (the pre-0.43 behavior).
156
+ every segment and passes through unchanged.
157
157
  """
158
158
  if not context:
159
159
  return context
@@ -184,7 +184,7 @@ def _segment_context(
184
184
  1. **Per-source resolution** (:func:`_resolve_source_context`): a context
185
185
  value may be a per-source ``dict`` keyed by ``str(segment.source)``;
186
186
  it collapses to this segment's source. A bare value broadcasts to all
187
- segments (the pre-0.43 behavior). This lets a multi-clip plan carry
187
+ segments. This lets a multi-clip plan carry
188
188
  ``{"transcription": {"a.mp4": tx_a, "b.mp4": tx_b}}`` and feed each
189
189
  segment its OWN transcription.
190
190
  2. **Re-basing**: a cut segment is decoded 0-based -- its first frame is
@@ -293,9 +293,8 @@ def _segment_end_exceeds_source(index: int, seg: SegmentConfig, meta: VideoMetad
293
293
  def _segment_bounds_errors(index: int, seg: SegmentConfig, meta: VideoMetadata) -> list[_LocatedError]:
294
294
  """Every numeric-bound failure of a segment's ``start``/``end``, in order.
295
295
 
296
- These checks moved off the (now permissive) ``SegmentConfig`` model so a
297
- bad range becomes a collectable, repairable :class:`PlanError` instead of a
298
- hard ``from_dict`` failure. Order is the raise order for ``validate``:
296
+ A bad range becomes a collectable, repairable :class:`PlanError`. Order is
297
+ the raise order for ``validate``:
299
298
  negative ``start``, negative ``end``, ``end <= start``, then ``end`` past
300
299
  the source. A segment with any of these cannot be cut, so the caller skips
301
300
  its op chain.
@@ -331,11 +330,10 @@ def _segment_bounds_errors(index: int, seg: SegmentConfig, meta: VideoMetadata)
331
330
  def _window_errors(op: Operation, duration: float, location: str) -> list[_LocatedError]:
332
331
  """Every bound failure of an :attr:`Effect.window`, in raise order.
333
332
 
334
- Subsumes the old window-vs-duration check and the negative/order checks that
335
- moved off the (now permissive) ``TimeRange`` model: negative ``start``,
336
- negative ``stop``, ``stop < start``, ``start`` past duration, ``stop`` past
337
- duration. A ``stop`` clamped to ``duration`` by ``clamp_windows`` no longer
338
- overruns, so the final check stays silent for it (matching ``run_to_file()``).
333
+ Checks negative ``start``, negative ``stop``, ``stop < start``, ``start``
334
+ past duration, and ``stop`` past duration. A ``stop`` clamped to ``duration``
335
+ by ``clamp_windows`` no longer overruns, so the final check stays silent for
336
+ it (matching ``run_to_file()``).
339
337
  """
340
338
  if not isinstance(op, Effect) or op.window is None:
341
339
  return []
@@ -1,6 +1,6 @@
1
1
  """videopython MCP server: the auto-edit primitives exposed as MCP tools.
2
2
 
3
- Run with the ``videopython-mcp`` console script (needs the ``[ai,mcp]`` extras).
3
+ Run with the ``videopython-mcp`` console script (needs the ``[mcp]`` extra).
4
4
  The MCP client's own model is the planner; this server only exposes the steps
5
5
  (analyze -> catalog -> validate/repair/run over an EditPlan by scene id).
6
6
  """
@@ -0,0 +1,83 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from pydantic import BaseModel, ConfigDict
6
+
7
+
8
+ class SchemaIssue(BaseModel):
9
+ """One Pydantic schema-validation issue."""
10
+
11
+ model_config = ConfigDict(extra="forbid")
12
+
13
+ loc: list[str | int]
14
+ msg: str
15
+ type: str
16
+
17
+
18
+ class McpError(BaseModel):
19
+ """Structured error returned by an editing tool."""
20
+
21
+ model_config = ConfigDict(extra="forbid")
22
+
23
+ code: str
24
+ message: str
25
+ location: str | None = None
26
+ op: str | None = None
27
+ field: str | None = None
28
+ value: float | list[str] | None = None
29
+ limit: float | None = None
30
+ detail: str | list[SchemaIssue] | None = None
31
+
32
+
33
+ class McpRepair(BaseModel):
34
+ """One change made while repairing an edit plan."""
35
+
36
+ model_config = ConfigDict(extra="forbid")
37
+
38
+ location: str
39
+ field: str
40
+ old: float | str | None
41
+ new: float | str | None
42
+ code: str
43
+
44
+
45
+ class AnalyzeVideoResult(BaseModel):
46
+ """Summary returned after analysis is cached."""
47
+
48
+ model_config = ConfigDict(extra="forbid")
49
+
50
+ source: str
51
+ duration: float | None
52
+ fps: float | None
53
+ width: int | None
54
+ height: int | None
55
+ scenes: int
56
+
57
+
58
+ class ValidateEditResult(BaseModel):
59
+ """Result of edit-plan validation."""
60
+
61
+ model_config = ConfigDict(extra="forbid")
62
+
63
+ valid: bool
64
+ errors: list[McpError]
65
+
66
+
67
+ class RepairEditResult(BaseModel):
68
+ """Concrete repaired edit and its change records."""
69
+
70
+ model_config = ConfigDict(extra="forbid")
71
+
72
+ edit: dict[str, Any] | None
73
+ repairs: list[McpRepair]
74
+ errors: list[McpError]
75
+
76
+
77
+ class RunEditResult(BaseModel):
78
+ """Rendered output path or the errors that prevented rendering."""
79
+
80
+ model_config = ConfigDict(extra="forbid")
81
+
82
+ output_path: str | None
83
+ errors: list[McpError]
@@ -12,6 +12,7 @@ from __future__ import annotations
12
12
  import json
13
13
  import sys
14
14
  from contextlib import redirect_stdout
15
+ from importlib import metadata as importlib_metadata
15
16
  from pathlib import Path
16
17
  from typing import TYPE_CHECKING, Any, Literal
17
18
 
@@ -24,12 +25,23 @@ from videopython.ai.auto_edit import build_catalog as _build_scene_catalog
24
25
  from videopython.ai.keyframe import keyframe_to_png_b64
25
26
  from videopython.editing import VideoEdit
26
27
 
28
+ from ._models import (
29
+ AnalyzeVideoResult,
30
+ McpError,
31
+ McpRepair,
32
+ RepairEditResult,
33
+ RunEditResult,
34
+ SchemaIssue,
35
+ ValidateEditResult,
36
+ )
37
+
27
38
  if TYPE_CHECKING:
28
39
  from videopython.ai.auto_edit import CatalogBundle
29
40
  from videopython.ai.video_analysis import VideoAnalysis, VideoAnalyzer
30
41
  from videopython.base import PlanError, PlanRepair
31
42
 
32
43
  mcp = FastMCP("videopython")
44
+ mcp._mcp_server.version = importlib_metadata.version("videopython")
33
45
 
34
46
  # Session state for one stdio client (one process per client).
35
47
  _analyses: dict[str, VideoAnalysis] = {}
@@ -40,12 +52,13 @@ _MAX_INLINE_KEYFRAMES = 12 # cap inlined keyframes in build_catalog; pull the r
40
52
 
41
53
 
42
54
  @mcp.tool()
43
- def analyze_video(path: str, profile: Literal["full", "editing"] = "full") -> dict[str, Any]:
55
+ def analyze_video(path: str, profile: Literal["full", "editing"] = "editing") -> AnalyzeVideoResult:
44
56
  """Analyze a source video (scenes, transcript, captions) and cache it for build_catalog.
45
57
 
46
- ``profile="editing"`` skips audio classification (faster on long sources); the
47
- catalog (captions + transcript + face flag) is unaffected. Returns a short
48
- summary; call this once per source, then build_catalog.
58
+ The default ``profile="editing"`` skips audio classification; the catalog
59
+ (captions + transcript + face flag) is unaffected. ``profile="full"`` adds
60
+ audio classification. Returns a short summary; call this once per source,
61
+ then build_catalog.
49
62
  """
50
63
  # Heavy analyzer deps (e.g. transnetv2-pytorch) bare-print to stdout, which here is
51
64
  # the stdio JSON-RPC channel; send that to stderr so the transport stays clean.
@@ -53,14 +66,14 @@ def analyze_video(path: str, profile: Literal["full", "editing"] = "full") -> di
53
66
  analysis = _get_analyzer(profile).analyze_path(path)
54
67
  _analyses[str(Path(path))] = analysis
55
68
  src = analysis.source
56
- return {
57
- "source": str(Path(path)),
58
- "duration": src.duration,
59
- "fps": src.fps,
60
- "width": src.width,
61
- "height": src.height,
62
- "scenes": len(analysis.scenes.samples) if analysis.scenes else 0,
63
- }
69
+ return AnalyzeVideoResult(
70
+ source=str(Path(path)),
71
+ duration=src.duration,
72
+ fps=src.fps,
73
+ width=src.width,
74
+ height=src.height,
75
+ scenes=len(analysis.scenes.samples) if analysis.scenes else 0,
76
+ )
64
77
 
65
78
 
66
79
  @mcp.tool(structured_output=False)
@@ -110,7 +123,7 @@ def scene_keyframes(scene_ids: list[str]) -> list[TextContent | ImageContent]:
110
123
 
111
124
 
112
125
  @mcp.tool()
113
- def validate_edit(plan: dict[str, Any]) -> dict[str, Any]:
126
+ def validate_edit(plan: dict[str, Any]) -> ValidateEditResult:
114
127
  """Validate an edit plan (an EditPlan referencing catalog scene ids).
115
128
 
116
129
  Returns every problem at once as structured errors; ``valid`` is True when
@@ -119,13 +132,13 @@ def validate_edit(plan: dict[str, Any]) -> dict[str, Any]:
119
132
  """
120
133
  edit, errors = _resolve(plan)
121
134
  if edit is None:
122
- return {"valid": False, "errors": errors}
135
+ return ValidateEditResult(valid=False, errors=errors)
123
136
  errors = [_error_dict(e) for e in edit.check(_source_metadata(edit), context=_context())]
124
- return {"valid": not errors, "errors": errors}
137
+ return ValidateEditResult(valid=not errors, errors=errors)
125
138
 
126
139
 
127
140
  @mcp.tool()
128
- def repair_edit(plan: dict[str, Any]) -> dict[str, Any]:
141
+ def repair_edit(plan: dict[str, Any]) -> RepairEditResult:
129
142
  """Repair the mechanical issues in an edit plan and normalize segment dimensions.
130
143
 
131
144
  Returns the resolved+repaired VideoEdit and a changelog, for inspection;
@@ -136,16 +149,20 @@ def repair_edit(plan: dict[str, Any]) -> dict[str, Any]:
136
149
  """
137
150
  edit, errors = _resolve(plan)
138
151
  if edit is None:
139
- return {"edit": None, "repairs": [], "errors": errors}
152
+ return RepairEditResult(edit=None, repairs=[], errors=errors)
140
153
  metadata = _source_metadata(edit)
141
154
  context = _context()
142
155
  edit, repairs = edit.repair(metadata, context=context, clamp_segment_end=True)
143
156
  edit, dim_repairs = edit.normalize_dimensions(metadata, "largest", context=context)
144
- return {"edit": edit.to_dict(), "repairs": [_repair_dict(r) for r in (*repairs, *dim_repairs)], "errors": []}
157
+ return RepairEditResult(
158
+ edit=edit.to_dict(),
159
+ repairs=[_repair_dict(r) for r in (*repairs, *dim_repairs)],
160
+ errors=[],
161
+ )
145
162
 
146
163
 
147
164
  @mcp.tool()
148
- def run_edit(plan: dict[str, Any], output_path: str) -> dict[str, Any]:
165
+ def run_edit(plan: dict[str, Any], output_path: str) -> RunEditResult:
149
166
  """Render an edit plan to an MP4 file (the path suffix is normalized to .mp4).
150
167
 
151
168
  Resolves scene ids, repairs + normalizes, validates, then renders. If the
@@ -154,16 +171,16 @@ def run_edit(plan: dict[str, Any], output_path: str) -> dict[str, Any]:
154
171
  """
155
172
  edit, errors = _resolve(plan)
156
173
  if edit is None:
157
- return {"output_path": None, "errors": errors}
174
+ return RunEditResult(output_path=None, errors=errors)
158
175
  metadata = _source_metadata(edit)
159
176
  context = _context()
160
177
  edit, _ = edit.repair(metadata, context=context, clamp_segment_end=True)
161
178
  edit, _ = edit.normalize_dimensions(metadata, "largest", context=context)
162
179
  errors = [_error_dict(e) for e in edit.check(metadata, context=context)]
163
180
  if errors:
164
- return {"output_path": None, "errors": errors}
181
+ return RunEditResult(output_path=None, errors=errors)
165
182
  out = edit.run_to_file(output_path, context=context)
166
- return {"output_path": str(out), "errors": []}
183
+ return RunEditResult(output_path=str(out), errors=[])
167
184
 
168
185
 
169
186
  @mcp.resource("schema://videopython/edit-plan", mime_type="application/json")
@@ -174,9 +191,11 @@ def edit_plan_schema() -> str:
174
191
 
175
192
  def _get_analyzer(profile: str = "full") -> VideoAnalyzer:
176
193
  if profile not in _analyzers:
177
- from videopython.ai.video_analysis import VideoAnalysisConfig, VideoAnalyzer
194
+ from videopython.ai.video_analysis import AUDIO_TO_TEXT, VideoAnalysisConfig, VideoAnalyzer
178
195
 
179
- _analyzers[profile] = VideoAnalyzer(config=VideoAnalysisConfig.for_profile(profile))
196
+ config = VideoAnalysisConfig.for_profile(profile)
197
+ config.analyzer_params[AUDIO_TO_TEXT] = {"enable_vad": False}
198
+ _analyzers[profile] = VideoAnalyzer(config=config)
180
199
  return _analyzers[profile]
181
200
 
182
201
 
@@ -197,17 +216,17 @@ def _keyframe_blocks(scene_ids: list[str]) -> list[TextContent | ImageContent]:
197
216
  return blocks
198
217
 
199
218
 
200
- def _resolve(plan: dict[str, Any]) -> tuple[VideoEdit | None, list[dict[str, Any]]]:
219
+ def _resolve(plan: dict[str, Any]) -> tuple[VideoEdit | None, list[McpError]]:
201
220
  """Resolve a by-id plan, or return (None, structured errors) for the agent's plan mistakes."""
202
221
  if _bundle is None:
203
222
  raise ValueError("No catalog cached; call build_catalog first.")
204
223
  try:
205
224
  edit = resolve_plan(EditPlan.model_validate(plan), _bundle.catalog)
206
225
  except ValidationError as exc:
207
- detail = [{"loc": list(e["loc"]), "msg": e["msg"], "type": e["type"]} for e in exc.errors()]
208
- return None, [{"code": "schema_invalid", "detail": detail, "message": str(exc)}]
226
+ detail = [SchemaIssue(loc=list(e["loc"]), msg=e["msg"], type=e["type"]) for e in exc.errors()]
227
+ return None, [McpError(code="schema_invalid", detail=detail, message=str(exc))]
209
228
  except UnknownSceneIdsError as exc:
210
- return None, [{"code": "unknown_scene_ids", "value": sorted(set(exc.ids)), "message": str(exc)}]
229
+ return None, [McpError(code="unknown_scene_ids", value=sorted(set(exc.ids)), message=str(exc))]
211
230
  return edit, []
212
231
 
213
232
 
@@ -226,27 +245,27 @@ def _context() -> dict[str, Any] | None:
226
245
  return {"transcription": transcriptions} if transcriptions else None
227
246
 
228
247
 
229
- def _error_dict(error: PlanError) -> dict[str, Any]:
230
- return {
231
- "code": error.code.value,
232
- "location": error.location,
233
- "op": error.op,
234
- "field": error.field,
235
- "value": error.value,
236
- "limit": error.limit,
237
- "detail": error.detail,
238
- "message": error.to_prompt_line(),
239
- }
240
-
241
-
242
- def _repair_dict(repair: PlanRepair) -> dict[str, Any]:
243
- return {
244
- "location": repair.location,
245
- "field": repair.field,
246
- "old": repair.old,
247
- "new": repair.new,
248
- "code": repair.code.value,
249
- }
248
+ def _error_dict(error: PlanError) -> McpError:
249
+ return McpError(
250
+ code=error.code.value,
251
+ location=error.location,
252
+ op=error.op,
253
+ field=error.field,
254
+ value=error.value,
255
+ limit=error.limit,
256
+ detail=error.detail,
257
+ message=error.to_prompt_line(),
258
+ )
259
+
260
+
261
+ def _repair_dict(repair: PlanRepair) -> McpRepair:
262
+ return McpRepair(
263
+ location=repair.location,
264
+ field=repair.field,
265
+ old=repair.old,
266
+ new=repair.new,
267
+ code=repair.code.value,
268
+ )
250
269
 
251
270
 
252
271
  def main() -> None:
File without changes