videopython 0.58.0__tar.gz → 0.60.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.
- videopython-0.60.0/PKG-INFO +167 -0
- videopython-0.60.0/README.md +110 -0
- {videopython-0.58.0 → videopython-0.60.0}/pyproject.toml +1 -1
- videopython-0.60.0/src/videopython/_exceptions.py +63 -0
- {videopython-0.58.0/src/videopython/base → videopython-0.60.0/src/videopython}/_ffmpeg.py +49 -18
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/remux.py +2 -2
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/transforms.py +11 -16
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/video_analysis/__init__.py +2 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/video_analysis/analyzer.py +63 -2
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/video_analysis/models.py +30 -8
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/video_analysis/source_metadata.py +3 -5
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/audio/__init__.py +3 -1
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/audio/audio.py +3 -2
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/__init__.py +10 -18
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/_video_io.py +14 -17
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/video.py +13 -4
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/__init__.py +6 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/audio_ops.py +2 -2
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/effects.py +2 -2
- videopython-0.60.0/src/videopython/editing/errors.py +98 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/operation.py +2 -3
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/streaming.py +2 -2
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/transcription_overlay.py +1 -1
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/transforms.py +1 -1
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/video_edit.py +41 -29
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/mcp/_models.py +3 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/mcp/server.py +4 -3
- videopython-0.58.0/PKG-INFO +0 -198
- videopython-0.58.0/README.md +0 -141
- videopython-0.58.0/src/videopython/base/exceptions.py +0 -219
- {videopython-0.58.0 → videopython-0.60.0}/.gitignore +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/LICENSE +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/_device.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/_ollama.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/_optional.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/_predictor.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/_revisions.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/auto_edit/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/auto_edit/backend.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/auto_edit/catalog.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/auto_edit/editor.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/auto_edit/local.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/auto_edit/models.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/auto_edit/resolve.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/_tts_backend.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/audio_ops.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/config.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/dubber.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/models.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/pipeline.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/quality.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/separation.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/timing.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/translation.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/dubbing/voice_sample.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/effects.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/errors.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/generation/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/generation/audio.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/generation/image.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/generation/video.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/keyframe.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/ops.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/_detector.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/audio.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/classification.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/faces.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/image.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/objects.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/understanding/temporal.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/video_analysis/detectors.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/ai/video_analysis/sampling.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/audio/analysis.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/_dimensions.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/description.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/draw_detections.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/Anton-OFL.txt +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/Anton-Regular.ttf +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/BebasNeue-OFL.txt +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/BebasNeue-Regular.ttf +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/DejaVuSans.ttf +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/LICENSE_DEJAVU +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/Lato-Bold.ttf +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/Lato-OFL.txt +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/Poppins-Bold.ttf +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/Poppins-OFL.txt +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/fonts/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/base/transcription.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/_ass.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/_easing.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/editing/_schema.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/mcp/__init__.py +0 -0
- {videopython-0.58.0 → videopython-0.60.0}/src/videopython/py.typed +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: videopython
|
|
3
|
+
Version: 0.60.0
|
|
4
|
+
Summary: LLM-friendly Python video editing with JSON plans, local AI, and MCP tools.
|
|
5
|
+
Project-URL: Homepage, https://videopython.com
|
|
6
|
+
Project-URL: Repository, https://github.com/bartwojtowicz/videopython/
|
|
7
|
+
Project-URL: Documentation, https://videopython.com
|
|
8
|
+
Author-email: Bartosz Wójtowicz <bartoszwojtowicz@outlook.com>, Bartosz Rudnikowicz <bartoszrudnikowicz840@gmail.com>, Piotr Pukisz <piotr.pukisz@gmail.com>
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,ai-agents,editing,ffmpeg,generation,llm,mcp,movie,ollama,opencv,python,shorts,video,video-editing,videopython
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Python: <3.15,>=3.11
|
|
20
|
+
Requires-Dist: numpy>=1.25.2
|
|
21
|
+
Requires-Dist: opencv-python-headless>=4.9.0.80
|
|
22
|
+
Requires-Dist: pillow>=12.1.1
|
|
23
|
+
Requires-Dist: pydantic>=2.8.0
|
|
24
|
+
Requires-Dist: resvg-py>=0.3.2
|
|
25
|
+
Requires-Dist: soxr>=0.5
|
|
26
|
+
Requires-Dist: tqdm>=4.66.3
|
|
27
|
+
Provides-Extra: ai
|
|
28
|
+
Requires-Dist: accelerate>=0.29.2; extra == 'ai'
|
|
29
|
+
Requires-Dist: demucs>=4.0.0; extra == 'ai'
|
|
30
|
+
Requires-Dist: diffusers>=0.35.0; extra == 'ai'
|
|
31
|
+
Requires-Dist: ftfy>=6.1; extra == 'ai'
|
|
32
|
+
Requires-Dist: imagehash>=4.3; extra == 'ai'
|
|
33
|
+
Requires-Dist: numba>=0.62; extra == 'ai'
|
|
34
|
+
Requires-Dist: ollama>=0.5.0; extra == 'ai'
|
|
35
|
+
Requires-Dist: openai-whisper>=20240930; extra == 'ai'
|
|
36
|
+
Requires-Dist: pyannote-audio>=4.0.0; extra == 'ai'
|
|
37
|
+
Requires-Dist: pyloudnorm>=0.1.1; extra == 'ai'
|
|
38
|
+
Requires-Dist: silero-vad>=5.1; extra == 'ai'
|
|
39
|
+
Requires-Dist: torch>=2.8.0; extra == 'ai'
|
|
40
|
+
Requires-Dist: torchaudio>=2.8.0; extra == 'ai'
|
|
41
|
+
Requires-Dist: torchcodec>=0.7.0; extra == 'ai'
|
|
42
|
+
Requires-Dist: torchvision>=0.23.0; extra == 'ai'
|
|
43
|
+
Requires-Dist: transformers>=5.2.0; extra == 'ai'
|
|
44
|
+
Requires-Dist: transnetv2-pytorch>=1.0.5; extra == 'ai'
|
|
45
|
+
Requires-Dist: videopython-chatterbox>=0.1.7.post1; extra == 'ai'
|
|
46
|
+
Provides-Extra: mcp
|
|
47
|
+
Requires-Dist: imagehash>=4.3; extra == 'mcp'
|
|
48
|
+
Requires-Dist: mcp<2,>=1.27; extra == 'mcp'
|
|
49
|
+
Requires-Dist: numba>=0.62; extra == 'mcp'
|
|
50
|
+
Requires-Dist: ollama>=0.5.0; extra == 'mcp'
|
|
51
|
+
Requires-Dist: openai-whisper>=20240930; extra == 'mcp'
|
|
52
|
+
Requires-Dist: torch>=2.8.0; extra == 'mcp'
|
|
53
|
+
Requires-Dist: torchvision>=0.23.0; extra == 'mcp'
|
|
54
|
+
Requires-Dist: transformers>=5.2.0; extra == 'mcp'
|
|
55
|
+
Requires-Dist: transnetv2-pytorch>=1.0.5; extra == 'mcp'
|
|
56
|
+
Description-Content-Type: text/markdown
|
|
57
|
+
|
|
58
|
+
# videopython
|
|
59
|
+
|
|
60
|
+
[](https://pypi.org/project/videopython/)
|
|
61
|
+
[](https://pypi.org/project/videopython/)
|
|
62
|
+
[](LICENSE)
|
|
63
|
+
[](https://github.com/BartWojtowicz/videopython/actions/workflows/ci.yml)
|
|
64
|
+
|
|
65
|
+
Structured, local-first video editing for Python and AI agents.
|
|
66
|
+
|
|
67
|
+
Videopython represents an edit as a validated Python model or JSON plan. Whether the
|
|
68
|
+
plan comes from your code, an LLM, or an MCP client, it renders through the same
|
|
69
|
+
bounded-memory streaming engine.
|
|
70
|
+
|
|
71
|
+
[Documentation](https://videopython.com) ·
|
|
72
|
+
[First edit](https://videopython.com/tutorials/first-edit/) ·
|
|
73
|
+
[API reference](https://videopython.com/reference/) ·
|
|
74
|
+
[Roadmap](ROADMAP.md)
|
|
75
|
+
|
|
76
|
+
## Why videopython?
|
|
77
|
+
|
|
78
|
+
- **Structured edits** — segments and operations are Pydantic models with a generated
|
|
79
|
+
JSON Schema.
|
|
80
|
+
- **Predictable rendering** — validate dimensions, timing, and operation constraints
|
|
81
|
+
before decoding frames.
|
|
82
|
+
- **Bounded memory** — stream decode, effects, and encode without loading the full
|
|
83
|
+
source into memory.
|
|
84
|
+
- **Local AI** — add transcription, scene understanding, generation, dubbing, and
|
|
85
|
+
automatic editing without cloud inference APIs.
|
|
86
|
+
- **Agent-ready tools** — expose analysis, planning, validation, and rendering through
|
|
87
|
+
the included MCP server.
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
Install [FFmpeg](https://ffmpeg.org/download.html), then choose the package extras you
|
|
92
|
+
need:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install videopython # core video and audio editing
|
|
96
|
+
pip install "videopython[ai]" # all local AI features
|
|
97
|
+
pip install "videopython[mcp]" # MCP and its focused analysis stack
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Videopython supports Python `>=3.11, <3.15`. The `ai` and `mcp` extras are independent;
|
|
101
|
+
install `videopython[ai,mcp]` if you need both. See the
|
|
102
|
+
[installation guide](https://videopython.com/install/) for FFmpeg features, model
|
|
103
|
+
downloads, Ollama setup, and hardware requirements.
|
|
104
|
+
|
|
105
|
+
## Quick start
|
|
106
|
+
|
|
107
|
+
Describe the edit, validate it without loading frames, then render it:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from videopython.editing import VideoEdit
|
|
111
|
+
|
|
112
|
+
edit = VideoEdit.from_dict({
|
|
113
|
+
"segments": [
|
|
114
|
+
{
|
|
115
|
+
"source": "input.mp4",
|
|
116
|
+
"start": 10.0,
|
|
117
|
+
"end": 20.0,
|
|
118
|
+
"operations": [
|
|
119
|
+
{"op": "resize", "width": 1080, "height": 1920},
|
|
120
|
+
{"op": "color_adjust", "saturation": 1.15, "contrast": 1.05},
|
|
121
|
+
{"op": "fade", "mode": "in", "duration": 0.5},
|
|
122
|
+
],
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
edit.validate()
|
|
128
|
+
edit.run_to_file("output.mp4")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`run_to_file()` streams the source through FFmpeg and the operation pipeline, so memory
|
|
132
|
+
use stays bounded for long videos. Continue with
|
|
133
|
+
[Your first edit](https://videopython.com/tutorials/first-edit/).
|
|
134
|
+
|
|
135
|
+
## What you can build
|
|
136
|
+
|
|
137
|
+
| Area | Capabilities | Start here |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| Editing | Cuts, transforms, effects, overlays, subtitles, audio, and multi-segment plans | [Editing guides](https://videopython.com/how-to/) |
|
|
140
|
+
| AI workflows | Transcription, detection, scene understanding, generation, dubbing, and automatic editing | [Local AI](https://videopython.com/explanation/local-ai/) |
|
|
141
|
+
| LLM integrations | Generated schemas, structured validation, repair, and dimension normalization | [LLM plan guide](https://videopython.com/how-to/llm-plans/) |
|
|
142
|
+
| MCP agents | Local tools for media analysis, planning, validation, and rendering | [MCP guide](https://videopython.com/how-to/mcp-server/) |
|
|
143
|
+
|
|
144
|
+
Core editing does not install PyTorch or other model runtimes. AI dependencies load only
|
|
145
|
+
when you use an AI feature.
|
|
146
|
+
|
|
147
|
+
## Documentation
|
|
148
|
+
|
|
149
|
+
The documentation follows [Diataxis](https://diataxis.fr/):
|
|
150
|
+
|
|
151
|
+
- [Tutorials](https://videopython.com/tutorials/) teach the library through complete
|
|
152
|
+
examples.
|
|
153
|
+
- [How-to guides](https://videopython.com/how-to/) cover specific editing and AI tasks.
|
|
154
|
+
- [Reference](https://videopython.com/reference/) documents the API, operations, and
|
|
155
|
+
JSON wire format.
|
|
156
|
+
- [Explanation](https://videopython.com/explanation/) covers the streaming engine,
|
|
157
|
+
plan lifecycle, architecture, and LLM-first design.
|
|
158
|
+
|
|
159
|
+
## Project status
|
|
160
|
+
|
|
161
|
+
Videopython is pre-1.0, so public interfaces can still change. See the
|
|
162
|
+
[roadmap](ROADMAP.md) for the stability criteria and [release notes](RELEASE_NOTES.md)
|
|
163
|
+
for changes between versions. Report vulnerabilities through the [security
|
|
164
|
+
policy](SECURITY.md).
|
|
165
|
+
|
|
166
|
+
For local setup, tests, documentation builds, and releases, see
|
|
167
|
+
[DEVELOPMENT.md](DEVELOPMENT.md).
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# videopython
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/videopython/)
|
|
4
|
+
[](https://pypi.org/project/videopython/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/BartWojtowicz/videopython/actions/workflows/ci.yml)
|
|
7
|
+
|
|
8
|
+
Structured, local-first video editing for Python and AI agents.
|
|
9
|
+
|
|
10
|
+
Videopython represents an edit as a validated Python model or JSON plan. Whether the
|
|
11
|
+
plan comes from your code, an LLM, or an MCP client, it renders through the same
|
|
12
|
+
bounded-memory streaming engine.
|
|
13
|
+
|
|
14
|
+
[Documentation](https://videopython.com) ·
|
|
15
|
+
[First edit](https://videopython.com/tutorials/first-edit/) ·
|
|
16
|
+
[API reference](https://videopython.com/reference/) ·
|
|
17
|
+
[Roadmap](ROADMAP.md)
|
|
18
|
+
|
|
19
|
+
## Why videopython?
|
|
20
|
+
|
|
21
|
+
- **Structured edits** — segments and operations are Pydantic models with a generated
|
|
22
|
+
JSON Schema.
|
|
23
|
+
- **Predictable rendering** — validate dimensions, timing, and operation constraints
|
|
24
|
+
before decoding frames.
|
|
25
|
+
- **Bounded memory** — stream decode, effects, and encode without loading the full
|
|
26
|
+
source into memory.
|
|
27
|
+
- **Local AI** — add transcription, scene understanding, generation, dubbing, and
|
|
28
|
+
automatic editing without cloud inference APIs.
|
|
29
|
+
- **Agent-ready tools** — expose analysis, planning, validation, and rendering through
|
|
30
|
+
the included MCP server.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Install [FFmpeg](https://ffmpeg.org/download.html), then choose the package extras you
|
|
35
|
+
need:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install videopython # core video and audio editing
|
|
39
|
+
pip install "videopython[ai]" # all local AI features
|
|
40
|
+
pip install "videopython[mcp]" # MCP and its focused analysis stack
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Videopython supports Python `>=3.11, <3.15`. The `ai` and `mcp` extras are independent;
|
|
44
|
+
install `videopython[ai,mcp]` if you need both. See the
|
|
45
|
+
[installation guide](https://videopython.com/install/) for FFmpeg features, model
|
|
46
|
+
downloads, Ollama setup, and hardware requirements.
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
Describe the edit, validate it without loading frames, then render it:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from videopython.editing import VideoEdit
|
|
54
|
+
|
|
55
|
+
edit = VideoEdit.from_dict({
|
|
56
|
+
"segments": [
|
|
57
|
+
{
|
|
58
|
+
"source": "input.mp4",
|
|
59
|
+
"start": 10.0,
|
|
60
|
+
"end": 20.0,
|
|
61
|
+
"operations": [
|
|
62
|
+
{"op": "resize", "width": 1080, "height": 1920},
|
|
63
|
+
{"op": "color_adjust", "saturation": 1.15, "contrast": 1.05},
|
|
64
|
+
{"op": "fade", "mode": "in", "duration": 0.5},
|
|
65
|
+
],
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
edit.validate()
|
|
71
|
+
edit.run_to_file("output.mp4")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`run_to_file()` streams the source through FFmpeg and the operation pipeline, so memory
|
|
75
|
+
use stays bounded for long videos. Continue with
|
|
76
|
+
[Your first edit](https://videopython.com/tutorials/first-edit/).
|
|
77
|
+
|
|
78
|
+
## What you can build
|
|
79
|
+
|
|
80
|
+
| Area | Capabilities | Start here |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| Editing | Cuts, transforms, effects, overlays, subtitles, audio, and multi-segment plans | [Editing guides](https://videopython.com/how-to/) |
|
|
83
|
+
| AI workflows | Transcription, detection, scene understanding, generation, dubbing, and automatic editing | [Local AI](https://videopython.com/explanation/local-ai/) |
|
|
84
|
+
| LLM integrations | Generated schemas, structured validation, repair, and dimension normalization | [LLM plan guide](https://videopython.com/how-to/llm-plans/) |
|
|
85
|
+
| MCP agents | Local tools for media analysis, planning, validation, and rendering | [MCP guide](https://videopython.com/how-to/mcp-server/) |
|
|
86
|
+
|
|
87
|
+
Core editing does not install PyTorch or other model runtimes. AI dependencies load only
|
|
88
|
+
when you use an AI feature.
|
|
89
|
+
|
|
90
|
+
## Documentation
|
|
91
|
+
|
|
92
|
+
The documentation follows [Diataxis](https://diataxis.fr/):
|
|
93
|
+
|
|
94
|
+
- [Tutorials](https://videopython.com/tutorials/) teach the library through complete
|
|
95
|
+
examples.
|
|
96
|
+
- [How-to guides](https://videopython.com/how-to/) cover specific editing and AI tasks.
|
|
97
|
+
- [Reference](https://videopython.com/reference/) documents the API, operations, and
|
|
98
|
+
JSON wire format.
|
|
99
|
+
- [Explanation](https://videopython.com/explanation/) covers the streaming engine,
|
|
100
|
+
plan lifecycle, architecture, and LLM-first design.
|
|
101
|
+
|
|
102
|
+
## Project status
|
|
103
|
+
|
|
104
|
+
Videopython is pre-1.0, so public interfaces can still change. See the
|
|
105
|
+
[roadmap](ROADMAP.md) for the stability criteria and [release notes](RELEASE_NOTES.md)
|
|
106
|
+
for changes between versions. Report vulnerabilities through the [security
|
|
107
|
+
policy](SECURITY.md).
|
|
108
|
+
|
|
109
|
+
For local setup, tests, documentation builds, and releases, see
|
|
110
|
+
[DEVELOPMENT.md](DEVELOPMENT.md).
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Exception hierarchy shared by the package layers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class VideoPythonError(Exception):
|
|
7
|
+
"""Base exception for all videopython errors."""
|
|
8
|
+
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FFmpegError(VideoPythonError):
|
|
13
|
+
"""Base exception for ffmpeg/ffprobe subprocess failures."""
|
|
14
|
+
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FFmpegProbeError(FFmpegError):
|
|
19
|
+
"""Raised when an ffprobe invocation or its JSON output fails."""
|
|
20
|
+
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class FFmpegRunError(FFmpegError):
|
|
25
|
+
"""Raised when a blocking ffmpeg run returns a non-zero exit code."""
|
|
26
|
+
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class VideoError(VideoPythonError):
|
|
31
|
+
"""Base exception for video-related errors."""
|
|
32
|
+
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class VideoLoadError(VideoError):
|
|
37
|
+
"""Raised when there's an error loading a video file."""
|
|
38
|
+
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class VideoMetadataError(VideoError):
|
|
43
|
+
"""Raised when there's an error getting video metadata."""
|
|
44
|
+
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AudioError(VideoPythonError):
|
|
49
|
+
"""Base exception for audio-related errors."""
|
|
50
|
+
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class AudioLoadError(AudioError):
|
|
55
|
+
"""Raised when there's an error loading audio."""
|
|
56
|
+
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class TransformError(VideoPythonError):
|
|
61
|
+
"""Base exception for transformation errors."""
|
|
62
|
+
|
|
63
|
+
pass
|
|
@@ -11,11 +11,17 @@ from __future__ import annotations
|
|
|
11
11
|
|
|
12
12
|
import json
|
|
13
13
|
import subprocess
|
|
14
|
+
import tempfile
|
|
14
15
|
from contextlib import contextmanager
|
|
15
16
|
from pathlib import Path
|
|
16
|
-
from typing import Any, Iterator, Sequence
|
|
17
|
+
from typing import Any, BinaryIO, Iterator, Sequence, cast
|
|
17
18
|
|
|
18
|
-
from videopython.
|
|
19
|
+
from videopython._exceptions import FFmpegProbeError, FFmpegRunError
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _strict_decode_command(cmd: Sequence[str]) -> list[str]:
|
|
23
|
+
argv = list(cmd)
|
|
24
|
+
return [argv[0], "-hide_banner", "-loglevel", "error", "-xerror", *argv[1:]]
|
|
19
25
|
|
|
20
26
|
|
|
21
27
|
def run(cmd: Sequence[str], *, stdin: bytes | None = None) -> bytes:
|
|
@@ -86,13 +92,37 @@ def _terminate(proc: subprocess.Popen[bytes], *, timeout: float = 5) -> None:
|
|
|
86
92
|
proc.wait()
|
|
87
93
|
|
|
88
94
|
|
|
95
|
+
class _DecodeProcess:
|
|
96
|
+
"""FFmpeg decode process with diagnostics stored outside the pipe."""
|
|
97
|
+
|
|
98
|
+
def __init__(self, process: subprocess.Popen[bytes], errors: BinaryIO):
|
|
99
|
+
self._process = process
|
|
100
|
+
self._errors = errors
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def stdout(self) -> BinaryIO:
|
|
104
|
+
return cast(BinaryIO, self._process.stdout)
|
|
105
|
+
|
|
106
|
+
def communicate(self) -> tuple[bytes, None]:
|
|
107
|
+
stdout, _ = self._process.communicate()
|
|
108
|
+
return stdout, None
|
|
109
|
+
|
|
110
|
+
def check(self) -> None:
|
|
111
|
+
if self._process.wait() == 0:
|
|
112
|
+
return
|
|
113
|
+
self._errors.seek(0)
|
|
114
|
+
detail = self._errors.read().decode(errors="replace")
|
|
115
|
+
raise FFmpegRunError(f"ffmpeg failed (exit {self._process.returncode}): {detail}")
|
|
116
|
+
|
|
117
|
+
|
|
89
118
|
@contextmanager
|
|
90
|
-
def popen_decode(cmd: Sequence[str], *, bufsize: int = -1) -> Iterator[
|
|
119
|
+
def popen_decode(cmd: Sequence[str], *, bufsize: int = -1) -> Iterator[_DecodeProcess]:
|
|
91
120
|
"""Context manager wrapping an ffmpeg decode process.
|
|
92
121
|
|
|
93
|
-
Yields a
|
|
94
|
-
|
|
95
|
-
|
|
122
|
+
Yields a :class:`_DecodeProcess` with ``stdout=PIPE`` and diagnostics
|
|
123
|
+
stored in a temporary file. A caller that drains stdout must call
|
|
124
|
+
:meth:`_DecodeProcess.check`; a caller that stops early can leave the
|
|
125
|
+
context and the process is terminated without a decode error.
|
|
96
126
|
|
|
97
127
|
Args:
|
|
98
128
|
cmd: Full ffmpeg argv. The output target is typically ``pipe:1``.
|
|
@@ -100,18 +130,19 @@ def popen_decode(cmd: Sequence[str], *, bufsize: int = -1) -> Iterator[subproces
|
|
|
100
130
|
(e.g. ``10**8``) for batched reads or a frame-sized value
|
|
101
131
|
for streaming reads.
|
|
102
132
|
"""
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
proc.stdout.
|
|
133
|
+
with tempfile.TemporaryFile() as errors:
|
|
134
|
+
proc = subprocess.Popen(
|
|
135
|
+
_strict_decode_command(cmd),
|
|
136
|
+
stdout=subprocess.PIPE,
|
|
137
|
+
stderr=errors,
|
|
138
|
+
bufsize=bufsize,
|
|
139
|
+
)
|
|
140
|
+
try:
|
|
141
|
+
yield _DecodeProcess(proc, errors)
|
|
142
|
+
finally:
|
|
143
|
+
_terminate(proc)
|
|
144
|
+
if proc.stdout is not None and not proc.stdout.closed:
|
|
145
|
+
proc.stdout.close()
|
|
115
146
|
|
|
116
147
|
|
|
117
148
|
@contextmanager
|
|
@@ -10,9 +10,9 @@ from typing import TYPE_CHECKING
|
|
|
10
10
|
|
|
11
11
|
import numpy as np
|
|
12
12
|
|
|
13
|
+
from videopython import _ffmpeg
|
|
14
|
+
from videopython._exceptions import FFmpegRunError
|
|
13
15
|
from videopython.ai.errors import AiError
|
|
14
|
-
from videopython.base import _ffmpeg
|
|
15
|
-
from videopython.base.exceptions import FFmpegRunError
|
|
16
16
|
|
|
17
17
|
if TYPE_CHECKING:
|
|
18
18
|
from videopython.audio import Audio
|
|
@@ -10,12 +10,12 @@ from pathlib import Path
|
|
|
10
10
|
from typing import ClassVar, Literal
|
|
11
11
|
|
|
12
12
|
import numpy as np
|
|
13
|
-
from pydantic import Field
|
|
13
|
+
from pydantic import Field, PositiveInt
|
|
14
14
|
from tqdm import tqdm
|
|
15
15
|
|
|
16
|
+
from videopython._ffmpeg import escape_filter_value
|
|
16
17
|
from videopython.ai.understanding.faces import FaceSmoothingTracker
|
|
17
18
|
from videopython.base._dimensions import floor_to_even
|
|
18
|
-
from videopython.base._ffmpeg import escape_filter_value
|
|
19
19
|
from videopython.base.video import FrameIterator, VideoMetadata
|
|
20
20
|
from videopython.editing.operation import FilterCtx, OpCategory, Operation
|
|
21
21
|
|
|
@@ -46,30 +46,28 @@ class FaceTrackingCrop(Operation):
|
|
|
46
46
|
category: ClassVar[OpCategory] = OpCategory.TRANSFORM
|
|
47
47
|
compiles_from_source: ClassVar[bool] = True
|
|
48
48
|
|
|
49
|
-
target_aspect: tuple[
|
|
49
|
+
target_aspect: tuple[PositiveInt, PositiveInt] = Field(
|
|
50
|
+
(9, 16), description="Output aspect ratio as (width, height)."
|
|
51
|
+
)
|
|
50
52
|
face_selection: Literal["largest", "centered", "index"] = Field(
|
|
51
53
|
"largest", description="Strategy for selecting which face to track."
|
|
52
54
|
)
|
|
53
55
|
face_index: int = Field(0, ge=0, description='Index of face to track when using ``face_selection="index"``.')
|
|
54
|
-
padding: float = Field(0.3, ge=0, description="Extra space around face (0.3 = 30% padding on each side).")
|
|
55
56
|
vertical_offset: float = Field(-0.1, description='Vertical position offset used by ``framing_rule="offset"``.')
|
|
56
|
-
framing_rule: Literal["offset", "center", "headroom", "thirds"
|
|
57
|
+
framing_rule: Literal["offset", "center", "headroom", "thirds"] = Field(
|
|
57
58
|
"offset",
|
|
58
59
|
description=(
|
|
59
60
|
'Subject framing strategy. "offset": apply ``vertical_offset``; '
|
|
60
61
|
'"center": keep face centered; "headroom": extra room above the face; '
|
|
61
|
-
'"thirds": face near the upper-third line
|
|
62
|
+
'"thirds": face near the upper-third line.'
|
|
62
63
|
),
|
|
63
64
|
)
|
|
64
65
|
headroom: float = Field(0.15, description="Headroom amount for framing rules that use it.")
|
|
65
66
|
smoothing: float = Field(0.8, ge=0, le=1, description="Position smoothing factor (0-1, higher = smoother).")
|
|
66
67
|
max_speed: float | None = Field(None, gt=0, description="Optional max camera movement per frame (normalized).")
|
|
67
|
-
fallback: Literal["center", "last_position"
|
|
68
|
+
fallback: Literal["center", "last_position"] = Field(
|
|
68
69
|
"last_position",
|
|
69
|
-
description=
|
|
70
|
-
'Behavior when no face detected. "center" and "full_frame" both center the crop '
|
|
71
|
-
'while "last_position" holds the last tracked crop.'
|
|
72
|
-
),
|
|
70
|
+
description='Behavior when no face is detected. "center" centers the crop; "last_position" holds it.',
|
|
73
71
|
)
|
|
74
72
|
detection_interval: int = Field(3, ge=1, description="Frames between face detections.")
|
|
75
73
|
|
|
@@ -80,10 +78,7 @@ class FaceTrackingCrop(Operation):
|
|
|
80
78
|
return (face_cx, face_cy)
|
|
81
79
|
if self.framing_rule == "headroom":
|
|
82
80
|
return (face_cx, face_cy - self.headroom)
|
|
83
|
-
|
|
84
|
-
return (face_cx, face_cy - (1 / 3 - 0.5))
|
|
85
|
-
# "dynamic" — placeholder until motion/look-direction framing is implemented.
|
|
86
|
-
return (face_cx, face_cy - self.headroom)
|
|
81
|
+
return (face_cx, face_cy - (1 / 3 - 0.5))
|
|
87
82
|
|
|
88
83
|
def _resolved_output_dims(self, w: int, h: int) -> tuple[int, int]:
|
|
89
84
|
"""Output ``(width, height)`` -- the fixed crop-window size.
|
|
@@ -154,7 +149,7 @@ class FaceTrackingCrop(Operation):
|
|
|
154
149
|
positions.append((x, y))
|
|
155
150
|
elif self.fallback == "last_position":
|
|
156
151
|
positions.append(last)
|
|
157
|
-
else:
|
|
152
|
+
else:
|
|
158
153
|
positions.append(default)
|
|
159
154
|
return positions
|
|
160
155
|
|
|
@@ -17,6 +17,7 @@ from .models import (
|
|
|
17
17
|
SCENE_VLM,
|
|
18
18
|
SEMANTIC_SCENE_DETECTOR,
|
|
19
19
|
AnalysisRunInfo,
|
|
20
|
+
AnalyzerOutcome,
|
|
20
21
|
AudioAnalysisSection,
|
|
21
22
|
GeoMetadata,
|
|
22
23
|
SceneAnalysisSample,
|
|
@@ -30,6 +31,7 @@ __all__ = [
|
|
|
30
31
|
"ALL_ANALYZER_IDS",
|
|
31
32
|
"AUDIO_CLASSIFIER",
|
|
32
33
|
"AUDIO_TO_TEXT",
|
|
34
|
+
"AnalyzerOutcome",
|
|
33
35
|
"AnalysisRunInfo",
|
|
34
36
|
"AudioAnalysisSection",
|
|
35
37
|
"FACE_TRACKER",
|