@topy-ai/maggie 0.8.8 → 0.8.9
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.
- package/README-zh-TW.md +1 -1
- package/README.md +1 -1
- package/bundled-references/ffmpeg-recipes.md +1 -0
- package/bundled-references/video-timeline-model.md +17 -0
- package/bundled-skills/maggie-video/SKILL.md +11 -5
- package/bundled-tools/clis/maggie_video.py +185 -1
- package/package.json +1 -1
- package/references/ffmpeg-recipes.md +1 -0
- package/references/video-timeline-model.md +17 -0
package/README-zh-TW.md
CHANGED
|
@@ -143,7 +143,7 @@ structure drift 或重複 treatment product 時 fail closed。
|
|
|
143
143
|
deployment、memory、feedback 和 MaggieDash。內容先 draft/review,外部寫入、
|
|
144
144
|
publish 與 production deployment 需要明確確認。
|
|
145
145
|
|
|
146
|
-
目前 npm 版本為 `0.8.8
|
|
146
|
+
目前 npm 版本為 `0.8.9`,為 `maggie_video.py` 新增 `compile` 子命令(把宣告式 timeline JSON 編譯成單一 ffmpeg 命令,已實測)。先前 0.8.8 新增 `maggie-video`(製作與處理行銷影片:剪輯、字幕、裁切成各渠道比例、浮水印、轉碼、響度正規化、clip 組裝、程式化動畫),附一個實測可用的 ffmpeg 配方 CLI(`maggie_video.py`),從參考庫的影片專案(moviepy/editly/ffmpeg 命令層、Revideo/Motion Canvas/CCapture 程式化渲染、MLT/OpenShot/Olive 的 timeline 資料形狀)提煉而來;另加 `ffmpeg-recipes`、`programmatic-video`、`video-timeline-model` 三個 reference。先前 0.8.7 把 redesign 稽核併入 `maggie-design`(改編自 MIT 的 `elayadesign/redesign-skill`):掃描 + 診斷 AI 通病/缺失狀態/雜亂程式碼,再經 in-place/verify 流程就地修正,因此「稽核/打磨/升級既有站點」會路由到 maggie-design。先前 0.8.6 補齊兩個設計技能:加入完整的生產 reference,並把設計來源明確為 Figma 非必需(實時 URL、既有程式碼、Figma、或純截圖)。先前 0.8.5 採納兩個設計技能(改編自 MIT 的 `elayadesign/ai-design-skills`):maggie-landing-page(轉化策略 + 視覺系統紀律,具體數值為可被專案 DESIGN.md 覆蓋的預設值;由 maggie-design 生產與驗證)與 maggie-design-motion(靜態設計→像素級動畫 HTML 複刻→匯出 MP4 + GIF)。先前 0.8.4 將技能庫擴展成完整的「一人用 AI 跑一家公司」C-suite,新增八條職能線:maggie-sales(CRM 中立的銷售管線)、maggie-finance(只解釋的 CFO 指標,含確定性 maggie_finance.py 計算器)、maggie-support(面向客戶的客戶成功)、maggie-product(路線圖 + 預註冊實驗)、maggie-fundraising(pitch deck、data room、投資人更新)、maggie-legal(ToS/隱私/DPA/SOC2 readiness)、maggie-monetization(定價/paywall/dunning,金錢操作需人工批准)、maggie-orchestrator(CEO 編排層:將目標拆成帶審批門的 mission 分派到各職能線,含 maggie_orchestrator.py 規劃器)。先前 0.8.3 將 cmo.so/www 開發經驗沉澱進技能庫:新增兩個技能 maggie-skill-authoring(依 catalog 與 MCP 工具白名單撰寫/校驗社區營銷 playbook 技能)與 maggie-feedback-triage(反饋的團隊接收端:決策/定級/分派、PRD + issue 流程、24/7 隊列守護);新增多個 reference(OAuth PKCE 登入、Expo 約定與 Router 骨架、MCP evals 測試框架、conversation cards、WordPress→Firebase 認證遷移手冊);並增補 maggie-assistant-tools(tool≤user 每輪工具過濾、agent loop 安全不變量、preview-only 橋接代理、MCP resources/prompts、注解加固、CLI 與 ChatGPT 插件打包)、maggie-auth-reference(自清理登入測試套件、自簽單次令牌)、maggie-mobile-app(OTA 開機拉取、live==built 部署守衛)、maggie-deployment(pm2 單包發布、live-hash 校驗)與 maggie-ops(template-as-code 郵件同步)。先前 0.8.2 新增 maggie-spirit(為 AI 品牌生成平面像素 spirit/sprite 系統)與 goal-led AI agent 設計參考;0.8.0 為安全優化 roadmap(scan、image-patch、標頭評分、SSVC、GDPR 日誌規則、新 MCP 工具)。先前 0.8.0 為安全優化 roadmap(scan、image-patch、標頭評分、SSVC、GDPR 日誌規則、新 MCP 工具),含 fix-plan 修補風險分級 T1–T4(判斷補丁是否安全套用)與 host-impact 補丁影響面量測(哪些服務需重啟、是否需重開機)、public-check、Maggie Security、batch 31 排程 agent routines、報告收件匣與無人值守 agent 限制、PHP runtime 盤點與主機鎖、pull 網站改寫、query 點子與社群佇列檢查,batch 30 MaggieDash 先裝核心、release privacy gate、feedback 備援、社群連結與圖片檢查、大量頁面產生與 app 檢查,batch 29 預約規則、部署、app QA、助理與社群功能,以及 batch 28 產品 app、assistant tools、mobile、product release、skills catalog 與 bridge host 功能、batch 26、27 feedback 修正與 idempotent `maggie update`與 Booking email-template 合約/CLI validator 同步。本版完成 2026-09-24 booking feedback batch:Calendar grid/free-slot entry 與 host modal focus-restoration evidence。本版新增 Starter marketplace provisioning plan;本版完成 feedback batches 22、23:加入 declarative browser interaction evidence、design markup/style/content-key gate、compiler source anchoring、entity double-escape protection、`update --help` read-only、noindex hypothetical indexability、可過期 baseline acknowledgement、DOM-only link extraction regression,以及 MaggieDash 0.2.10 的 content override、短期 browser session、CDN-safe public-session cache contracts。authentication 和 isolated dev server 仍由 host 負責。`maggie-booking` workflow、傳統 email/password、Stripe、Resend、public booking flow 及既有安全邊界維持不變;provider-bound video generation 與 transactional delivery 仍記錄在 issue #39,前一批延後功能仍在 issue #38,不會直接成為 active memory。0.7.33 記錄並審查一筆更正回饋;確認 0.7.32 已正確處理 batch index,沒有修改已驗證的 shared behavior。0.7.32 加入 feedback 一基索引支援、MaggieDash panel 的 source/freshness/error evidence、Consent Mode 與實際 write/no-op reconciliation、SEO baseline recapture、sitemap origin rebasing、content-diff scope、migration ledger reconciliation、deployment credential preflight、release provenance/runtime preflight、icon release gate、opt-in blog auto-publish gate,以及 least-privilege VPS deployer。也修復 top-level `maggie feedback` dispatcher parity。0.7.31 加入 update 差異摘要、atomic installer copy、subset install manifest merge,以及 inventory drift 時 doctor non-zero。0.7.30 補上 feedback tracking issue closeout gate 與 batch 14/15 audit ledger。0.7.29 修正 npm package landing page 使用英文 README;0.7.28 加入 versioned Gemini model policy、明確 fallback 與 provenance、bundled-first CLI
|
|
147
147
|
dispatch、`maggie --version`、feedback batch review 聚合與重複偵測、marketplace enrichment evidence、booking
|
|
148
148
|
worker/resolver evidence,以及 read-only migration preflight。它也包含 host-owned mobile app surface contract、signed-in
|
|
149
149
|
camera-state QA、直接 Astro route resolution、correlated feedback batch,以及
|
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Maggie keeps the existing project foundation and asks for decisions before
|
|
|
89
89
|
shared routes, analytics, or publishing boundaries change. The current
|
|
90
90
|
package ships 37 installable skills and a local-first MaggieDash foundation.
|
|
91
91
|
|
|
92
|
-
This package is `0.8.
|
|
92
|
+
This package is `0.8.9` — it adds a `compile` subcommand to `maggie_video.py` (declarative timeline JSON -> one ffmpeg command, tested end-to-end). `0.8.8` added `maggie-video` (produce and process marketing video: cut, caption, resize to channel aspects, watermark, transcode, normalize loudness, assemble clips, render code-drawn animation) with a tested ffmpeg-recipe CLI, distilled from the reference library's video projects; plus references `ffmpeg-recipes`, `programmatic-video`, `video-timeline-model`. `0.8.7` folded a redesign audit into `maggie-design` (from the MIT `elayadesign/redesign-skill`): scan + diagnose generic AI-design patterns/weak states/sloppy code, then fix in place via the in-place/verify flow, so "audit/polish/upgrade an existing site" routes to maggie-design. `0.8.6` completed the two adopted design skills with full production references and made the design source Figma-optional (live URL, existing code, Figma, or a screenshot). `0.8.5` adopted the two design skills (adapted, MIT, from `elayadesign/ai-design-skills`): `maggie-landing-page` (conversion strategy + a visual-system discipline whose values defer to the project's DESIGN.md) and `maggie-design-motion` (static design → pixel-exact animated HTML replica → MP4 + GIF export). `0.8.4` expanded the library into a full "one person runs a company with AI" C-suite with eight new function lanes: `maggie-sales` (CRM-neutral pipeline), `maggie-finance` (explain-only CFO metrics + a deterministic `maggie_finance.py` calculator), `maggie-support` (customer success), `maggie-product` (roadmap + pre-registered experiments), `maggie-fundraising` (deck, data room, investor updates), `maggie-legal` (ToS/privacy/DPA/SOC2 readiness), `maggie-monetization` (pricing/paywalls/dunning; money actions human-approved), and `maggie-orchestrator` (the CEO layer that decomposes a goal into gated missions across the lanes, with a `maggie_orchestrator.py` planner). `0.8.3` folded cmo.so/www development learnings in (maggie-skill-authoring, maggie-feedback-triage, and mobile/MCP/auth references); `0.8.2` added `maggie-spirit`; `0.8.0` was the security optimization roadmap.
|
|
93
93
|
|
|
94
94
|
The 0.7.59 release made `maggie security host-audit` (the deep
|
|
95
95
|
lynis audit over SSH) robust on hosts where a storage test can stall: lynis runs
|
|
@@ -120,6 +120,7 @@ map onto xfade's transition list.
|
|
|
120
120
|
```bash
|
|
121
121
|
maggie tool maggie_video.py social --input in.mp4 --output reel.mp4 --aspect reel
|
|
122
122
|
maggie tool maggie_video.py gif --input in.mp4 --output out.gif --fps 15 --width 480
|
|
123
|
+
maggie tool maggie_video.py compile --spec timeline.json # declarative timeline -> one command
|
|
123
124
|
maggie tool maggie_video.py --run encode --input in.mov --output out.mp4 # actually runs
|
|
124
125
|
maggie tool maggie_video.py presets
|
|
125
126
|
```
|
|
@@ -93,6 +93,23 @@ Compile the model to one `filter_complex`:
|
|
|
93
93
|
`mifi/editly` (MIT) and `Zulko/moviepy` (MIT) are working prior art that this JSON
|
|
94
94
|
shape renders through ffmpeg without any GPL engine.
|
|
95
95
|
|
|
96
|
+
### maggie_video.py compile
|
|
97
|
+
|
|
98
|
+
`maggie_video.py compile --spec timeline.json` compiles this model into one ffmpeg
|
|
99
|
+
`filter_complex` command (printed; run with `--run`). Supported today: a main video
|
|
100
|
+
track of clips (video/image) fit `cover`/`contain` to the canvas, hard-cut `concat`
|
|
101
|
+
or sequential `crossfade` (from `transitions`), image/text/caption overlays with
|
|
102
|
+
`position`+`duration` timing and `rect` placement, and an `audio[]` mix with
|
|
103
|
+
per-track `position`/`gain` plus `loudnorm`. Output is bounded to the computed video
|
|
104
|
+
duration and uses the shared web-safe profile. Not compiled yet (emitted as
|
|
105
|
+
`# NOTE:` lines): keyframes, ken-burns, and sidechain ducking - set static values or
|
|
106
|
+
use a programmatic engine for those.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
maggie tool maggie_video.py compile --spec timeline.json # print the command
|
|
110
|
+
maggie tool maggie_video.py --run compile --spec timeline.json # render it
|
|
111
|
+
```
|
|
112
|
+
|
|
96
113
|
## Optional higher-fidelity backend: melt (GPL, external)
|
|
97
114
|
|
|
98
115
|
The same model can emit **MLT XML** and render with
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: maggie-video
|
|
3
3
|
description: Produce and process marketing video - render a composition to MP4/GIF/WebM, assemble clips/images/text/captions/audio on a timeline, cut to channel aspects (reel/square/youtube), burn in captions, normalize loudness, watermark, transcode, and make social cuts. Engine-neutral over the renderer (ffmpeg for assembly/transcode, a programmatic engine for code-drawn animation). Use when the user wants to make, edit, cut, caption, resize, or export a video for marketing.
|
|
4
4
|
metadata:
|
|
5
|
-
version: 0.1.
|
|
5
|
+
version: 0.1.1
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Maggie Video
|
|
@@ -35,9 +35,12 @@ completion.
|
|
|
35
35
|
layer** directly. Every command is in [ffmpeg recipes](../../references/ffmpeg-recipes.md)
|
|
36
36
|
and generated by the CLI below.
|
|
37
37
|
- **Declarative multi-clip composition** (clips + overlays + transitions + audio) →
|
|
38
|
-
author the [timeline model](../../references/video-timeline-model.md) JSON and
|
|
39
|
-
compile it to one ffmpeg
|
|
40
|
-
|
|
38
|
+
author the [timeline model](../../references/video-timeline-model.md) JSON and run
|
|
39
|
+
`maggie_video.py compile --spec timeline.json`, which compiles it to one ffmpeg
|
|
40
|
+
`filter_complex` command (main track fit + concat/crossfade, image/text/caption
|
|
41
|
+
overlays with timing, audio mix + loudnorm; keyframes/ken-burns/ducking are flagged
|
|
42
|
+
as notes). For higher fidelity, emit MLT XML and render with `melt` as an optional
|
|
43
|
+
external GPL tool behind an adapter.
|
|
41
44
|
- **Code-drawn animation** (kinetic type, charts, N data-driven variants) →
|
|
42
45
|
[programmatic video](../../references/programmatic-video.md): use **Revideo**
|
|
43
46
|
(MIT, headless, parameterized) by default; **CCapture** for an existing canvas
|
|
@@ -61,12 +64,15 @@ maggie tool maggie_video.py overlay --input in.mp4 --logo logo.png --output bran
|
|
|
61
64
|
maggie tool maggie_video.py trim --input in.mp4 --output cut.mp4 --start 5 --duration 10
|
|
62
65
|
maggie tool maggie_video.py concat --inputs a.mp4 b.mp4 --output all.mp4 --reencode
|
|
63
66
|
maggie tool maggie_video.py thumb --input in.mp4 --output poster.jpg --at 00:00:03
|
|
67
|
+
maggie tool maggie_video.py compile --spec timeline.json # declarative -> one command
|
|
64
68
|
maggie tool maggie_video.py --run encode --input in.mov --output out.mp4 # actually runs
|
|
65
69
|
maggie tool maggie_video.py presets
|
|
66
70
|
```
|
|
67
71
|
|
|
68
72
|
Subcommands: `encode` (web-safe MP4 / VP9 WebM), `gif`, `trim`, `concat`, `social`,
|
|
69
|
-
`overlay`, `subtitle` (burn or soft-mux), `loudnorm`, `thumb`, `
|
|
73
|
+
`overlay`, `subtitle` (burn or soft-mux), `loudnorm`, `thumb`, `compile` (timeline
|
|
74
|
+
JSON -> ffmpeg), `presets`. `--run` (before the subcommand) executes when ffmpeg is
|
|
75
|
+
on PATH; otherwise the command is printed for review.
|
|
70
76
|
|
|
71
77
|
## Channel presets and safe areas
|
|
72
78
|
|
|
@@ -9,9 +9,10 @@ LGPL/GPL use); it links no libav and vendors no GPL code. Output is always force
|
|
|
9
9
|
to a web-safe, platform-correct profile.
|
|
10
10
|
|
|
11
11
|
Subcommands: encode, gif, trim, concat, social, overlay, subtitle, loudnorm,
|
|
12
|
-
thumb, presets.
|
|
12
|
+
thumb, compile, presets.
|
|
13
13
|
"""
|
|
14
14
|
import argparse
|
|
15
|
+
import json
|
|
15
16
|
import shlex
|
|
16
17
|
import shutil
|
|
17
18
|
import subprocess
|
|
@@ -142,6 +143,184 @@ def c_thumb(a):
|
|
|
142
143
|
return emit(cmd, a.run)
|
|
143
144
|
|
|
144
145
|
|
|
146
|
+
def _fit(w, h, mode, fps, color="black"):
|
|
147
|
+
"""A filter chain that fits a source to WxH and normalizes it for concat/xfade."""
|
|
148
|
+
if mode == "contain":
|
|
149
|
+
scale = (f"scale={w}:{h}:force_original_aspect_ratio=decrease,"
|
|
150
|
+
f"pad={w}:{h}:(ow-iw)/2:(oh-ih)/2:color={color}")
|
|
151
|
+
else: # cover (fill)
|
|
152
|
+
scale = f"scale={w}:{h}:force_original_aspect_ratio=increase,crop={w}:{h}"
|
|
153
|
+
return f"{scale},fps={fps},format=yuv420p,setsar=1"
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _clip_dur(clip, default):
|
|
157
|
+
if isinstance(clip.get("duration"), (int, float)):
|
|
158
|
+
return float(clip["duration"])
|
|
159
|
+
if isinstance(clip.get("start"), (int, float)) and isinstance(clip.get("end"), (int, float)):
|
|
160
|
+
return float(clip["end"]) - float(clip["start"])
|
|
161
|
+
return float(default)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def _px(val, total):
|
|
165
|
+
"""Resolve '80%' / 0.8 / 120 against a total dimension to an int pixel value."""
|
|
166
|
+
if isinstance(val, str) and val.strip().endswith("%"):
|
|
167
|
+
return int(round(float(val.strip()[:-1]) / 100.0 * total))
|
|
168
|
+
v = float(val)
|
|
169
|
+
return int(round(v * total)) if 0 < v <= 1 else int(round(v))
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def c_compile(a):
|
|
173
|
+
"""Compile a timeline-model JSON (references/video-timeline-model.md) into one
|
|
174
|
+
ffmpeg command. Supports: a main video track of clips (video/image) fit to the
|
|
175
|
+
canvas, hard-cut concat or sequential crossfade, image/text/caption overlays
|
|
176
|
+
with timing, and an audio mix with per-track gain + optional loudnorm. Keyframes,
|
|
177
|
+
ken-burns, and sidechain ducking are not compiled yet (flagged as notes)."""
|
|
178
|
+
with open(a.spec, encoding="utf-8") as fh:
|
|
179
|
+
spec = json.load(fh)
|
|
180
|
+
out = spec.get("output", {})
|
|
181
|
+
W, H = int(out.get("width", 1080)), int(out.get("height", 1920))
|
|
182
|
+
FPS = int(out.get("fps", 30))
|
|
183
|
+
outfile = a.output or out.get("path") or "out.mp4"
|
|
184
|
+
assets = spec.get("assets", {})
|
|
185
|
+
defaults = spec.get("defaults", {})
|
|
186
|
+
def_dur = defaults.get("clipDuration", 4)
|
|
187
|
+
notes, inputs, filters = [], [], []
|
|
188
|
+
|
|
189
|
+
def add_input(opts, path):
|
|
190
|
+
inputs.extend(opts + ["-i", path])
|
|
191
|
+
return len([x for x in inputs if x == "-i"]) - 1 # index of this input
|
|
192
|
+
|
|
193
|
+
tracks = spec.get("tracks", [])
|
|
194
|
+
vtracks = [t for t in tracks if t.get("kind", "video") == "video"]
|
|
195
|
+
if not vtracks:
|
|
196
|
+
raise SystemExit("spec needs at least one video track")
|
|
197
|
+
main = sorted(vtracks, key=lambda t: t.get("z", 0))[0]
|
|
198
|
+
overlays = [t for t in sorted(vtracks, key=lambda t: t.get("z", 0))[1:]]
|
|
199
|
+
|
|
200
|
+
# --- main track: build each clip segment, then concat or crossfade ---
|
|
201
|
+
segs, durs = [], []
|
|
202
|
+
for i, clip in enumerate(main.get("clips", [])):
|
|
203
|
+
aid = clip.get("asset")
|
|
204
|
+
asset = assets.get(aid, {})
|
|
205
|
+
dur = _clip_dur(clip, def_dur)
|
|
206
|
+
fit = clip.get("fit", "cover")
|
|
207
|
+
if asset.get("type") == "image" or clip.get("type") == "image":
|
|
208
|
+
idx = add_input(["-loop", "1", "-t", f"{dur}"], asset.get("src", clip.get("src", "")))
|
|
209
|
+
filters.append(f"[{idx}:v]{_fit(W, H, fit, FPS)}[v{i}]")
|
|
210
|
+
elif asset.get("type") == "video":
|
|
211
|
+
idx = add_input([], asset.get("src", ""))
|
|
212
|
+
s = clip.get("start", 0)
|
|
213
|
+
trim = f"trim=start={s}:end={s + dur},setpts=PTS-STARTPTS,"
|
|
214
|
+
filters.append(f"[{idx}:v]{trim}{_fit(W, H, fit, FPS)}[v{i}]")
|
|
215
|
+
else:
|
|
216
|
+
notes.append(f"clip {i}: unsupported type (need asset of type image/video)")
|
|
217
|
+
continue
|
|
218
|
+
segs.append(f"[v{i}]")
|
|
219
|
+
durs.append(dur)
|
|
220
|
+
|
|
221
|
+
transitions = spec.get("transitions", [])
|
|
222
|
+
tdur0 = float(transitions[0].get("duration", 0.5)) if transitions else 0.0
|
|
223
|
+
video_dur = (sum(durs) - tdur0 * (len(segs) - 1)) if (transitions and len(segs) > 1) else sum(durs)
|
|
224
|
+
if len(segs) == 1:
|
|
225
|
+
filters.append(f"{segs[0]}copy[vbase]")
|
|
226
|
+
elif transitions:
|
|
227
|
+
# sequential crossfade; offset = cumulative shown time - transition dur
|
|
228
|
+
tdur = float(transitions[0].get("duration", 0.5))
|
|
229
|
+
tname = transitions[0].get("type", "fade")
|
|
230
|
+
if tname in ("crossfade",):
|
|
231
|
+
tname = "fade"
|
|
232
|
+
prev, off = segs[0], 0.0
|
|
233
|
+
for i in range(1, len(segs)):
|
|
234
|
+
off += durs[i - 1] - tdur
|
|
235
|
+
label = "[vbase]" if i == len(segs) - 1 else f"[vx{i}]"
|
|
236
|
+
filters.append(f"{prev}{segs[i]}xfade=transition={tname}:duration={tdur}:offset={off}{label}")
|
|
237
|
+
prev = label
|
|
238
|
+
notes.append(f"crossfade '{tname}' {tdur}s between all clips (first transition's settings)")
|
|
239
|
+
else:
|
|
240
|
+
filters.append(f"{''.join(segs)}concat=n={len(segs)}:v=1:a=0[vbase]")
|
|
241
|
+
|
|
242
|
+
# --- overlays (image / text / captions) ---
|
|
243
|
+
cur = "[vbase]"
|
|
244
|
+
step = 0
|
|
245
|
+
for t in overlays:
|
|
246
|
+
for clip in t.get("clips", []):
|
|
247
|
+
nxt = f"[vo{step}]"
|
|
248
|
+
pos = float(clip.get("position", 0))
|
|
249
|
+
dur = _clip_dur(clip, def_dur)
|
|
250
|
+
en = f"enable='between(t,{pos},{pos + dur})'"
|
|
251
|
+
if clip.get("effects"):
|
|
252
|
+
notes.append("overlay effects/keyframes (opacity/zoom) not compiled; shown at full opacity")
|
|
253
|
+
ctype = clip.get("type")
|
|
254
|
+
if ctype == "text":
|
|
255
|
+
st = clip.get("style", {})
|
|
256
|
+
rect = clip.get("rect", {})
|
|
257
|
+
x = _px(rect.get("x", "10%"), W)
|
|
258
|
+
y = _px(rect.get("y", "80%"), H)
|
|
259
|
+
txt = str(clip.get("text", "")).replace(":", r"\:").replace("'", "’")
|
|
260
|
+
box = f":box=1:boxcolor={st['box']}:boxborderw=12" if st.get("box") else ""
|
|
261
|
+
dt = (f"drawtext=text='{txt}':x={x}:y={y}:fontsize={st.get('size',48)}:"
|
|
262
|
+
f"fontcolor={st.get('color','#FFFFFF')}{box}:{en}")
|
|
263
|
+
filters.append(f"{cur}{dt}{nxt}")
|
|
264
|
+
elif ctype == "captions":
|
|
265
|
+
src = clip.get("src", "")
|
|
266
|
+
filters.append(f"{cur}subtitles={src}{nxt}")
|
|
267
|
+
elif assets.get(clip.get("asset"), {}).get("type") == "image":
|
|
268
|
+
asset = assets[clip["asset"]]
|
|
269
|
+
rect = clip.get("rect", {})
|
|
270
|
+
ow = _px(rect.get("w", "15%"), W)
|
|
271
|
+
idx = add_input(["-loop", "1"], asset.get("src", ""))
|
|
272
|
+
filters.append(f"[{idx}:v]scale={ow}:-1[ov{step}]")
|
|
273
|
+
x = _px(rect.get("x", "80%"), W)
|
|
274
|
+
y = _px(rect.get("y", "5%"), H)
|
|
275
|
+
filters.append(f"{cur}[ov{step}]overlay={x}:{y}:{en}:eof_action=pass{nxt}")
|
|
276
|
+
else:
|
|
277
|
+
notes.append(f"overlay clip of type {ctype!r} not compiled")
|
|
278
|
+
continue
|
|
279
|
+
cur = nxt
|
|
280
|
+
step += 1
|
|
281
|
+
filters.append(f"{cur}format=yuv420p[vout]")
|
|
282
|
+
|
|
283
|
+
# --- audio: mix audio[] tracks with gain + optional loudnorm ---
|
|
284
|
+
aud = spec.get("audio", [])
|
|
285
|
+
alabels = []
|
|
286
|
+
for i, tr in enumerate(aud):
|
|
287
|
+
asset = assets.get(tr.get("asset"), {})
|
|
288
|
+
if not asset.get("src"):
|
|
289
|
+
continue
|
|
290
|
+
idx = add_input([], asset["src"])
|
|
291
|
+
chain = f"[{idx}:a]"
|
|
292
|
+
pos = float(tr.get("position", 0))
|
|
293
|
+
if pos > 0:
|
|
294
|
+
ms = int(pos * 1000)
|
|
295
|
+
chain += f"adelay={ms}|{ms},"
|
|
296
|
+
gain = tr.get("gain", 0)
|
|
297
|
+
if gain:
|
|
298
|
+
chain += f"volume={gain}dB,"
|
|
299
|
+
if tr.get("ducking"):
|
|
300
|
+
notes.append("audio ducking (sidechain) not compiled; set music gain lower instead")
|
|
301
|
+
chain = chain.rstrip(",") + f"[a{i}]"
|
|
302
|
+
filters.append(chain)
|
|
303
|
+
alabels.append(f"[a{i}]")
|
|
304
|
+
have_audio = bool(alabels)
|
|
305
|
+
if have_audio:
|
|
306
|
+
if len(alabels) == 1:
|
|
307
|
+
filters.append(f"{alabels[0]}aresample=async=1[amix]")
|
|
308
|
+
else:
|
|
309
|
+
filters.append(f"{''.join(alabels)}amix=inputs={len(alabels)}:duration=longest[amix]")
|
|
310
|
+
norm = next((t for t in aud if isinstance(t, dict)), {}) # master normalize lives on audio? use output
|
|
311
|
+
tgt = (spec.get("audio_normalize") or {}).get("I", -14)
|
|
312
|
+
filters.append(f"[amix]loudnorm=I={tgt}:TP=-1.5:LRA=11[aout]")
|
|
313
|
+
|
|
314
|
+
fc = ";".join(filters)
|
|
315
|
+
cmd = PREFIX + inputs + ["-filter_complex", fc, "-map", "[vout]"]
|
|
316
|
+
if have_audio:
|
|
317
|
+
cmd += ["-map", "[aout]", "-shortest", "-c:a", "aac", "-b:a", "128k"]
|
|
318
|
+
cmd += ["-t", f"{round(video_dur, 3)}", "-r", str(FPS)] + MP4_OUT + [outfile]
|
|
319
|
+
for n in notes:
|
|
320
|
+
print(f"# NOTE: {n}")
|
|
321
|
+
return emit(cmd, a.run)
|
|
322
|
+
|
|
323
|
+
|
|
145
324
|
def c_presets(a):
|
|
146
325
|
print("Channel aspect presets (use with `social --aspect <name>`):")
|
|
147
326
|
for name, (w, h) in SOCIAL.items():
|
|
@@ -205,6 +384,11 @@ def main(argv=None):
|
|
|
205
384
|
th.add_argument("--at", default="00:00:03"); th.add_argument("--smart", action="store_true")
|
|
206
385
|
th.set_defaults(fn=c_thumb)
|
|
207
386
|
|
|
387
|
+
cp = sub.add_parser("compile", help="compile a timeline-model JSON into one ffmpeg command")
|
|
388
|
+
cp.add_argument("--spec", required=True, help="timeline JSON (video-timeline-model.md)")
|
|
389
|
+
cp.add_argument("--output", help="override the output path from the spec")
|
|
390
|
+
cp.set_defaults(fn=c_compile)
|
|
391
|
+
|
|
208
392
|
sub.add_parser("presets", help="list channel aspect presets").set_defaults(fn=c_presets)
|
|
209
393
|
|
|
210
394
|
a = ap.parse_args(argv)
|
package/package.json
CHANGED
|
@@ -120,6 +120,7 @@ map onto xfade's transition list.
|
|
|
120
120
|
```bash
|
|
121
121
|
maggie tool maggie_video.py social --input in.mp4 --output reel.mp4 --aspect reel
|
|
122
122
|
maggie tool maggie_video.py gif --input in.mp4 --output out.gif --fps 15 --width 480
|
|
123
|
+
maggie tool maggie_video.py compile --spec timeline.json # declarative timeline -> one command
|
|
123
124
|
maggie tool maggie_video.py --run encode --input in.mov --output out.mp4 # actually runs
|
|
124
125
|
maggie tool maggie_video.py presets
|
|
125
126
|
```
|
|
@@ -93,6 +93,23 @@ Compile the model to one `filter_complex`:
|
|
|
93
93
|
`mifi/editly` (MIT) and `Zulko/moviepy` (MIT) are working prior art that this JSON
|
|
94
94
|
shape renders through ffmpeg without any GPL engine.
|
|
95
95
|
|
|
96
|
+
### maggie_video.py compile
|
|
97
|
+
|
|
98
|
+
`maggie_video.py compile --spec timeline.json` compiles this model into one ffmpeg
|
|
99
|
+
`filter_complex` command (printed; run with `--run`). Supported today: a main video
|
|
100
|
+
track of clips (video/image) fit `cover`/`contain` to the canvas, hard-cut `concat`
|
|
101
|
+
or sequential `crossfade` (from `transitions`), image/text/caption overlays with
|
|
102
|
+
`position`+`duration` timing and `rect` placement, and an `audio[]` mix with
|
|
103
|
+
per-track `position`/`gain` plus `loudnorm`. Output is bounded to the computed video
|
|
104
|
+
duration and uses the shared web-safe profile. Not compiled yet (emitted as
|
|
105
|
+
`# NOTE:` lines): keyframes, ken-burns, and sidechain ducking - set static values or
|
|
106
|
+
use a programmatic engine for those.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
maggie tool maggie_video.py compile --spec timeline.json # print the command
|
|
110
|
+
maggie tool maggie_video.py --run compile --spec timeline.json # render it
|
|
111
|
+
```
|
|
112
|
+
|
|
96
113
|
## Optional higher-fidelity backend: melt (GPL, external)
|
|
97
114
|
|
|
98
115
|
The same model can emit **MLT XML** and render with
|