open-montage 0.3.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.
- open_montage-0.3.0/.github/workflows/ci.yml +45 -0
- open_montage-0.3.0/.github/workflows/release.yml +46 -0
- open_montage-0.3.0/.gitignore +31 -0
- open_montage-0.3.0/CHANGELOG.md +48 -0
- open_montage-0.3.0/CONTRIBUTING.md +26 -0
- open_montage-0.3.0/LICENSE +21 -0
- open_montage-0.3.0/PKG-INFO +190 -0
- open_montage-0.3.0/README.md +162 -0
- open_montage-0.3.0/pyproject.toml +56 -0
- open_montage-0.3.0/src/open_montage/__init__.py +23 -0
- open_montage-0.3.0/src/open_montage/__main__.py +6 -0
- open_montage-0.3.0/src/open_montage/cli.py +162 -0
- open_montage-0.3.0/src/open_montage/montage.py +127 -0
- open_montage-0.3.0/src/open_montage/py.typed +0 -0
- open_montage-0.3.0/src/open_montage/render.py +277 -0
- open_montage-0.3.0/tests/test_cli.py +65 -0
- open_montage-0.3.0/tests/test_montage.py +58 -0
- open_montage-0.3.0/tests/test_render.py +164 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- name: Install
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
pip install -e ".[dev]"
|
|
25
|
+
- name: Lint
|
|
26
|
+
run: ruff check .
|
|
27
|
+
- name: Test
|
|
28
|
+
run: pytest
|
|
29
|
+
|
|
30
|
+
render:
|
|
31
|
+
# Installs the optional renderer (MoviePy + bundled ffmpeg) and runs the
|
|
32
|
+
# full suite, including the integration test that encodes a real video.
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- name: Set up Python
|
|
37
|
+
uses: actions/setup-python@v5
|
|
38
|
+
with:
|
|
39
|
+
python-version: "3.12"
|
|
40
|
+
- name: Install (with render extra)
|
|
41
|
+
run: |
|
|
42
|
+
python -m pip install --upgrade pip
|
|
43
|
+
pip install -e ".[dev,render]"
|
|
44
|
+
- name: Test (incl. video rendering)
|
|
45
|
+
run: pytest
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Build distributions on every tag, and publish to PyPI for v* tags.
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags: ["v*"]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
- name: Build sdist and wheel
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip build
|
|
23
|
+
python -m build
|
|
24
|
+
- name: Check metadata
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install twine
|
|
27
|
+
python -m twine check dist/*
|
|
28
|
+
- uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: dist
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
publish:
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
# Publishes using a PYPI_API_TOKEN repository secret. Add it under
|
|
37
|
+
# Settings -> Secrets and variables -> Actions (see "Publishing" in README).
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/download-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: dist
|
|
42
|
+
path: dist/
|
|
43
|
+
- name: Publish to PyPI
|
|
44
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
45
|
+
with:
|
|
46
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
.Python
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.eggs/
|
|
12
|
+
|
|
13
|
+
# Test / coverage
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
htmlcov/
|
|
17
|
+
.tox/
|
|
18
|
+
|
|
19
|
+
# Tooling caches
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
env/
|
|
27
|
+
|
|
28
|
+
# Editors / OS
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
.DS_Store
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format is based on
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.3.0] - 2026-06-06
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Aspect-ratio fitting for rendering: `fit="contain"` (letterbox, default),
|
|
12
|
+
`"cover"` (fill and crop), or `"stretch"`.
|
|
13
|
+
- Crossfade `transition` between consecutive clips.
|
|
14
|
+
- `ken_burns` slow centered zoom on still images.
|
|
15
|
+
- Optional `title` card and per-clip `captions` (drawn from each clip's label),
|
|
16
|
+
rendered with Pillow so no system font is required.
|
|
17
|
+
- New CLI flags: `--fit`, `--transition`, `--ken-burns`, `--title`,
|
|
18
|
+
`--title-duration`, `--captions`.
|
|
19
|
+
- Release workflow (`.github/workflows/release.yml`) that builds and publishes
|
|
20
|
+
to PyPI on `v*` tags via Trusted Publishing, plus a README "Publishing"
|
|
21
|
+
section.
|
|
22
|
+
|
|
23
|
+
## [0.2.0] - 2026-06-05
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Video rendering: `open_montage.render.render_montage()` turns a montage into a
|
|
28
|
+
real MP4 — still images held for their duration, video clips trimmed and
|
|
29
|
+
concatenated, with an optional audio track. Built on MoviePy (bundled ffmpeg
|
|
30
|
+
via imageio-ffmpeg), exposed behind the optional `[render]` extra so the core
|
|
31
|
+
model stays dependency-free.
|
|
32
|
+
- `open-montage render` CLI subcommand (`--fps`, `--size`, `--audio`,
|
|
33
|
+
`--progress`).
|
|
34
|
+
- Helpers `clip_kind()` and `parse_size()`, and a `RenderError` type.
|
|
35
|
+
- Tests for the renderer, including an integration test that encodes a real
|
|
36
|
+
video (skipped when the render extra is unavailable), plus a CI job that
|
|
37
|
+
exercises rendering.
|
|
38
|
+
|
|
39
|
+
## [0.1.0] - 2026-06-05
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Initial project scaffold.
|
|
44
|
+
- Core domain model: `Clip`, `Segment`, `Montage`, and `MontageError`.
|
|
45
|
+
- `Montage.timeline()` for computing absolute clip start/end times, plus
|
|
46
|
+
JSON serialization (`to_json` / `from_json`).
|
|
47
|
+
- `open-montage` command-line interface with `build` and `info` subcommands.
|
|
48
|
+
- Test suite, `ruff` linting, and a GitHub Actions CI workflow.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Contributing to Open Montage
|
|
2
|
+
|
|
3
|
+
Thanks for helping build Open Montage.
|
|
4
|
+
|
|
5
|
+
## Getting set up
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install -e ".[dev]"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Before opening a PR
|
|
12
|
+
|
|
13
|
+
Please make sure both of these pass:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ruff check .
|
|
17
|
+
pytest
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Guidelines
|
|
21
|
+
|
|
22
|
+
- Keep `open_montage.montage` free of I/O and third-party dependencies — it is
|
|
23
|
+
the pure core of the project. I/O and integrations belong in `cli.py` or in
|
|
24
|
+
new, clearly separated modules.
|
|
25
|
+
- Add or update tests for any behavior change.
|
|
26
|
+
- Keep public API changes documented in the `README` and `CHANGELOG`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BAS-More
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open-montage
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Describe media montages and render them into real movies.
|
|
5
|
+
Project-URL: Homepage, https://github.com/BAS-More/Open-Montage
|
|
6
|
+
Project-URL: Repository, https://github.com/BAS-More/Open-Montage
|
|
7
|
+
Project-URL: Issues, https://github.com/BAS-More/Open-Montage/issues
|
|
8
|
+
Author: BAS-More
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: edit-decision-list,media,montage,timeline,video
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Multimedia :: Video
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
25
|
+
Provides-Extra: render
|
|
26
|
+
Requires-Dist: moviepy<3,>=2.0; extra == 'render'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Open Montage
|
|
30
|
+
|
|
31
|
+
A Python toolkit to **describe media montages and render them into real movies**.
|
|
32
|
+
|
|
33
|
+
Open Montage has two layers:
|
|
34
|
+
|
|
35
|
+
1. **A tiny, dependency-free model** — build a montage out of clips and read back
|
|
36
|
+
its timeline (the absolute start/end time of every clip), serialize it to JSON.
|
|
37
|
+
2. **A video renderer** — turn that montage into an actual MP4: still images are
|
|
38
|
+
held for their duration, video clips are trimmed and stitched together, with an
|
|
39
|
+
optional audio track. Rendering uses [MoviePy](https://zulko.github.io/moviepy/),
|
|
40
|
+
which ships its own ffmpeg, so **no system ffmpeg install is needed**.
|
|
41
|
+
|
|
42
|
+
`v0.3.0`, part of the BAS-More software library.
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install -e ".[render]" # model + video renderer
|
|
48
|
+
pip install -e ".[dev,render]" # everything, incl. test/lint tools
|
|
49
|
+
pip install -e . # model + CLI only (build/info), no rendering deps
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The core model has **no third-party dependencies**; only the renderer pulls in
|
|
53
|
+
MoviePy + ffmpeg.
|
|
54
|
+
|
|
55
|
+
## Make a movie
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 1. Describe the montage (3 sources, 1.5s each)
|
|
59
|
+
open-montage build scene1.png clip.mp4 scene2.jpg --duration 1.5 --title "Reel" -o reel.json
|
|
60
|
+
|
|
61
|
+
# 2. Render it to a video file
|
|
62
|
+
open-montage render reel.json -o reel.mp4 --fps 24 --size 1280x720 --audio music.mp3
|
|
63
|
+
# Wrote 3 clip(s) → reel.mp4 (4.5s)
|
|
64
|
+
|
|
65
|
+
# ...with effects: letterbox, crossfades, slow zoom, a title card and captions
|
|
66
|
+
open-montage render reel.json -o reel.mp4 \
|
|
67
|
+
--size 1920x1080 --fit contain --transition 0.5 \
|
|
68
|
+
--ken-burns --title "Holiday" --captions
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- **Images** (`.png .jpg .jpeg .bmp .gif .webp .tif`) are shown as stills for
|
|
72
|
+
their duration.
|
|
73
|
+
- **Videos** (`.mp4 .mov .avi .mkv .webm .m4v .mpg`) are trimmed to their duration
|
|
74
|
+
(or used whole if shorter).
|
|
75
|
+
- `--size` defaults to the first video clip's resolution, falling back to 1280×720.
|
|
76
|
+
- `--audio` lays a track under the whole montage, trimmed to its length.
|
|
77
|
+
|
|
78
|
+
### Effects
|
|
79
|
+
|
|
80
|
+
| Flag | What it does |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `--fit contain\|cover\|stretch` | Fit clips to the frame: letterbox (default), fill-and-crop, or stretch. |
|
|
83
|
+
| `--transition SECONDS` | Crossfade between consecutive clips. Must be shorter than the shortest clip. |
|
|
84
|
+
| `--ken-burns` | Slow centered zoom on still images. |
|
|
85
|
+
| `--title TEXT` / `--title-duration S` | Show a title card before the montage. |
|
|
86
|
+
| `--captions` | Overlay each clip's `label` as a caption along the bottom. |
|
|
87
|
+
|
|
88
|
+
From Python:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from open_montage import Clip, Montage, render_montage
|
|
92
|
+
|
|
93
|
+
montage = (
|
|
94
|
+
Montage(title="Reel")
|
|
95
|
+
.add(Clip("scene1.png", duration=1.5, label="Sunrise"))
|
|
96
|
+
.add(Clip("clip.mp4", duration=3.0, label="Harbour"))
|
|
97
|
+
)
|
|
98
|
+
render_montage(
|
|
99
|
+
montage, "reel.mp4",
|
|
100
|
+
fps=24, size=(1920, 1080),
|
|
101
|
+
fit="contain", transition=0.5, ken_burns=True,
|
|
102
|
+
title="Holiday", captions=True, audio="music.mp3",
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Model & inspection (no rendering deps)
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from open_montage import Clip, Montage
|
|
110
|
+
|
|
111
|
+
montage = (
|
|
112
|
+
Montage(title="Holiday")
|
|
113
|
+
.add(Clip("beach.jpg", duration=2.0, label="Beach"))
|
|
114
|
+
.add(Clip("sunset.mp4", duration=4.0))
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
print(montage.total_duration) # 6.0
|
|
118
|
+
for segment in montage.timeline():
|
|
119
|
+
print(segment.clip.source, segment.start, "->", segment.end)
|
|
120
|
+
|
|
121
|
+
montage.to_json() # serialize to a JSON document
|
|
122
|
+
Montage.from_json(text) # ...and back again
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
open-montage info reel.json
|
|
127
|
+
# Reel — 3 clip(s), 4.5s total
|
|
128
|
+
# 1. scene1.png [0s → 1.5s]
|
|
129
|
+
# ...
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
You can also run the CLI as a module: `python -m open_montage ...`.
|
|
133
|
+
|
|
134
|
+
## Project layout
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
src/open_montage/
|
|
138
|
+
__init__.py # public API (Clip, Montage, Segment, render_montage, ...)
|
|
139
|
+
montage.py # pure domain model — no I/O, no dependencies
|
|
140
|
+
render.py # video rendering via MoviePy/ffmpeg (optional [render] extra)
|
|
141
|
+
cli.py # argparse command-line interface
|
|
142
|
+
__main__.py # `python -m open_montage`
|
|
143
|
+
tests/ # pytest suite
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pip install -e ".[dev,render]"
|
|
150
|
+
ruff check .
|
|
151
|
+
pytest
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Render tests that encode video are skipped automatically if the `render` extra
|
|
155
|
+
isn't installed.
|
|
156
|
+
|
|
157
|
+
## Publishing
|
|
158
|
+
|
|
159
|
+
Releases are built and published to [PyPI](https://pypi.org/) by
|
|
160
|
+
[`.github/workflows/release.yml`](.github/workflows/release.yml) when a `v*` tag
|
|
161
|
+
is pushed:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
git tag v0.3.0
|
|
165
|
+
git push origin v0.3.0
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The workflow builds an sdist + wheel, runs `twine check`, and uploads to PyPI.
|
|
169
|
+
Authentication uses a **PyPI API token**, configured once:
|
|
170
|
+
|
|
171
|
+
1. Create the project / reserve the name `open-montage` on PyPI, and generate an
|
|
172
|
+
API token (PyPI → Account settings → API tokens).
|
|
173
|
+
2. Add it to this repo as a secret named **`PYPI_API_TOKEN`**
|
|
174
|
+
(Settings → Secrets and variables → Actions → New repository secret).
|
|
175
|
+
|
|
176
|
+
Then publishing happens automatically on the next `v*` tag. (Prefer keyless
|
|
177
|
+
[Trusted Publishing](https://docs.pypi.org/trusted-publishers/) instead? Drop the
|
|
178
|
+
`with: password:` line from the publish step and configure a Trusted Publisher
|
|
179
|
+
for this repo + `release.yml`.)
|
|
180
|
+
|
|
181
|
+
Build locally to sanity-check before tagging:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
python -m pip install build twine
|
|
185
|
+
python -m build && python -m twine check dist/*
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
[MIT](LICENSE) © BAS-More
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Open Montage
|
|
2
|
+
|
|
3
|
+
A Python toolkit to **describe media montages and render them into real movies**.
|
|
4
|
+
|
|
5
|
+
Open Montage has two layers:
|
|
6
|
+
|
|
7
|
+
1. **A tiny, dependency-free model** — build a montage out of clips and read back
|
|
8
|
+
its timeline (the absolute start/end time of every clip), serialize it to JSON.
|
|
9
|
+
2. **A video renderer** — turn that montage into an actual MP4: still images are
|
|
10
|
+
held for their duration, video clips are trimmed and stitched together, with an
|
|
11
|
+
optional audio track. Rendering uses [MoviePy](https://zulko.github.io/moviepy/),
|
|
12
|
+
which ships its own ffmpeg, so **no system ffmpeg install is needed**.
|
|
13
|
+
|
|
14
|
+
`v0.3.0`, part of the BAS-More software library.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install -e ".[render]" # model + video renderer
|
|
20
|
+
pip install -e ".[dev,render]" # everything, incl. test/lint tools
|
|
21
|
+
pip install -e . # model + CLI only (build/info), no rendering deps
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The core model has **no third-party dependencies**; only the renderer pulls in
|
|
25
|
+
MoviePy + ffmpeg.
|
|
26
|
+
|
|
27
|
+
## Make a movie
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# 1. Describe the montage (3 sources, 1.5s each)
|
|
31
|
+
open-montage build scene1.png clip.mp4 scene2.jpg --duration 1.5 --title "Reel" -o reel.json
|
|
32
|
+
|
|
33
|
+
# 2. Render it to a video file
|
|
34
|
+
open-montage render reel.json -o reel.mp4 --fps 24 --size 1280x720 --audio music.mp3
|
|
35
|
+
# Wrote 3 clip(s) → reel.mp4 (4.5s)
|
|
36
|
+
|
|
37
|
+
# ...with effects: letterbox, crossfades, slow zoom, a title card and captions
|
|
38
|
+
open-montage render reel.json -o reel.mp4 \
|
|
39
|
+
--size 1920x1080 --fit contain --transition 0.5 \
|
|
40
|
+
--ken-burns --title "Holiday" --captions
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- **Images** (`.png .jpg .jpeg .bmp .gif .webp .tif`) are shown as stills for
|
|
44
|
+
their duration.
|
|
45
|
+
- **Videos** (`.mp4 .mov .avi .mkv .webm .m4v .mpg`) are trimmed to their duration
|
|
46
|
+
(or used whole if shorter).
|
|
47
|
+
- `--size` defaults to the first video clip's resolution, falling back to 1280×720.
|
|
48
|
+
- `--audio` lays a track under the whole montage, trimmed to its length.
|
|
49
|
+
|
|
50
|
+
### Effects
|
|
51
|
+
|
|
52
|
+
| Flag | What it does |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `--fit contain\|cover\|stretch` | Fit clips to the frame: letterbox (default), fill-and-crop, or stretch. |
|
|
55
|
+
| `--transition SECONDS` | Crossfade between consecutive clips. Must be shorter than the shortest clip. |
|
|
56
|
+
| `--ken-burns` | Slow centered zoom on still images. |
|
|
57
|
+
| `--title TEXT` / `--title-duration S` | Show a title card before the montage. |
|
|
58
|
+
| `--captions` | Overlay each clip's `label` as a caption along the bottom. |
|
|
59
|
+
|
|
60
|
+
From Python:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from open_montage import Clip, Montage, render_montage
|
|
64
|
+
|
|
65
|
+
montage = (
|
|
66
|
+
Montage(title="Reel")
|
|
67
|
+
.add(Clip("scene1.png", duration=1.5, label="Sunrise"))
|
|
68
|
+
.add(Clip("clip.mp4", duration=3.0, label="Harbour"))
|
|
69
|
+
)
|
|
70
|
+
render_montage(
|
|
71
|
+
montage, "reel.mp4",
|
|
72
|
+
fps=24, size=(1920, 1080),
|
|
73
|
+
fit="contain", transition=0.5, ken_burns=True,
|
|
74
|
+
title="Holiday", captions=True, audio="music.mp3",
|
|
75
|
+
)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Model & inspection (no rendering deps)
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from open_montage import Clip, Montage
|
|
82
|
+
|
|
83
|
+
montage = (
|
|
84
|
+
Montage(title="Holiday")
|
|
85
|
+
.add(Clip("beach.jpg", duration=2.0, label="Beach"))
|
|
86
|
+
.add(Clip("sunset.mp4", duration=4.0))
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
print(montage.total_duration) # 6.0
|
|
90
|
+
for segment in montage.timeline():
|
|
91
|
+
print(segment.clip.source, segment.start, "->", segment.end)
|
|
92
|
+
|
|
93
|
+
montage.to_json() # serialize to a JSON document
|
|
94
|
+
Montage.from_json(text) # ...and back again
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
open-montage info reel.json
|
|
99
|
+
# Reel — 3 clip(s), 4.5s total
|
|
100
|
+
# 1. scene1.png [0s → 1.5s]
|
|
101
|
+
# ...
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
You can also run the CLI as a module: `python -m open_montage ...`.
|
|
105
|
+
|
|
106
|
+
## Project layout
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
src/open_montage/
|
|
110
|
+
__init__.py # public API (Clip, Montage, Segment, render_montage, ...)
|
|
111
|
+
montage.py # pure domain model — no I/O, no dependencies
|
|
112
|
+
render.py # video rendering via MoviePy/ffmpeg (optional [render] extra)
|
|
113
|
+
cli.py # argparse command-line interface
|
|
114
|
+
__main__.py # `python -m open_montage`
|
|
115
|
+
tests/ # pytest suite
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install -e ".[dev,render]"
|
|
122
|
+
ruff check .
|
|
123
|
+
pytest
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Render tests that encode video are skipped automatically if the `render` extra
|
|
127
|
+
isn't installed.
|
|
128
|
+
|
|
129
|
+
## Publishing
|
|
130
|
+
|
|
131
|
+
Releases are built and published to [PyPI](https://pypi.org/) by
|
|
132
|
+
[`.github/workflows/release.yml`](.github/workflows/release.yml) when a `v*` tag
|
|
133
|
+
is pushed:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
git tag v0.3.0
|
|
137
|
+
git push origin v0.3.0
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The workflow builds an sdist + wheel, runs `twine check`, and uploads to PyPI.
|
|
141
|
+
Authentication uses a **PyPI API token**, configured once:
|
|
142
|
+
|
|
143
|
+
1. Create the project / reserve the name `open-montage` on PyPI, and generate an
|
|
144
|
+
API token (PyPI → Account settings → API tokens).
|
|
145
|
+
2. Add it to this repo as a secret named **`PYPI_API_TOKEN`**
|
|
146
|
+
(Settings → Secrets and variables → Actions → New repository secret).
|
|
147
|
+
|
|
148
|
+
Then publishing happens automatically on the next `v*` tag. (Prefer keyless
|
|
149
|
+
[Trusted Publishing](https://docs.pypi.org/trusted-publishers/) instead? Drop the
|
|
150
|
+
`with: password:` line from the publish step and configure a Trusted Publisher
|
|
151
|
+
for this repo + `release.yml`.)
|
|
152
|
+
|
|
153
|
+
Build locally to sanity-check before tagging:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
python -m pip install build twine
|
|
157
|
+
python -m build && python -m twine check dist/*
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
[MIT](LICENSE) © BAS-More
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "open-montage"
|
|
7
|
+
description = "Describe media montages and render them into real movies."
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "BAS-More" }]
|
|
12
|
+
keywords = ["montage", "media", "video", "edit-decision-list", "timeline"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Topic :: Multimedia :: Video",
|
|
23
|
+
]
|
|
24
|
+
dynamic = ["version"]
|
|
25
|
+
dependencies = []
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
# Video rendering. MoviePy pulls in its own ffmpeg via imageio-ffmpeg, so no
|
|
29
|
+
# system ffmpeg install is required.
|
|
30
|
+
render = ["moviepy>=2.0,<3"]
|
|
31
|
+
dev = ["pytest>=7", "ruff>=0.4"]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/BAS-More/Open-Montage"
|
|
35
|
+
Repository = "https://github.com/BAS-More/Open-Montage"
|
|
36
|
+
Issues = "https://github.com/BAS-More/Open-Montage/issues"
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
open-montage = "open_montage.cli:main"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.version]
|
|
42
|
+
path = "src/open_montage/__init__.py"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.wheel]
|
|
45
|
+
packages = ["src/open_montage"]
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
testpaths = ["tests"]
|
|
49
|
+
addopts = "-ra"
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
line-length = 100
|
|
53
|
+
target-version = "py39"
|
|
54
|
+
|
|
55
|
+
[tool.ruff.lint]
|
|
56
|
+
select = ["E", "F", "I", "B", "UP"]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Open Montage — describe media montages and render them into real movies.
|
|
2
|
+
|
|
3
|
+
Two layers:
|
|
4
|
+
|
|
5
|
+
* :mod:`open_montage.montage` — a tiny, dependency-free model. Build a
|
|
6
|
+
:class:`Montage` out of :class:`Clip` objects and read back its
|
|
7
|
+
:class:`Segment` timeline.
|
|
8
|
+
* :mod:`open_montage.render` — turn a montage into an actual video file with
|
|
9
|
+
:func:`render_montage`. This needs the optional ``[render]`` extra (MoviePy).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .montage import Clip, Montage, MontageError, Segment
|
|
13
|
+
from .render import RenderError, render_montage
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"Clip",
|
|
17
|
+
"Montage",
|
|
18
|
+
"MontageError",
|
|
19
|
+
"RenderError",
|
|
20
|
+
"Segment",
|
|
21
|
+
"render_montage",
|
|
22
|
+
]
|
|
23
|
+
__version__ = "0.3.0"
|