kaizen-agent 1.49.0 → 1.49.1
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/cli/hermes.ts +5 -2
- package/cli/state.test.ts +13 -0
- package/cli/state.ts +12 -0
- package/cli/versions.test.ts +154 -0
- package/cli/versions.ts +272 -0
- package/cli/video.test.ts +64 -3
- package/cli/video.ts +111 -18
- package/cli/web.ts +15 -0
- package/package.json +1 -1
- package/skills/media/kaizen-video/SKILL.md +20 -2
- package/skills/media/kaizen-video/canvas.html +241 -0
- package/skills/media/kaizen-video/examples/canvas-film/cat.txt +31 -0
- package/skills/media/kaizen-video/examples/canvas-film/film.json +460 -0
- package/skills/media/kaizen-video/examples/canvas-film/lines.json +10 -0
- package/skills/media/kaizen-video/examples/canvas-film/skip.txt +18 -0
- package/skills/media/kaizen-video/examples/canvas-film/talk.txt +23 -0
- package/skills/media/kaizen-video/examples/canvas-film/wow.txt +24 -0
- package/skills/media/kaizen-video/examples/kaizen-promo/promo.json +17 -0
- package/skills/media/kaizen-video/examples/kaizen-promo/record.json +10 -0
- package/skills/media/kaizen-video/examples/notula-promo/promo.json +41 -0
- package/skills/media/kaizen-video/examples/notula-promo/record.json +135 -0
- package/skills/media/kaizen-video/examples/notula-promo/seed.php +20 -0
- package/skills/media/kaizen-video/examples/notula-promo/seed.py +38 -0
- package/skills/media/kaizen-video/presets/app-promo/CREDITS.txt +2 -0
- package/skills/media/kaizen-video/presets/app-promo/README.md +21 -0
- package/skills/media/kaizen-video/presets/app-promo/preset.json +7 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/end.html +25 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/hook.html +19 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/name.html +19 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/step.html +52 -0
- package/skills/media/kaizen-video/presets/app-promo/template/index.html +24 -0
- package/skills/media/kaizen-video/presets/film-cinematic-drama/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/CREDITS.txt +3 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/README.md +7 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/fonts/InstrumentSerif.ttf +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/fonts/SpaceMono.ttf +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/boing.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/ding.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/ending.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/pop.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/reveal.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/shutter.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/stamp.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/tick.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/whoosh.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/style.json +15 -0
- package/skills/media/kaizen-video/presets/film-fun-energetic/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-promo-booth/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-viral-social/.hidden +1 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/index.html +1 -1
- package/skills/media/kaizen-video/references/canvas.md +60 -0
- package/skills/media/kaizen-video/references/presets.md +31 -0
- package/skills/media/kaizen-video/references/promo.md +148 -0
- package/skills/media/kaizen-video/references/revisions.md +11 -2
- package/skills/media/kaizen-video/scripts/make_film.py +157 -4
- package/skills/media/kaizen-video/scripts/make_promo.py +297 -0
- package/skills/media/kaizen-video/scripts/make_tiktok.py +34 -6
- package/skills/media/kaizen-video/scripts/pixel.py +40 -0
- package/skills/media/kaizen-video/scripts/record.mjs +103 -0
- package/web/board.html +1 -1
- package/web/board.js +1 -1
- package/web/notebook.js +1 -1
- package/web/term.js +1 -1
- package/web/video.html +43 -9
- package/web/video.js +67 -56
- package/web/video.ts +266 -33
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Product promos: template presets (app-promo)
|
|
2
|
+
|
|
3
|
+
A **template preset** is a whole HyperFrames film that fills itself from a product brief. It is used when
|
|
4
|
+
the user wants a video about their product: an app, a website, a tool. The first template preset is
|
|
5
|
+
`app-promo`, made from the kaizen launch video the user approved on 2026-10-26.
|
|
6
|
+
|
|
7
|
+
An app-promo video has these parts, in order:
|
|
8
|
+
- a two-second hook;
|
|
9
|
+
- the product's name;
|
|
10
|
+
- the product used for real, one task per step, each step with one caption, tap marks and camera
|
|
11
|
+
punch-ins;
|
|
12
|
+
- an end card with the logo, the tagline and the call to action.
|
|
13
|
+
|
|
14
|
+
Everything on screen is the real product. Nothing is mocked up.
|
|
15
|
+
|
|
16
|
+
A template preset is a folder with `preset.json` (`"kind": "template"`), a `template/` HyperFrames project,
|
|
17
|
+
`README.md` and `CREDITS.txt`. The Video page lists it for a from-scratch start.
|
|
18
|
+
|
|
19
|
+
## 1. Learn the product, write the brief
|
|
20
|
+
|
|
21
|
+
Read the product before asking anything:
|
|
22
|
+
- its site or README;
|
|
23
|
+
- its `manifest.webmanifest`, for name, description and theme colour;
|
|
24
|
+
- its logo files and CSS colours.
|
|
25
|
+
|
|
26
|
+
Ask only what you cannot find:
|
|
27
|
+
- where it runs;
|
|
28
|
+
- a safe account;
|
|
29
|
+
- the tasks worth showing.
|
|
30
|
+
|
|
31
|
+
Then write `videos/<name>/promo.json`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"product": "Notula", "url": "notula.huseinf.my.id",
|
|
36
|
+
"tagline": "Record & Summarize", "cta": "notula.huseinf.my.id",
|
|
37
|
+
"hook": ["You talked", "for an hour.", "Now what?"],
|
|
38
|
+
"brand": { "logo": "logo.png", "bg": "#f4f3ff", "ink": "#16133a", "accent": "#4b44cf", "font": "Inter" },
|
|
39
|
+
"music": "sunny",
|
|
40
|
+
"steps": [
|
|
41
|
+
{ "clip": "list-web", "with": "list", "caption": "Every meeting, / *recorded.*", "from": 0.3, "to": 4.2 },
|
|
42
|
+
{ "clip": "meeting", "caption": "Who said what, / *transcribed.*", "from": 0.5, "to": 8.6 }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- **Words.** Tagline, CTA and claims use the product's own words. The hook can be a line of yours, but it
|
|
48
|
+
makes no claim. Captions:
|
|
49
|
+
- hold at most 6 words;
|
|
50
|
+
- break lines with `/`;
|
|
51
|
+
- mark the one accent word with `*word*`.
|
|
52
|
+
|
|
53
|
+
Say each idea once: no caption repeats another.
|
|
54
|
+
- **Brand.** It comes from the product:
|
|
55
|
+
- its theme colour as the accent;
|
|
56
|
+
- its background, or the logo's ground, as `bg`;
|
|
57
|
+
- its ink.
|
|
58
|
+
|
|
59
|
+
A light brand gets a light ground; the device frames follow it.
|
|
60
|
+
- **Devices follow where the product runs.** Each step shows its clip's device:
|
|
61
|
+
- a phone for a mobile app or PWA;
|
|
62
|
+
- a browser window with the real URL for a web app;
|
|
63
|
+
- a titled window for a native desktop app, which needs the user's own recording.
|
|
64
|
+
|
|
65
|
+
`"with"` puts a second clip of the same task on another device beside it: laptop and phone together,
|
|
66
|
+
for a product that runs on both. Use it once, early, to say "everywhere". Then stay on the device where
|
|
67
|
+
the task reads best.
|
|
68
|
+
|
|
69
|
+
## 2. Record
|
|
70
|
+
|
|
71
|
+
Write `videos/<name>/record.json`. Each clip lists its device and its steps:
|
|
72
|
+
|
|
73
|
+
- `["tap", "text:Label" | css]`
|
|
74
|
+
- `["type", css, "words"]`
|
|
75
|
+
- `["key", "Enter"]`
|
|
76
|
+
- `["scroll", px]`
|
|
77
|
+
- `["wait", ms]`
|
|
78
|
+
- `["goto", "/path"]`
|
|
79
|
+
- `"prep"`: steps run before filming starts, such as a sign-in. Clips share one browser, so sign in on the
|
|
80
|
+
first clip only.
|
|
81
|
+
|
|
82
|
+
Then run:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
node $S/record.mjs videos/<name> # writes rec/<clip>.mp4 + rec/<clip>.json (device, taps)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Privacy:** everything on screen is filmed. Never point the recorder at a real account with real data.
|
|
89
|
+
|
|
90
|
+
| Product | What to do |
|
|
91
|
+
|---|---|
|
|
92
|
+
| has a demo account | use it |
|
|
93
|
+
| open-source or in ~/Projects | run a local copy with its own empty database and seed sample data made for the video |
|
|
94
|
+
| kaizen itself | a sandboxed board: `HOME=<scratch>/home` with `projects`/`projects_dir` pointing at a scratch copy of `.kaizen` |
|
|
95
|
+
|
|
96
|
+
Watch out for a local copy:
|
|
97
|
+
- **Laravel:** delete `bootstrap/cache/config.php` before any `artisan` command, or it still points at the
|
|
98
|
+
real database.
|
|
99
|
+
- **Check the database first:** confirm the copy's own database path
|
|
100
|
+
(`php artisan tinker --execute 'echo config("database.connections.sqlite.database");'`) before writing
|
|
101
|
+
anything.
|
|
102
|
+
- **Sample content:** content made for the video (demo meetings, sample cards) is illustrative. Say so in
|
|
103
|
+
the delivery note.
|
|
104
|
+
|
|
105
|
+
For a native app the recorder cannot drive, put the user's screen recording at `rec/<clip>.mp4` and write
|
|
106
|
+
`rec/<clip>.json` yourself: `{"device": "phone"|"app", "cssW", "cssH", "seconds", "taps": []}`.
|
|
107
|
+
|
|
108
|
+
## 3. Build, look, render
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
python3 $S/make_promo.py videos/<name> # project in videos/<name>/promo/, check, promo/check/sheet.jpg
|
|
112
|
+
python3 $S/make_promo.py videos/<name> --render # output/<name>/app-promo/<name>.mp4 + CREDITS.txt, -14 LUFS
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Pick each step's `from`/`to` from the tap times in `rec/<clip>.json`. A step starts just before its first
|
|
116
|
+
tap and ends after the UI has answered.
|
|
117
|
+
|
|
118
|
+
Look at `promo/check/sheet.jpg` before rendering. Check for:
|
|
119
|
+
- captions clear of the device;
|
|
120
|
+
- each step's screen showing what its caption says;
|
|
121
|
+
- no private data;
|
|
122
|
+
- no repeated idea.
|
|
123
|
+
|
|
124
|
+
Punch-ins are automatic: on each tap the UI then has time to act on. Set `"punch": []` on a step to turn
|
|
125
|
+
them off, or give your own list.
|
|
126
|
+
|
|
127
|
+
## 4. Adding the next approved preset
|
|
128
|
+
|
|
129
|
+
A new look becomes a preset only after the user approves a video made with it:
|
|
130
|
+
|
|
131
|
+
1. Agree a reference with the user: a HyperFrames showcase film or any video they like. Study it frame by
|
|
132
|
+
frame.
|
|
133
|
+
2. Make one real video in that look with the `/hyperframes` skill workflow:
|
|
134
|
+
- `SPEC.md`;
|
|
135
|
+
- one scene per sub-composition;
|
|
136
|
+
- real material;
|
|
137
|
+
- `hyperframes check`;
|
|
138
|
+
- a snapshot review.
|
|
139
|
+
|
|
140
|
+
Revise until the user says it meets their standard.
|
|
141
|
+
3. Turn the approved project into `presets/<name>/template/`:
|
|
142
|
+
- replace its product text, colours and media with placeholders the build step fills;
|
|
143
|
+
- add `preset.json` and `CREDITS.txt`;
|
|
144
|
+
- add a build script, or extend `make_promo.py` when the scene contract is the same.
|
|
145
|
+
4. Build it on a second product before listing it. A look that only works for one product is not a preset
|
|
146
|
+
yet.
|
|
147
|
+
|
|
148
|
+
Unapproved presets carry a `.hidden` file: they still build, but the New video wizard does not offer them.
|
|
@@ -17,9 +17,18 @@ Clients revise. Make every revision cheap, traceable and reversible.
|
|
|
17
17
|
Never regenerate all narration for a one-line change: voices vary between takes and credits cost money.
|
|
18
18
|
|
|
19
19
|
## Versioning
|
|
20
|
-
-
|
|
20
|
+
- Renders still land in `output/<name>/<preset>/<name>.mp4`. The kaizen board then files each one as a
|
|
21
|
+
**version** (a, b, c…) under `output/<name>/versions/<letter>/<n>/`. Next to it goes its **recipe**, a
|
|
22
|
+
copy of the video folder's small files (film.json or config.json, lines, words, voice lines,
|
|
23
|
+
pictures, transcript JSON), in `videos/<name>/versions/<letter>/<n>/`. Do not move or rename these
|
|
24
|
+
folders by hand.
|
|
25
|
+
- `videos/<name>/versions.json` says which version the draft is revising (`revising`).
|
|
26
|
+
- When it is set, the user picked that version on the Video page, and its recipe is in the draft. Keep
|
|
27
|
+
its preset. Your render becomes that version's **try**, which the user keeps or reverts on the page.
|
|
28
|
+
- When it is unset, a render becomes a new version.
|
|
21
29
|
- Append to `videos/<name>/REVISIONS.md`: date, the user's words verbatim, what changed, output file.
|
|
22
|
-
-
|
|
30
|
+
- A rejected revision is reverted on the Video page, not re-rendered. Older renders sit in each version's
|
|
31
|
+
history there.
|
|
23
32
|
|
|
24
33
|
## Before re-delivering
|
|
25
34
|
Re-check stills of the beats that changed, master, and say exactly what changed and what did not.
|
|
@@ -11,6 +11,14 @@ film.json: "preset" (a folder under presets/ with a style.json, e.g. film-cinema
|
|
|
11
11
|
("9x16" default, "16x9", or "4x5" for an Instagram feed post), "beats", "brand", "labels", "cta", "logo", "qr", "music" (a bundled track name;
|
|
12
12
|
without it videos/<name>/music.mp3 is used). The preset is found in ./presets/, $KAIZEN_VIDEO_PRESETS
|
|
13
13
|
(default ~/.kaizen/video-presets/), then the skill's presets/, like make_tiktok.py.
|
|
14
|
+
"style" overrides keys of the preset's style.json for this film (a dict merges into the preset's, e.g.
|
|
15
|
+
{"pace": {"lead": 0, "tail": 0}}). A footage preset (a folder with index.html) works too: the film is
|
|
16
|
+
rendered once with no captions and no music, then make_tiktok.py styles that video like recorded footage
|
|
17
|
+
(videos/<name>/footage-bridge/; film.json "hook" {"line1", "line2", "sub"} sets its hook, else the first words).
|
|
18
|
+
The film's scenes become the template's (title, stat as a big numeral, question as "?", items as item rows, cta as
|
|
19
|
+
end), each at the start of its line; film.json "footage_beats" (template beats, placed with "t" seconds or "word")
|
|
20
|
+
replaces that mapping, "mascot" (a picture in the video folder) adds the template's corner mascot, and a beat's "pics"
|
|
21
|
+
(pictures in the video folder) feed the picture scenes after its headline. The clip card is hidden (no real footage).
|
|
14
22
|
--format overrides film.json's format for one build and adds -<format> to the output name, so one film can be
|
|
15
23
|
rendered for several shapes (the Video page in kaizen web does this) without one render replacing another.
|
|
16
24
|
"""
|
|
@@ -44,11 +52,23 @@ LANG = film.get("language", "id")
|
|
|
44
52
|
dirs = [WORK / "presets", Path(os.environ.get("KAIZEN_VIDEO_PRESETS", Path.home() / ".kaizen/video-presets")), SKILL / "presets"]
|
|
45
53
|
want = film["preset"]
|
|
46
54
|
preset = next((d / n for n in (want, "film-" + want) for d in dirs if (d / n / "style.json").exists()), None)
|
|
55
|
+
# A footage preset: build pass 1 in a plain base style with no captions, no music and no cut sounds; it is styled after.
|
|
56
|
+
footage = None if preset else next((d / want for d in dirs if (d / want / "index.html").exists()), None)
|
|
57
|
+
if footage:
|
|
58
|
+
if fmt != "9x16" and forced: # the Video page renders every shape the platforms need; this one has no other shape
|
|
59
|
+
print(f"skipped {fmt}: footage preset {want!r} is 9:16 only")
|
|
60
|
+
sys.exit(0)
|
|
61
|
+
if fmt != "9x16":
|
|
62
|
+
sys.exit(f"footage preset {want!r} is 9:16 only; set film.json format to 9x16")
|
|
63
|
+
preset = next(d / "film-viral-social" for d in dirs if (d / "film-viral-social" / "style.json").exists())
|
|
47
64
|
if not preset:
|
|
48
65
|
names = sorted({p.parent.name for d in dirs if d.exists() for p in d.glob("*/style.json")})
|
|
49
66
|
sys.exit(f"preset {want!r} not found in {', '.join(map(str, dirs))}; available: {', '.join(names)}")
|
|
50
67
|
print(f"preset {preset}")
|
|
51
68
|
style = json.loads((preset / "style.json").read_text())
|
|
69
|
+
over = {**film.get("style", {}), **({"captions": "none", "music": {"base": 0, "lift": 0}, "sfx": {"cut": "", "text": "", "reveal": "", "question": ""}} if footage else {})}
|
|
70
|
+
for k, v in over.items():
|
|
71
|
+
style[k] = {**style.get(k, {}), **v} if isinstance(v, dict) else v
|
|
52
72
|
brand = film.get("brand", {})
|
|
53
73
|
style["palette"] = {**style["palette"], **brand.get("palette", {})}
|
|
54
74
|
style["fonts"] = {**style["fonts"], **brand.get("fonts", {})}
|
|
@@ -68,6 +88,10 @@ def run(*cmd, cwd=proj):
|
|
|
68
88
|
|
|
69
89
|
|
|
70
90
|
# 2. Timeline: every beat is lead + its voice line + tail (+ hold), in whole frames, one after another.
|
|
91
|
+
canvas = style.get("engine") == "canvas" # a canvas film: one large canvas and a camera (canvas.html, references/canvas.md)
|
|
92
|
+
if canvas:
|
|
93
|
+
for b in film["beats"]:
|
|
94
|
+
b.setdefault("kind", "canvas")
|
|
71
95
|
t, beats = 0, []
|
|
72
96
|
for n, b in enumerate(film["beats"]):
|
|
73
97
|
v = b.get("vo")
|
|
@@ -97,6 +121,13 @@ def stage(name, sub):
|
|
|
97
121
|
return f"assets/{sub}/{flat}"
|
|
98
122
|
|
|
99
123
|
|
|
124
|
+
scenes = []
|
|
125
|
+
if footage:
|
|
126
|
+
# Pass 1 carries pictures only: the footage template draws the words, from these scenes.
|
|
127
|
+
scenes = [dict(b) for b in beats]
|
|
128
|
+
keep = ("n", "start", "len", "dur", "vo", "hold", "ambience", "sfx", "img", "video", "shotRatio")
|
|
129
|
+
beats = [{**{k: b[k] for k in keep if k in b}, "kind": b["kind"] if b["kind"] in ("footage", "shot") else "media",
|
|
130
|
+
**({"img": b["panels"][0]["img"]} if b.get("panels") and not b.get("img") else {})} for b in beats]
|
|
100
131
|
for b in beats:
|
|
101
132
|
b["img"], b["video"] = stage(b.get("img"), "img"), stage(b.get("video"), "video")
|
|
102
133
|
if b.get("panels"):
|
|
@@ -125,12 +156,13 @@ def groups(ws):
|
|
|
125
156
|
return out
|
|
126
157
|
|
|
127
158
|
|
|
128
|
-
captions, cues = [], []
|
|
159
|
+
captions, cues, spoken = [], [], []
|
|
129
160
|
for b in beats:
|
|
130
161
|
if not b.get("vo"):
|
|
131
162
|
continue
|
|
132
163
|
t0 = b["start"] + pace["lead"]
|
|
133
164
|
ws = [{"w": w["w"], "s": round(t0 + w["s"], 3), "e": round(t0 + w["e"], 3)} for w in words[b["vo"]]["words"]]
|
|
165
|
+
spoken += ws
|
|
134
166
|
cues += [[c[0]["s"], c[-1]["e"] + 0.2, " ".join(w["w"] for w in c)] for c in chunks(ws)]
|
|
135
167
|
if b["kind"] == "cta" or style["captions"] == "none":
|
|
136
168
|
continue
|
|
@@ -143,8 +175,34 @@ for a, c in zip(cues, cues[1:]):
|
|
|
143
175
|
proj.mkdir(exist_ok=True)
|
|
144
176
|
(proj / "cues.json").write_text(json.dumps(cues, ensure_ascii=False))
|
|
145
177
|
|
|
178
|
+
# A canvas film's pictures, and its actions' times: "at" is seconds from the beat's start, or "word:<w>" the moment
|
|
179
|
+
# the beat's first word starting with <w> is spoken.
|
|
180
|
+
CANVAS_SFX = {"move": "whoosh", "pop": "pop", "stamp": "stamp", "scrub": "tick", "morph": "shutter", "fill": "reveal"}
|
|
181
|
+
if canvas:
|
|
182
|
+
if fmt != "9x16" or not film.get("canvas"):
|
|
183
|
+
sys.exit("a canvas preset needs film.json \"canvas\" (see references/canvas.md) and the 9x16 format")
|
|
184
|
+
for e in film["canvas"]["elements"]:
|
|
185
|
+
if e.get("img"):
|
|
186
|
+
e["img"] = stage(e["img"], "img")
|
|
187
|
+
for fr in e.get("frames", []):
|
|
188
|
+
if fr.get("img"):
|
|
189
|
+
fr["img"] = stage(fr["img"], "img")
|
|
190
|
+
for b in beats:
|
|
191
|
+
bw = [{"w": w["w"], "s": b["start"] + pace["lead"] + w["s"]} for w in words[b["vo"]]["words"]] if b.get("vo") else []
|
|
192
|
+
for a in b.get("do", []):
|
|
193
|
+
at = a.get("at", 0)
|
|
194
|
+
if isinstance(at, str) and at.startswith("word:"):
|
|
195
|
+
key = at[5:].lower()
|
|
196
|
+
hit = next((w["s"] for w in bw if w["w"].lower().strip(",.?!\"'").startswith(key)), None)
|
|
197
|
+
if hit is None:
|
|
198
|
+
sys.exit(f"beat {b['n'] + 1}: no word starting with {key!r} for {a}")
|
|
199
|
+
a["t"] = round(hit, 3)
|
|
200
|
+
else:
|
|
201
|
+
a["t"] = round(b["start"] + float(at), 3)
|
|
202
|
+
|
|
146
203
|
film_data = {"fmt": fmt, "W": W, "H": H, "language": LANG, "style": style, "labels": labels, "total": total, "beats": beats, "captions": captions,
|
|
147
|
-
"cta": film.get("cta"), "logo": stage(film.get("logo"), "img"), "logoOnLight": stage(film.get("logoOnLight"), "img"), "qr": stage(film.get("qr"), "img")
|
|
204
|
+
"cta": film.get("cta"), "logo": stage(film.get("logo"), "img"), "logoOnLight": stage(film.get("logoOnLight"), "img"), "qr": stage(film.get("qr"), "img"),
|
|
205
|
+
**({"canvas": film["canvas"], "mascot": stage(film.get("mascot"), "img")} if canvas else {})}
|
|
148
206
|
(proj / "film-data.js").write_text("window.FILM = " + json.dumps(film_data, ensure_ascii=False) + ";\n")
|
|
149
207
|
|
|
150
208
|
# 5. Audio: the voice lines on one track, the music bed with the style's levels, sound effects and room tone.
|
|
@@ -167,6 +225,8 @@ music = style["music"]
|
|
|
167
225
|
track = vdir / music["track"]
|
|
168
226
|
if film.get("music"):
|
|
169
227
|
track = SKILL / "assets/music" / f"{film['music']}.mp3"
|
|
228
|
+
if footage and not track.exists(): # pass 1 is silent music; any bundled track will do
|
|
229
|
+
track = SKILL / "assets/music/sunny.mp3"
|
|
170
230
|
if not track.exists():
|
|
171
231
|
sys.exit(f"no music: put {music['track']} in {vdir} (scripts/music.sh) or set film.json \"music\" to one of: "
|
|
172
232
|
+ ", ".join(sorted(p.stem for p in (SKILL / "assets/music").glob("*.mp3"))))
|
|
@@ -200,6 +260,10 @@ for i, b in enumerate(beats):
|
|
|
200
260
|
if cut:
|
|
201
261
|
sfx.append((sound(cut), b["start"], 0.7 if b["kind"] == "reveal" else 0.35))
|
|
202
262
|
sfx += [(sound(s), b["start"] + pace["lead"], 0.45) for s in b.get("sfx", [])]
|
|
263
|
+
for a in b.get("do", []) if canvas else []: # each camera action carries its sound, unless "sfx": "" turns it off
|
|
264
|
+
name = a.get("sfx", CANVAS_SFX.get(a["act"], ""))
|
|
265
|
+
if name:
|
|
266
|
+
sfx.append((sound(name), a["t"] + (0.35 if a["act"] == "stamp" else 0), a.get("vol", 0.4)))
|
|
203
267
|
if fx["text"] and b.get("title") and i:
|
|
204
268
|
sfx.append((sound(fx["text"]), b["start"] + pace["lead"] + 0.2, 0.25))
|
|
205
269
|
if b.get("ambience"):
|
|
@@ -235,7 +299,7 @@ for fam in sorted(fonts):
|
|
|
235
299
|
faces.append(f'@font-face {{ font-family: "{fam}"; src: url("assets/fonts/{src.name}"); font-weight: 100 900; font-style: {slant}; }}')
|
|
236
300
|
elif not suffix:
|
|
237
301
|
sys.exit(f"font {fam!r} not found: add {stem}.ttf to the preset's assets/fonts or the skill's assets/film-fonts")
|
|
238
|
-
page = (SKILL / "film.html").read_text()
|
|
302
|
+
page = (SKILL / ("canvas.html" if canvas else "film.html")).read_text()
|
|
239
303
|
for k, v in {"W": W, "H": H, "RES": RES, "DURATION": total, "LANG": LANG}.items():
|
|
240
304
|
page = page.replace("{{" + k + "}}", str(v))
|
|
241
305
|
page = page.replace("/*FONTS*/", "\n ".join(faces)).replace("<!-- AUDIO -->", audio)
|
|
@@ -259,5 +323,94 @@ credits += [f.read_text().strip() for f in (preset / "CREDITS.txt",) if f.exists
|
|
|
259
323
|
credits.append("Voice and sound effects: see the voice provider in film.json (ElevenLabs commercial use requires a paid plan).")
|
|
260
324
|
(proj / "CREDITS.txt").write_text("\n\n".join(credits) + "\n")
|
|
261
325
|
(proj / "meta.json").write_text(json.dumps({"name": name, "folder": film.get("name", vdir.name), "preset": preset.name, "loudness": style["loudness"]}))
|
|
262
|
-
if
|
|
326
|
+
if footage:
|
|
327
|
+
# ponytail: pass 1 renders on every build, so a footage preset's build takes a render longer; cache it if that hurts.
|
|
328
|
+
tmp = proj / ".render-tmp"
|
|
329
|
+
tmp.mkdir(exist_ok=True)
|
|
330
|
+
subprocess.run(["npx", "--yes", HF, "render", "--crf", "16", "-o", str(proj / "pass1.mp4")], check=True, cwd=proj, env={**os.environ, "TMPDIR": str(tmp)})
|
|
331
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
332
|
+
shutil.rmtree(proj / "renders", ignore_errors=True)
|
|
333
|
+
bridge = vdir / "footage-bridge"
|
|
334
|
+
bridge.mkdir(exist_ok=True)
|
|
335
|
+
(bridge / "words.json").write_text(json.dumps({"segments": [{"words": [{"word": w["w"], "start": w["s"], "end": w["e"]} for w in spoken]}]}, ensure_ascii=False))
|
|
336
|
+
# The film's scenes as the template's, paced like an explainer (or film.json "footage_beats" as written):
|
|
337
|
+
# each scene opens on a headline scene, then picture scenes change at its phrase breaks, about every 2 s.
|
|
338
|
+
(bridge / "images").mkdir(exist_ok=True)
|
|
339
|
+
|
|
340
|
+
def copy_pic(name, staged=None):
|
|
341
|
+
src = proj / staged if staged else next((f for f in (vdir / name, vdir / f"{Path(name).stem}-9x16.jpg") if f.exists()), None)
|
|
342
|
+
if not src:
|
|
343
|
+
sys.exit(f"picture {name!r} not found in {vdir}")
|
|
344
|
+
shutil.copy(src, bridge / "images" / src.name)
|
|
345
|
+
return src.name
|
|
346
|
+
|
|
347
|
+
def headline(text):
|
|
348
|
+
if len(text) > 14: # the template shrinks longer headlines to unreadable sizes
|
|
349
|
+
print(f"warning: headline {text!r} is over 14 characters; shown as the serif line instead")
|
|
350
|
+
return "", text
|
|
351
|
+
return text.upper(), ""
|
|
352
|
+
|
|
353
|
+
mapped, cursor = [], 3.2 # the hook holds the first 3 s
|
|
354
|
+
for i, s in enumerate(scenes):
|
|
355
|
+
start, end = max(s["start"] + pace["lead"], cursor), s["start"] + s["len"]
|
|
356
|
+
if end - start < 0.8:
|
|
357
|
+
continue
|
|
358
|
+
cursor = end
|
|
359
|
+
if s["kind"] == "cta":
|
|
360
|
+
c = film.get("cta") or {}
|
|
361
|
+
mapped.append({"kind": "end", "t": round(start, 3), "title": s.get("title") or c.get("title", ""), "sub": c.get("url") or c.get("sub", "") or s.get("sub", "")})
|
|
362
|
+
continue
|
|
363
|
+
if s.get("items"):
|
|
364
|
+
mapped += [{"kind": "item", "t": round(start + 0.3 + (end - start - 0.6) * k / len(s["items"]), 3), "label": f"{k + 1:02d}", "text": it,
|
|
365
|
+
**({"head": s["title"]} if k == 0 and s.get("title") else {})} for k, it in enumerate(s["items"])]
|
|
366
|
+
continue
|
|
367
|
+
pics = ([copy_pic(beats[i]["img"], beats[i]["img"])] if beats[i].get("img") else []) + [copy_pic(n) for n in s.get("pics", [])]
|
|
368
|
+
head = {"kind": "title", "t": round(start, 3), "kicker": s.get("kick", "")}
|
|
369
|
+
if s["kind"] == "stat" and s.get("stat"):
|
|
370
|
+
st = s["stat"][0]
|
|
371
|
+
head["title"], long = headline(st.get("suffix", "").strip())
|
|
372
|
+
head.update(big=str(st["value"]), sub=" ".join(x for x in (long, st.get("label", "")) if x))
|
|
373
|
+
elif s["kind"] == "question":
|
|
374
|
+
head.update(big="?", sub=s.get("title", ""))
|
|
375
|
+
else:
|
|
376
|
+
head["title"], long = headline(s.get("title", ""))
|
|
377
|
+
head["sub"] = long or s.get("sub", "")
|
|
378
|
+
# Phrase breaks after the headline: a word that starts 1.6 s or more after the last break, sooner at punctuation.
|
|
379
|
+
cuts, last, prev = [], start + min(2.2, end - start), {"w": "-"}
|
|
380
|
+
for w in (w for w in spoken if last + 0.3 < w["s"] < end - 0.8):
|
|
381
|
+
if w["s"] - last >= 2.4 or (w["s"] - last >= 1.6 and prev["w"][-1] in ",.?!;:"):
|
|
382
|
+
cuts.append(w["s"])
|
|
383
|
+
last = w["s"]
|
|
384
|
+
prev = w
|
|
385
|
+
if not pics: # nothing to show between headlines: the headline holds the whole scene
|
|
386
|
+
mapped.append({**head, "dur": round(end - start, 3)})
|
|
387
|
+
continue
|
|
388
|
+
stops = [start + min(2.2, end - start)] + cuts + [end]
|
|
389
|
+
# No picture holds longer than 2.5 s: split a long gap evenly where no phrase break fell.
|
|
390
|
+
stops = [round(a + (b - a) * k / -(-(b - a) // 2.5), 3) for a, b in zip(stops, stops[1:]) for k in range(int(-(-(b - a) // 2.5)))] + [end]
|
|
391
|
+
mapped.append({**head, "dur": round(stops[0] - start, 3), "img": pics[0]})
|
|
392
|
+
mapped += [{"kind": "photo", "t": round(a, 3), "dur": round(b - a, 3), "img": pics[(k + 1) % len(pics)]} for k, (a, b) in enumerate(zip(stops, stops[1:])) if b - a > 0.5]
|
|
393
|
+
first = next((b["img"] for b in mapped if b.get("img")), None)
|
|
394
|
+
if first: # something to look at under the hook
|
|
395
|
+
mapped.insert(0, {"kind": "photo", "t": 0.2, "dur": 2.95, "img": first})
|
|
396
|
+
if film.get("mascot"):
|
|
397
|
+
mapped.append({"kind": "mascot", "t": 0.3, "img": copy_pic(film["mascot"])})
|
|
398
|
+
fb = film.get("footage_beats", mapped)
|
|
399
|
+
for b in film.get("footage_beats", []):
|
|
400
|
+
if b.get("img"):
|
|
401
|
+
copy_pic(b["img"])
|
|
402
|
+
first = [w["w"] for w in spoken]
|
|
403
|
+
hook = film.get("hook") or {"line1": " ".join(first[:3]).upper(), "line2": " ".join(first[3:6]).upper(), "sub": ""}
|
|
404
|
+
own = [f.read_text().strip() for f in [vdir / "CREDITS.txt", *sorted(vdir.glob("CREDITS-*.txt"))] if f.exists()]
|
|
405
|
+
if own: # make_tiktok.py puts the video's own credits first in the render's CREDITS.txt
|
|
406
|
+
(bridge / "CREDITS.txt").write_text("\n\n".join(own) + "\n")
|
|
407
|
+
# One plan segment per scene, back to back over the whole film: the template treats each as a jump cut
|
|
408
|
+
# (card tilt, lists leave), and the last one keeps the tail after the last word.
|
|
409
|
+
(bridge / "plan.json").write_text(json.dumps({"segments": [{"start_time": b["start"], "end_time": b["start"] + b["len"]} for b in beats]}))
|
|
410
|
+
(bridge / "config.json").write_text(json.dumps({"name": film.get("name", vdir.name), "preset": want, "video": str(proj / "pass1.mp4"),
|
|
411
|
+
"words": str(bridge / "words.json"), "plan": str(bridge / "plan.json"), "hook": hook, "music": film.get("music", "sunny"),
|
|
412
|
+
"beats": fb, "card": False, "tail": 1.5 if any(b.get("kind") == "end" for b in fb) else 0}, ensure_ascii=False, indent=1))
|
|
413
|
+
print(f"footage preset {want}: styling pass 1 with make_tiktok.py")
|
|
414
|
+
run("python3", str(SKILL / "scripts/make_tiktok.py"), str(bridge), *(["--render"] if "--render" in sys.argv else []), cwd=WORK)
|
|
415
|
+
elif "--render" in sys.argv:
|
|
263
416
|
run("bash", str(SKILL / "scripts/master.sh"), str(vdir), cwd=WORK)
|