kaizen-agent 1.48.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/README.md +2 -2
- package/cli/build-web.ts +4 -2
- package/cli/hermes.ts +68 -0
- package/cli/install.ts +18 -5
- package/cli/localsend.test.ts +84 -0
- package/cli/localsend.ts +131 -0
- package/cli/notes.test.ts +6 -4
- package/cli/settings.ts +1 -0
- package/cli/state.test.ts +50 -0
- package/cli/state.ts +47 -20
- package/cli/versions.test.ts +154 -0
- package/cli/versions.ts +272 -0
- package/cli/video.test.ts +540 -0
- package/cli/video.ts +600 -0
- package/cli/web.ts +142 -1
- package/package.json +1 -1
- package/skills/kaizen/config.default.yml +4 -0
- package/skills/media/kaizen-book/SKILL.md +107 -0
- package/skills/media/kaizen-book/assets/reader.html +440 -0
- package/skills/media/kaizen-book/assets/styles.json +45 -0
- package/skills/media/kaizen-book/examples/book.json +14 -0
- package/skills/media/kaizen-book/examples/images/reach.svg +1 -0
- package/skills/media/kaizen-book/examples/manuscript.md +127 -0
- package/skills/media/kaizen-book/references/interview.md +85 -0
- package/skills/media/kaizen-book/references/proofread.md +47 -0
- package/skills/media/kaizen-book/references/writing.md +53 -0
- package/skills/media/kaizen-book/scripts/build_book.py +279 -0
- package/skills/media/kaizen-book/scripts/check.sh +10 -0
- package/skills/media/kaizen-book/scripts/check_book.py +128 -0
- package/skills/media/kaizen-book/scripts/deploy.py +58 -0
- package/skills/media/kaizen-book/scripts/pdf.mjs +99 -0
- package/skills/media/kaizen-book/scripts/setup.sh +9 -0
- package/skills/media/kaizen-book/scripts/verify.mjs +95 -0
- package/skills/{story-deck → media/kaizen-deck}/SKILL.md +1 -1
- package/skills/{story-deck → media/kaizen-deck}/scripts/check.sh +1 -1
- package/skills/{story-deck → media/kaizen-deck}/scripts/install_fonts.py +2 -2
- package/skills/media/kaizen-video/SKILL.md +130 -0
- package/skills/{kaizen-video → media/kaizen-video}/assets/CREDITS.txt +5 -0
- package/skills/media/kaizen-video/assets/film-fonts/Fraunces.ttf +0 -0
- package/skills/media/kaizen-video/assets/film-fonts/Inter.ttf +0 -0
- package/skills/media/kaizen-video/assets/film-fonts/PlayfairDisplay-Italic.ttf +0 -0
- package/skills/media/kaizen-video/assets/film-fonts/PlayfairDisplay.ttf +0 -0
- 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/examples/sample-film/README.md +10 -0
- package/skills/media/kaizen-video/examples/sample-film/film.json +63 -0
- package/skills/media/kaizen-video/film.html +246 -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-cinematic-drama/CREDITS.txt +1 -0
- package/skills/media/kaizen-video/presets/film-cinematic-drama/README.md +2 -0
- package/skills/media/kaizen-video/presets/film-cinematic-drama/style.json +39 -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-fun-energetic/CREDITS.txt +1 -0
- package/skills/media/kaizen-video/presets/film-fun-energetic/README.md +2 -0
- package/skills/media/kaizen-video/presets/film-fun-energetic/style.json +39 -0
- package/skills/media/kaizen-video/presets/film-promo-booth/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-promo-booth/CREDITS.txt +1 -0
- package/skills/media/kaizen-video/presets/film-promo-booth/README.md +2 -0
- package/skills/media/kaizen-video/presets/film-promo-booth/style.json +39 -0
- package/skills/media/kaizen-video/presets/film-viral-social/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-viral-social/CREDITS.txt +1 -0
- package/skills/media/kaizen-video/presets/film-viral-social/README.md +2 -0
- package/skills/media/kaizen-video/presets/film-viral-social/style.json +39 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/CREDITS.txt +3 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/README.md +52 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/fonts/InstrumentSerif.ttf +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/fonts/SpaceMono.ttf +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/boing.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/ding.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/ending.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/pop.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/reveal.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/shutter.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/stamp.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/tick.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/assets/sfx/whoosh.wav +0 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/index.html +272 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/package.json +10 -0
- package/skills/media/kaizen-video/references/canvas.md +60 -0
- package/skills/media/kaizen-video/references/presets.md +107 -0
- package/skills/{story-video → media/kaizen-video}/references/production.md +2 -2
- package/skills/media/kaizen-video/references/promo.md +148 -0
- package/skills/media/kaizen-video/references/revisions.md +34 -0
- package/skills/media/kaizen-video/scripts/__pycache__/intake.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/make_film.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/make_tiktok.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/render_cut.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/sfx.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/srt.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/transcribe.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/vo.cpython-314.pyc +0 -0
- package/skills/{kaizen-video → media/kaizen-video}/scripts/check.sh +8 -0
- package/skills/{story-video → media/kaizen-video}/scripts/intake.py +2 -2
- package/skills/media/kaizen-video/scripts/make_film.py +416 -0
- package/skills/media/kaizen-video/scripts/make_promo.py +297 -0
- package/skills/{kaizen-video → media/kaizen-video}/scripts/make_tiktok.py +42 -9
- package/skills/{story-video → media/kaizen-video}/scripts/master.sh +12 -11
- package/skills/media/kaizen-video/scripts/pixel.py +40 -0
- package/skills/media/kaizen-video/scripts/record.mjs +103 -0
- package/skills/{story-video → media/kaizen-video}/scripts/sfx.py +3 -3
- package/skills/media/kaizen-video/scripts/srt.py +9 -0
- package/skills/media/kaizen-video/scripts/still.sh +7 -0
- package/web/board/views.ts +1 -1
- package/web/board.html +3 -1
- package/web/board.js +2 -2
- package/web/notebook.js +1 -1
- package/web/notes.html +2 -0
- package/web/term.js +1 -1
- package/web/video.html +332 -0
- package/web/video.js +92 -0
- package/web/video.ts +843 -0
- package/skills/kaizen-video/SKILL.md +0 -73
- package/skills/kaizen-video/references/presets.md +0 -54
- package/skills/story-video/SKILL.md +0 -108
- package/skills/story-video/engine/package.json +0 -12
- package/skills/story-video/engine/src/Root.tsx +0 -24
- package/skills/story-video/engine/src/engine/Film.tsx +0 -405
- package/skills/story-video/engine/src/engine/presets.json +0 -58
- package/skills/story-video/engine/src/index.ts +0 -3
- package/skills/story-video/engine/tsconfig.json +0 -1
- package/skills/story-video/examples/sample-film/README.md +0 -12
- package/skills/story-video/examples/sample-film/film.json +0 -16
- package/skills/story-video/references/presets.md +0 -21
- package/skills/story-video/references/revisions.md +0 -25
- package/skills/story-video/scripts/check.sh +0 -19
- package/skills/story-video/scripts/setup.sh +0 -25
- package/skills/story-video/scripts/srt.py +0 -30
- package/skills/story-video/scripts/still.sh +0 -10
- /package/skills/{story-deck → media/kaizen-deck}/examples/build-example.js +0 -0
- /package/skills/{story-deck → media/kaizen-deck}/references/rules.md +0 -0
- /package/skills/{story-deck → media/kaizen-deck}/references/story-arc.md +0 -0
- /package/skills/{story-deck → media/kaizen-deck}/scripts/kit.js +0 -0
- /package/skills/{story-deck → media/kaizen-deck}/scripts/prep_images.py +0 -0
- /package/skills/{story-deck → media/kaizen-deck}/scripts/qa.sh +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/assets/fonts/Fredoka.ttf +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/assets/fonts/Montserrat.ttf +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/assets/fonts/SpecialElite.ttf +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/assets/music/investigations.mp3 +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/assets/music/lights.mp3 +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/assets/music/sunny.mp3 +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/examples/config.json +0 -0
- /package/skills/{story-video → media/kaizen-video}/examples/sample-film/lines.json +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/hyperframes.json +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/CREDITS.txt +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/README.md +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/assets/sfx/ending.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/assets/sfx/reveal.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/assets/sfx/shutter.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/assets/sfx/stamp.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/index.html +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/educational-warning/package.json +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/CREDITS.txt +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/README.md +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/boing.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/chime.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/ding.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/ending.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/pop.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/reveal.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/shutter.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/stamp.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/assets/sfx/whoosh.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/index.html +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-cheerful/package.json +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/CREDITS.txt +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/README.md +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/clock.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/ding.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/ending.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/heart.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/projector.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/reveal.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/shutter.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/stamp.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/assets/sfx/whoosh.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/index.html +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-mystery/package.json +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/CREDITS.txt +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/README.md +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/clock.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/ding.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/ending.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/heart.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/reveal.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/shutter.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/stamp.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/assets/sfx/whoosh.wav +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/index.html +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/presets/tiktok-scam-alert/package.json +0 -0
- /package/skills/{story-video → media/kaizen-video}/references/licensing.md +0 -0
- /package/skills/{story-video → media/kaizen-video}/references/script.md +0 -0
- /package/skills/{story-video → media/kaizen-video}/scripts/music.sh +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/scripts/render_cut.py +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/scripts/setup.sh +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/scripts/transcribe.py +0 -0
- /package/skills/{story-video → media/kaizen-video}/scripts/vo.py +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/tools/carve.mjs +0 -0
- /package/skills/{kaizen-video → media/kaizen-video}/tools/lib/main-module.mjs +0 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"""Build (and optionally render) an app-promo video: a product filmed in use, framed in its own devices.
|
|
2
|
+
|
|
3
|
+
python3 scripts/make_promo.py videos/<name> [--render]
|
|
4
|
+
|
|
5
|
+
Run from the project folder. videos/<name>/ holds promo.json (the brief, references/promo.md) and rec/,
|
|
6
|
+
the recordings from record.mjs (or the user's screen recordings with a rec/<clip>.json beside them).
|
|
7
|
+
Writes the HyperFrames project into videos/<name>/promo/, runs `hyperframes check` and snapshots one frame
|
|
8
|
+
per step into promo/check/; with --render it renders, levels the sound to -14 LUFS (true peak -1.5 dBTP)
|
|
9
|
+
and writes output/<name>/<preset>/<name>.mp4 with CREDITS.txt.
|
|
10
|
+
|
|
11
|
+
promo.json: "preset" (default app-promo), "product", "tagline", "cta", "hook" (2-3 lines; the last word
|
|
12
|
+
lands in the accent), "brand" {"logo", "bg", "ink", "accent", "muted", "font"}, "music" (a bundled track
|
|
13
|
+
name, or "none"), "steps": [{"clip", "caption" (*word* is the accent), "from", "to" (seconds of the clip),
|
|
14
|
+
"with" (a second clip on another device, shown together), "punch" ([] for none, or [{"at", "x", "y",
|
|
15
|
+
"zoom", "hold"}] in clip seconds and CSS px)}].
|
|
16
|
+
"""
|
|
17
|
+
import html
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import re
|
|
21
|
+
import shutil
|
|
22
|
+
import subprocess
|
|
23
|
+
import sys
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
HF = "hyperframes@0.8.176"
|
|
27
|
+
SKILL = Path(__file__).resolve().parent.parent
|
|
28
|
+
|
|
29
|
+
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
|
30
|
+
if not args:
|
|
31
|
+
sys.exit(__doc__)
|
|
32
|
+
vdir = Path(args[0])
|
|
33
|
+
render = "--render" in sys.argv
|
|
34
|
+
brief = json.loads((vdir / "promo.json").read_text())
|
|
35
|
+
want = brief.get("preset", "app-promo")
|
|
36
|
+
if not re.fullmatch(r"[A-Za-z0-9][\w.-]*", want) or ".." in want:
|
|
37
|
+
sys.exit(f"preset {want!r}: a folder name, not a path")
|
|
38
|
+
dirs = [Path("presets"), Path(os.environ.get("KAIZEN_VIDEO_PRESETS", Path.home() / ".kaizen/video-presets")), SKILL / "presets"]
|
|
39
|
+
preset = next((d / want for d in dirs if (d / want / "preset.json").exists()), None)
|
|
40
|
+
if not preset:
|
|
41
|
+
sys.exit(f"template preset {want!r} not found (a folder with preset.json)")
|
|
42
|
+
name = vdir.name
|
|
43
|
+
proj = vdir / "promo"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def safe(n, what):
|
|
47
|
+
"""A file name from the brief: inside the video folder, never absolute or with '..'."""
|
|
48
|
+
if not n or Path(n).is_absolute() or ".." in Path(n).parts:
|
|
49
|
+
sys.exit(f"{what} {n!r}: give a name inside {vdir}, not a path out of it")
|
|
50
|
+
return n
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def clip(c):
|
|
54
|
+
safe(c, "clip")
|
|
55
|
+
meta = vdir / "rec" / f"{c}.json"
|
|
56
|
+
if not meta.exists() or not (vdir / "rec" / f"{c}.mp4").exists():
|
|
57
|
+
sys.exit(f"clip {c!r}: rec/{c}.mp4 and rec/{c}.json are needed (record.mjs makes both)")
|
|
58
|
+
return json.loads(meta.read_text())
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ---- Brand
|
|
62
|
+
B = brief.get("brand", {})
|
|
63
|
+
bg, ink, accent = B.get("bg", "#0c162f"), B.get("ink", "#eef2fa"), B.get("accent", "#6d8cff")
|
|
64
|
+
font = B.get("font", "Inter")
|
|
65
|
+
dark = int(bg.lstrip("#")[:2], 16) + int(bg.lstrip("#")[2:4], 16) + int(bg.lstrip("#")[4:6], 16) < 384
|
|
66
|
+
css = f""":root {{ --bg: {bg}; --ink: {ink}; --accent: {accent}; --font: "{font}";
|
|
67
|
+
--muted: {B.get("muted", f"color-mix(in srgb, {ink} 62%, {bg})")}; --dim: color-mix(in srgb, {ink} 22%, {bg});
|
|
68
|
+
--bezel: color-mix(in srgb, {ink} {14 if dark else 80}%, {bg}); --bezel-edge: color-mix(in srgb, {ink} {24 if dark else 30}%, {bg}); }}"""
|
|
69
|
+
esc = html.escape
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def words(text, last_id=None):
|
|
73
|
+
"""Words as spans; *word* is the accent; "/" breaks the line."""
|
|
74
|
+
out = []
|
|
75
|
+
for line in text.split("/"):
|
|
76
|
+
ws = line.split()
|
|
77
|
+
out.append(" ".join(f"<span>{'<b>' + esc(w.strip('*')) + '</b>' if w.startswith('*') else esc(w)}</span>" for w in ws))
|
|
78
|
+
s = "<br />".join(out)
|
|
79
|
+
if last_id:
|
|
80
|
+
s = re.sub(r"<span>([^<]*)</span>$", rf'<span id="{last_id}">\1</span>', s)
|
|
81
|
+
return s
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def fit(text, size, width=1000):
|
|
85
|
+
return int(min(size, width / max(1, len(text) * 0.58)))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# ---- Device geometry (9:16 frame, 1080 x 1920). Screens keep the recording's aspect.
|
|
89
|
+
def frames(step, sid):
|
|
90
|
+
"""HTML for the step's device(s), with its clips and tap marks; returns (html, taps, points)."""
|
|
91
|
+
a = clip(step["clip"])
|
|
92
|
+
b = clip(step["with"]) if step.get("with") else None
|
|
93
|
+
t0, t1 = step.get("from", 0), step.get("to", a["seconds"])
|
|
94
|
+
dur = t1 - t0
|
|
95
|
+
parts, taps, points, conv = [], [], [], []
|
|
96
|
+
|
|
97
|
+
def device(c, meta, box, small=False):
|
|
98
|
+
kind = meta["device"]
|
|
99
|
+
x, y, w = box
|
|
100
|
+
if kind == "tablet": # a phone-style bezel, as wide as the frame's height allows (screen at most 1388 tall)
|
|
101
|
+
sw = min(w - 28, round(1388 * meta["cssW"] / meta["cssH"]))
|
|
102
|
+
w = sw + 28
|
|
103
|
+
x, y = (1080 - w) // 2, 440
|
|
104
|
+
if kind in ("phone", "tablet"):
|
|
105
|
+
sw = w - 28
|
|
106
|
+
sh = round(sw * meta["cssH"] / meta["cssW"])
|
|
107
|
+
ox, oy, k = x + 14, y + 14, sw / meta["cssW"]
|
|
108
|
+
body = (f'<div class="s-phone" style="left:{x}px;top:{y}px;width:{w}px;height:{sh + 28}px">'
|
|
109
|
+
f'<div class="scr" style="width:{sw}px;height:{sh}px">')
|
|
110
|
+
else:
|
|
111
|
+
sh = round(w * meta["cssH"] / meta["cssW"])
|
|
112
|
+
ox, oy, k = x, y + 64, w / meta["cssW"]
|
|
113
|
+
# A web product sits in a browser with its real URL; a native app ("app": the user's recording) in a titled window.
|
|
114
|
+
bar = (f'<i></i><i></i><i></i><span class="ttl">{esc(brief.get("product", ""))}</span>' if kind == "app"
|
|
115
|
+
else f'<i></i><i></i><i></i><span class="url">{esc(brief.get("url", ""))}</span>')
|
|
116
|
+
body = (f'<div class="s-win" style="left:{x}px;top:{y}px;width:{w}px"><div class="bar">{bar}</div>'
|
|
117
|
+
f'<div class="scr" style="width:{w}px;height:{sh}px">')
|
|
118
|
+
conv.append((ox, oy, k))
|
|
119
|
+
vid = f"{sid}-{c}"
|
|
120
|
+
body += (f'<video id="{vid}" class="clip" src="assets/rec/{c}.mp4" muted playsinline data-start="0" '
|
|
121
|
+
f'data-duration="{dur:.3f}" data-media-start="{t0:.3f}" data-track-index="0"></video>')
|
|
122
|
+
for i, tp in enumerate(m for m in meta["taps"] if t0 <= m["t"] < t1):
|
|
123
|
+
tid = f"{vid}-t{i}"
|
|
124
|
+
body += f'<div class="s-tap{" sm" if small else ""}" id="{tid}" style="left:{tp["x"] * k:.0f}px;top:{tp["y"] * k:.0f}px"></div>'
|
|
125
|
+
taps.append([tid, round(tp["t"] - t0, 3)])
|
|
126
|
+
points.append((tp["t"] - t0, ox + tp["x"] * k, oy + tp["y"] * k, kind))
|
|
127
|
+
return body + "</div></div>"
|
|
128
|
+
|
|
129
|
+
if b: # duo: the window large, the phone overlapping at the bottom right, both playing the same task
|
|
130
|
+
win, ph = (a, b) if a["device"] != "phone" else (b, a)
|
|
131
|
+
wc, pc = (step["clip"], step["with"]) if a is win else (step["with"], step["clip"])
|
|
132
|
+
parts.append(device(wc, win, (30, 470, 900)))
|
|
133
|
+
parts.append(device(pc, ph, (690, 860, 360), small=True))
|
|
134
|
+
elif a["device"] == "phone":
|
|
135
|
+
parts.append(device(step["clip"], a, (206, 440, 668)))
|
|
136
|
+
else:
|
|
137
|
+
parts.append(device(step["clip"], a, (40, 560, 1000)))
|
|
138
|
+
# CSS px -> frame px for hand-placed punch-ins: the step's one device, or the phone of a duo (drawn last).
|
|
139
|
+
return f'<div id="{sid}-dev">{"".join(parts)}</div>', taps, points, dur, a["device"] if not b else "duo", conv[-1]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def punches(step, points, dur, dev, conv):
|
|
143
|
+
"""Punch in on a tap when the UI then has time to act (the next tap is 1.6 s or more away).
|
|
144
|
+
With two devices on screen only the phone's taps lead, and gently, so the window stays in frame."""
|
|
145
|
+
if "punch" in step:
|
|
146
|
+
ox, oy, k = conv # x/y are CSS px of the step's clip, like the tap log
|
|
147
|
+
return [[p["at"] - step.get("from", 0), round(ox + p["x"] * k), round(oy + p["y"] * k), p.get("zoom", 1.35), p.get("hold", 2.0)] for p in step["punch"]]
|
|
148
|
+
if dev == "duo":
|
|
149
|
+
points = [p for p in points if p[3] == "phone"]
|
|
150
|
+
out, pts = [], sorted(points)
|
|
151
|
+
for i, (t, x, y, kind) in enumerate(pts):
|
|
152
|
+
nxt = pts[i + 1][0] if i + 1 < len(pts) else dur
|
|
153
|
+
gap = nxt - t
|
|
154
|
+
if gap < 1.6 or t < 0.3:
|
|
155
|
+
continue
|
|
156
|
+
z = 1.18 if dev == "duo" else 1.3 if kind == "phone" else 1.7
|
|
157
|
+
out.append([round(t + 0.1, 3), round(x), round(y), z, round(min(2.4, gap - 1.2), 2)])
|
|
158
|
+
return out
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# ---- Project
|
|
162
|
+
shutil.rmtree(proj, ignore_errors=True)
|
|
163
|
+
shutil.copytree(preset / "template", proj)
|
|
164
|
+
(proj / "assets/rec").mkdir(parents=True, exist_ok=True)
|
|
165
|
+
(proj / "assets/sfx").mkdir(parents=True, exist_ok=True)
|
|
166
|
+
for f in (vdir / "rec").glob("*.mp4"):
|
|
167
|
+
shutil.copy(f, proj / "assets/rec" / f.name)
|
|
168
|
+
for f in (SKILL / "presets/tiktok-explainer/assets/sfx").glob("*.wav"):
|
|
169
|
+
shutil.copy(f, proj / "assets/sfx" / f.name)
|
|
170
|
+
mark = ""
|
|
171
|
+
if B.get("logo"):
|
|
172
|
+
src = vdir / safe(B["logo"], "brand logo")
|
|
173
|
+
if not src.exists():
|
|
174
|
+
sys.exit(f"brand logo {B['logo']!r} not found in {vdir}")
|
|
175
|
+
shutil.copy(src, proj / "assets" / ("logo" + src.suffix))
|
|
176
|
+
mark = f'<div id="end-mark"><img src="assets/logo{src.suffix}" alt="" /></div>'
|
|
177
|
+
|
|
178
|
+
comp = proj / "compositions"
|
|
179
|
+
step_tpl = (comp / "step.html").read_text()
|
|
180
|
+
(comp / "step.html").unlink()
|
|
181
|
+
product, tagline, cta = brief.get("product", name), brief.get("tagline", ""), brief.get("cta", "")
|
|
182
|
+
hook = brief.get("hook", [])
|
|
183
|
+
hook_text = " / ".join(hook)
|
|
184
|
+
fill = {"HOOK_HTML": words(hook_text, "hook-last"), "HOOK_SIZE": fit(max(hook, key=len) if hook else "x", 150, 900),
|
|
185
|
+
"NAME": esc(product), "NAME_SIZE": fit(product, 230), "END_SIZE": fit(product, 168), "TAGLINE": esc(tagline),
|
|
186
|
+
"CTA": esc(cta), "MARK": mark}
|
|
187
|
+
for f in ("hook.html", "name.html", "end.html"):
|
|
188
|
+
s = (comp / f).read_text()
|
|
189
|
+
for k, v in fill.items():
|
|
190
|
+
s = s.replace("{{" + k + "}}", str(v))
|
|
191
|
+
(comp / f).write_text(s)
|
|
192
|
+
|
|
193
|
+
scenes, sfx, t = [], [], 0.0
|
|
194
|
+
if hook:
|
|
195
|
+
scenes.append(("hook", 0.0, 2.4)); sfx.append(("whoosh", 2.2)); t = 2.4
|
|
196
|
+
scenes.append(("name", t, 1.8)); sfx.append(("whoosh", t + 1.6)); t += 1.8
|
|
197
|
+
prev_dev = None
|
|
198
|
+
steps = brief["steps"]
|
|
199
|
+
for i, st in enumerate(steps):
|
|
200
|
+
sid = f"step{i + 1}"
|
|
201
|
+
body, taps, points, dur, dev, conv = frames(st, sid)
|
|
202
|
+
top = min(int(m) for m in re.findall(r'class="s-(?:phone|win)" style="left:\d+px;top:(\d+)px', body))
|
|
203
|
+
data = {"id": sid, "taps": taps, "punches": punches(st, points, dur, dev, conv), "rise": dev != prev_dev, "dur": round(dur, 3), "last": False, "top": top}
|
|
204
|
+
s = (step_tpl.replace("{{ID}}", sid).replace("{{CAPTION}}", words(st["caption"])).replace("{{FRAMES}}", body)
|
|
205
|
+
.replace("/*DATA*/{}", json.dumps(data)))
|
|
206
|
+
(comp / f"{sid}.html").write_text(s)
|
|
207
|
+
scenes.append((sid, t, dur))
|
|
208
|
+
if dev != prev_dev and prev_dev:
|
|
209
|
+
sfx.append(("whoosh", t - 0.15))
|
|
210
|
+
for k, (_, tt) in enumerate(taps):
|
|
211
|
+
sfx.append(("tick" if k % 2 == 0 else "pop", t + tt - 0.03))
|
|
212
|
+
prev_dev = dev
|
|
213
|
+
t += dur
|
|
214
|
+
scenes.append(("end", t, 3.4)); sfx.append(("reveal", t + 0.05))
|
|
215
|
+
total = round(t + 3.4, 3)
|
|
216
|
+
|
|
217
|
+
music = brief.get("music", "sunny")
|
|
218
|
+
audio = ""
|
|
219
|
+
if music != "none":
|
|
220
|
+
track = SKILL / "assets/music" / f"{music}.mp3"
|
|
221
|
+
if not track.exists():
|
|
222
|
+
sys.exit(f"music {music!r} not found in assets/music")
|
|
223
|
+
shutil.copy(track, proj / "assets/music.mp3")
|
|
224
|
+
audio += f' <audio id="music" src="assets/music.mp3" data-start="0" data-duration="{total}" data-track-index="2" data-volume="0.55" data-fade-out="1.5"></audio>\n'
|
|
225
|
+
for i, (snd, at) in enumerate(sfx):
|
|
226
|
+
d = {"whoosh": 0.6, "tick": 0.06, "pop": 0.18, "reveal": 0.6}[snd]
|
|
227
|
+
audio += f' <audio id="sfx{i}" src="assets/sfx/{snd}.wav" data-start="{max(0, at):.3f}" data-duration="{d}" data-track-index="3" data-volume="0.8"></audio>\n'
|
|
228
|
+
hosts = "\n".join(
|
|
229
|
+
f' <div id="{sid}" data-composition-id="{sid}" data-composition-src="compositions/{sid}.html" data-start="{st:.3f}" '
|
|
230
|
+
f'data-duration="{d:.3f}" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>'
|
|
231
|
+
for sid, st, d in scenes)
|
|
232
|
+
page = (proj / "index.html").read_text()
|
|
233
|
+
for k, v in {"CSS": css, "DURATION": total, "SCENES": hosts, "AUDIO": audio, "LANG": brief.get("language", "en")}.items():
|
|
234
|
+
page = page.replace("{{" + k + "}}", str(v))
|
|
235
|
+
(proj / "index.html").write_text(page)
|
|
236
|
+
|
|
237
|
+
# SPEC.md: the brief as numbers, for whoever opens the project in HyperFrames Studio.
|
|
238
|
+
spec = [f"GOAL: a viewer sees {product} do {len(steps)} real tasks and knows where to get it ({cta}).",
|
|
239
|
+
f"OUTPUT: HyperFrames, 1080 x 1920, 30 fps; {total} s; preset {preset.name}",
|
|
240
|
+
f"LOOK: ground {bg}, ink {ink}, accent {accent} (one word per caption, the hook's last word, the CTA); {font} 900",
|
|
241
|
+
"MOTION: arrivals expo.out 0.5-0.7 s; camera power2.inOut 0.5 s; captions blur 6px->0, 0.067 s apart, dead still after landing",
|
|
242
|
+
"SHOTS:"] + [f" {sid} {st:.1f}-{st + d:.1f}" for sid, st, d in scenes] + [
|
|
243
|
+
"BANNED: invented UI; glow, grain, particles; breathing loops; fade-and-slide-up; text outside 168-1330 px; a repeated claim"]
|
|
244
|
+
(proj / "SPEC.md").write_text("\n".join(spec) + "\n")
|
|
245
|
+
print(f"preset {preset}\n{len(steps)} steps, {len(sfx)} sounds, {total}s -> {proj}")
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def run(*cmd, **kw):
|
|
249
|
+
return subprocess.run(cmd, cwd=proj, **kw)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
chk = run("npx", "--yes", HF, "check", capture_output=True, text=True)
|
|
253
|
+
print("\n".join(l for l in chk.stdout.splitlines() if "✗" in l or "Check" in l))
|
|
254
|
+
if chk.returncode:
|
|
255
|
+
sys.exit("hyperframes check failed; see above")
|
|
256
|
+
at = ",".join(f"{st + min(d * 0.6, d - 0.2):.2f}" for sid, st, d in scenes)
|
|
257
|
+
snap = run("npx", "--yes", HF, "snapshot", "--at", at, capture_output=True, text=True)
|
|
258
|
+
m = re.search(r"(\S*contact-sheet[^\s]*\.jpg)", snap.stdout)
|
|
259
|
+
if m:
|
|
260
|
+
(proj / "check").mkdir(exist_ok=True)
|
|
261
|
+
shutil.copy(proj / m.group(1) if not m.group(1).startswith("/") else m.group(1), proj / "check/sheet.jpg")
|
|
262
|
+
print(f"snapshots: {proj / 'check/sheet.jpg'}")
|
|
263
|
+
if not render:
|
|
264
|
+
sys.exit(0)
|
|
265
|
+
|
|
266
|
+
out = Path("output") / name / preset.name
|
|
267
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
268
|
+
raw, final = proj / "render.mp4", out / f"{name}.mp4"
|
|
269
|
+
tmp = proj / ".render-tmp"
|
|
270
|
+
tmp.mkdir(exist_ok=True)
|
|
271
|
+
run("npx", "--yes", HF, "render", "--crf", "18", "-o", str(raw.resolve()), check=True, env={**os.environ, "TMPDIR": str(tmp)})
|
|
272
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def loud(f):
|
|
276
|
+
r = subprocess.run(["ffmpeg", "-i", str(f), "-af", "ebur128=peak=true", "-f", "null", "-"], capture_output=True, text=True).stderr
|
|
277
|
+
i = float(re.findall(r"I:\s+(-?[\d.]+) LUFS", r)[-1])
|
|
278
|
+
p = float(re.findall(r"Peak:\s+(-?[\d.]+) dBFS", r)[-1])
|
|
279
|
+
return i, p
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# Gain to -14 LUFS, then a limiter for the true peak; one correction pass if the limiter cost loudness.
|
|
283
|
+
gain = -14 - loud(raw)[0]
|
|
284
|
+
for _ in range(2):
|
|
285
|
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(raw), "-c:v", "copy", "-af",
|
|
286
|
+
f"volume={gain:.2f}dB,alimiter=limit=0.6:level=false:attack=1:release=60", "-ar", "48000", "-c:a", "aac", "-b:a", "192k", str(final)], check=True)
|
|
287
|
+
i, p = loud(final)
|
|
288
|
+
if abs(i + 14) <= 0.6:
|
|
289
|
+
break
|
|
290
|
+
gain += -14 - i
|
|
291
|
+
print(f"loudness {i} LUFS, true peak {p} dBTP")
|
|
292
|
+
credits = [f.read_text().strip() for f in (vdir / "CREDITS.txt", preset / "CREDITS.txt") if f.exists()]
|
|
293
|
+
if music != "none":
|
|
294
|
+
m2 = re.search(rf"^- {re.escape(music)}\.mp3: (.+)$", (SKILL / "assets/CREDITS.txt").read_text(), re.M)
|
|
295
|
+
credits.append("Music: " + (m2.group(1) if m2 else music))
|
|
296
|
+
(out / "CREDITS.txt").write_text("\n\n".join(credits) + "\n")
|
|
297
|
+
print(f"rendered {final}")
|
|
@@ -10,6 +10,10 @@ The preset is found by folder name in ./presets/, then $KAIZEN_VIDEO_PRESETS
|
|
|
10
10
|
(default ~/.kaizen/video-presets/), then the skill's bundled presets/. A preset file
|
|
11
11
|
missing from its folder falls back to the skill's shared assets/, tools/ and
|
|
12
12
|
hyperframes.json.
|
|
13
|
+
|
|
14
|
+
A film preset (a folder with style.json) works too: the cut footage becomes one full-length footage beat of
|
|
15
|
+
a film in videos/<name>/film-bridge/, its sound the narration and its words the timings, and make_film.py
|
|
16
|
+
builds and renders it in that style (the film's grade, captions, music and loudness; no cards from beats).
|
|
13
17
|
"""
|
|
14
18
|
import html
|
|
15
19
|
import os
|
|
@@ -33,10 +37,11 @@ proj.mkdir(exist_ok=True)
|
|
|
33
37
|
cfg = json.loads((vdir / "config.json").read_text())
|
|
34
38
|
dirs = [WORK / "presets", Path(os.environ.get("KAIZEN_VIDEO_PRESETS", Path.home() / ".kaizen/video-presets")), SKILL / "presets"]
|
|
35
39
|
preset = next((d / cfg["preset"] for d in dirs if (d / cfg["preset"] / "index.html").exists()), None)
|
|
36
|
-
if
|
|
37
|
-
|
|
40
|
+
film_style = None if preset else next((d / n for n in (cfg["preset"], "film-" + cfg["preset"]) for d in dirs if (d / n / "style.json").exists()), None)
|
|
41
|
+
if not preset and not film_style:
|
|
42
|
+
names = sorted({p.parent.name for d in dirs if d.exists() for p in [*d.glob("*/index.html"), *d.glob("*/style.json")]})
|
|
38
43
|
sys.exit(f"preset {cfg['preset']!r} not found in {', '.join(map(str, dirs))}; available: {', '.join(names)}")
|
|
39
|
-
print(f"preset {preset}")
|
|
44
|
+
print(f"preset {preset or film_style}")
|
|
40
45
|
src_of = lambda p: next(f for f in (preset / p, SKILL / p) if f.exists()) # preset file, else the shared one
|
|
41
46
|
rel = lambda p: (vdir / p).resolve()
|
|
42
47
|
|
|
@@ -46,9 +51,9 @@ def run(*cmd, **kw):
|
|
|
46
51
|
|
|
47
52
|
|
|
48
53
|
# 1. Preset files and this video's images into the project.
|
|
49
|
-
for f in ["package.json", "hyperframes.json"]:
|
|
54
|
+
for f in [] if film_style else ["package.json", "hyperframes.json"]:
|
|
50
55
|
shutil.copy(src_of(f), proj / f)
|
|
51
|
-
for d in ["fonts", "sfx"]:
|
|
56
|
+
for d in [] if film_style else ["fonts", "sfx"]:
|
|
52
57
|
shutil.rmtree(proj / "assets" / d, ignore_errors=True)
|
|
53
58
|
for base in (SKILL, preset): # shared assets first, the preset's own on top
|
|
54
59
|
if (base / "assets" / d).exists():
|
|
@@ -87,6 +92,26 @@ for s0, s1, length in segs:
|
|
|
87
92
|
cut_duration = offset
|
|
88
93
|
flat = [w for c in chunks for w in c]
|
|
89
94
|
|
|
95
|
+
if film_style:
|
|
96
|
+
# Hand the cut to the film engine: one footage beat as long as the cut, with no lead or tail so the voice stays on the lips.
|
|
97
|
+
bridge = vdir / "film-bridge"
|
|
98
|
+
bridge.mkdir(exist_ok=True)
|
|
99
|
+
src = rel(cfg["video"])
|
|
100
|
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(src), "-an", "-vf", "scale=1080:1920:flags=lanczos,fps=30,format=yuv420p",
|
|
101
|
+
"-c:v", "libx264", "-crf", "16", "-g", "30", str(bridge / "footage.mp4")], check=True)
|
|
102
|
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(src), "-vn", "-af", "afftdn=nf=-28,deesser=i=0.35", "-b:a", "256k", str(bridge / "v01.mp3")], check=True)
|
|
103
|
+
length = float(subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", str(src)]))
|
|
104
|
+
(bridge / "words.json").write_text(json.dumps({"v01": {"dur": round(length, 3), "offset": 0, "text": " ".join(w["w"] for w in flat), "words": flat}}, ensure_ascii=False))
|
|
105
|
+
(bridge / "lines.json").write_text(json.dumps({"v01": " ".join(w["w"] for w in flat)}, ensure_ascii=False))
|
|
106
|
+
if (vdir / "CREDITS.txt").exists():
|
|
107
|
+
shutil.copy(vdir / "CREDITS.txt", bridge / "CREDITS.txt")
|
|
108
|
+
(bridge / "film.json").write_text(json.dumps({"name": cfg["name"], "preset": film_style.name, "format": "9x16", "language": cfg.get("language", "id"),
|
|
109
|
+
"music": cfg["music"], "style": {"pace": {"lead": 0, "tail": 0}},
|
|
110
|
+
"beats": [{"kind": "footage", "video": "footage.mp4", "vo": "v01"}]}, ensure_ascii=False, indent=1))
|
|
111
|
+
print(f"film preset {film_style.name}: building the cut as a film")
|
|
112
|
+
subprocess.run(["python3", str(SKILL / "scripts/make_film.py"), str(bridge), *(["--render"] if "--render" in sys.argv else [])], check=True, cwd=WORK)
|
|
113
|
+
sys.exit(0)
|
|
114
|
+
|
|
90
115
|
|
|
91
116
|
def at(key, after=0):
|
|
92
117
|
try:
|
|
@@ -103,7 +128,8 @@ if co:
|
|
|
103
128
|
else:
|
|
104
129
|
co_a = co_b = 0.0
|
|
105
130
|
L = round(co_b - co_a, 3)
|
|
106
|
-
|
|
131
|
+
# A beat is placed on a spoken word, or at "t" seconds (films bridged from make_film.py).
|
|
132
|
+
beats = sorted(({**{k: v for k, v in b_.items() if k not in ("word", "after")}, "t": round((b_["t"] if "t" in b_ else at(b_["word"], b_.get("after", 0))) + L, 3)}
|
|
107
133
|
for b_ in cfg["beats"]), key=lambda x: x["t"])
|
|
108
134
|
shift = lambda w, d: {**w, "s": round(w["s"] + d, 3), "e": round(w["e"] + d, 3)}
|
|
109
135
|
cold = [[shift(w, -co_a) for w in c if co_a <= w["s"] and w["e"] <= co_b] for c in chunks] if co else []
|
|
@@ -158,7 +184,7 @@ tags = "\n".join(f' <audio id="sfx-{i}" src="assets/sfx/{n}.wav" data-start
|
|
|
158
184
|
src, key = rel(cfg["video"]), proj / "source.key"
|
|
159
185
|
vf = "scale=1080:1920:flags=lanczos,unsharp=5:5:0.6:5:5:0,fps=30,format=yuv420p"
|
|
160
186
|
af = "afftdn=nf=-28,deesser=i=0.35,aformat=sample_rates=48000:channel_layouts=stereo"
|
|
161
|
-
k = json.dumps([str(src), src.stat().st_mtime, co_a, co_b, vf, af])
|
|
187
|
+
k = json.dumps([str(src), src.stat().st_mtime, co_a, co_b, vf, af, "g30"])
|
|
162
188
|
if not (proj / "source.mp4").exists() or not key.exists() or key.read_text() != k:
|
|
163
189
|
if co:
|
|
164
190
|
graph = (f"[0:v]split[v1][v2];[0:a]asplit[a1][a2];"
|
|
@@ -167,7 +193,7 @@ if not (proj / "source.mp4").exists() or not key.exists() or key.read_text() !=
|
|
|
167
193
|
else:
|
|
168
194
|
graph = f"[0:v]{vf}[v];[0:a]{af}[a]"
|
|
169
195
|
run("ffmpeg", "-v", "error", "-y", "-i", str(src), "-filter_complex", graph, "-map", "[v]", "-map", "[a]",
|
|
170
|
-
"-c:v", "libx264", "-crf", "14", "-preset", "medium", "-c:a", "aac", "-b:a", "256k", "source.mp4")
|
|
196
|
+
"-c:v", "libx264", "-crf", "14", "-preset", "medium", "-g", "30", "-c:a", "aac", "-b:a", "256k", "source.mp4")
|
|
171
197
|
key.write_text(k)
|
|
172
198
|
|
|
173
199
|
# 5. Music bed trimmed to length, then the composition from the template.
|
|
@@ -179,6 +205,8 @@ page = (preset / "index.html").read_text()
|
|
|
179
205
|
for k, v in {"DURATION": duration, "VIDEO_DURATION": video_duration, "VIDEO": "source.mp4", "MUSIC_VOLUME": cfg.get("music_volume", 0.32),
|
|
180
206
|
"HOOK_1": html.escape(h["line1"]), "HOOK_2": html.escape(h["line2"]), "HOOK_SUB": html.escape(h["sub"])}.items():
|
|
181
207
|
page = page.replace("{{" + k + "}}", str(v))
|
|
208
|
+
if cfg.get("card") is False: # no real footage behind it (a film bridged from make_film.py): hide the clip card
|
|
209
|
+
page = page.replace("</head>", "<style>#cam { opacity: 0 !important; }</style>\n </head>", 1) # the renderer paints video despite visibility
|
|
182
210
|
page = page.replace("<!-- SFX:BEGIN -->", "<!-- SFX:BEGIN -->\n" + tags + "\n ")
|
|
183
211
|
(proj / "index.html").write_text(page)
|
|
184
212
|
|
|
@@ -191,7 +219,12 @@ print(f"{len(chunks)} caption chunks, {len(beats)} beats, {len(sfx)} sfx, {durat
|
|
|
191
219
|
if "--render" in sys.argv:
|
|
192
220
|
out = WORK / "output" / cfg["name"] / cfg["preset"] / f"{cfg['name']}.mp4"
|
|
193
221
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
194
|
-
|
|
222
|
+
# Frame extraction writes gigabytes of temp files; /tmp is often a small tmpfs, which fails as VIDEO_SOURCE_UNRENDERABLE.
|
|
223
|
+
tmp = proj / ".render-tmp"
|
|
224
|
+
tmp.mkdir(exist_ok=True)
|
|
225
|
+
run("npx", "--yes", HF, "render", "--crf", str(cfg.get("crf", 23)), "-o", str(out), # CRF 23: ~1/3 the size of the default 16, same resolution
|
|
226
|
+
env={**os.environ, "TMPDIR": str(tmp)})
|
|
227
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
195
228
|
shutil.rmtree(proj / "renders", ignore_errors=True)
|
|
196
229
|
# The video's own credits (images, footage), the music bed actually used, then the preset's (fonts, sound effects).
|
|
197
230
|
# A music credit is the line "- <music>.mp3: ..." in the preset's CREDITS.txt, else in the shared assets/CREDITS.txt.
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Render
|
|
3
|
-
# Earlier deliveries move to
|
|
4
|
-
# Usage: scripts/master.sh <film-dir>
|
|
2
|
+
# Render a built film (make_film.py), master loudness (two-pass), write .srt + thumbnail + credits.
|
|
3
|
+
# Run from the project folder. Earlier deliveries move to output/<name>/<preset>/previous/ (never overwritten).
|
|
4
|
+
# Usage: scripts/master.sh <film-dir> [lufs: default from the style, -14 social | -16 presentation] [thumb-second]
|
|
5
|
+
# Writes output/<film>/<preset>/<name>.mp4; <name> is <film>-<shape> when make_film.py ran with --format.
|
|
5
6
|
set -euo pipefail
|
|
6
|
-
DIR=$(cd "${1:?film dir}" && pwd);
|
|
7
|
+
DIR=$(cd "${1:?film dir}" && pwd); THUMB=${3:-3}
|
|
7
8
|
SKILL=$(cd "$(dirname "$0")/.." && pwd)
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
m(){ python3 -c "import json;print(json.load(open('$DIR/film/meta.json')).get('$1',''))"; }
|
|
10
|
+
# folder: the film's name; name: the file's, which make_film.py --format suffixes (gerbang-4x5) so shapes sit side by side.
|
|
11
|
+
NAME=$(m name); FOLDER=$(m folder); PRESET=$(m preset); LUFS=${2:-$(m loudness)}
|
|
12
|
+
OUT="$PWD/output/${FOLDER:-$NAME}/$PRESET"; mkdir -p "$OUT/previous"
|
|
10
13
|
if [ -f "$OUT/$NAME.mp4" ]; then
|
|
11
14
|
stamp=$(date +%Y%m%d-%H%M%S)
|
|
12
15
|
for x in "$OUT/$NAME".mp4 "$OUT/$NAME".srt "$OUT/$NAME"-thumb.jpg; do [ -f "$x" ] && mv "$x" "$OUT/previous/$(basename "${x%.*}")-$stamp.${x##*.}"; done
|
|
13
16
|
fi
|
|
14
|
-
|
|
15
|
-
(cd "$ENGINE" && npx remotion render src/index.ts "Film-$FMT" "$OUT/$NAME.raw.mp4" --props="$DIR/.props.json" --public-dir="$DIR" --log=error 2>&1 | grep -v "network requests" || true)
|
|
17
|
+
(cd "$DIR/film" && npx --yes hyperframes@0.8.176 render --crf 20 -o "$OUT/$NAME.raw.mp4" >/dev/null)
|
|
16
18
|
J=$(ffmpeg -hide_banner -i "$OUT/$NAME.raw.mp4" -af loudnorm=I=$LUFS:TP=-1.5:LRA=11:print_format=json -f null - 2>&1 | sed -n '/{/,/}/p')
|
|
17
19
|
g(){ echo "$J" | python3 -c "import sys,json;print(json.load(sys.stdin)['$1'])"; }
|
|
18
20
|
ffmpeg -v error -y -i "$OUT/$NAME.raw.mp4" -c:v copy -c:a aac -b:a 192k \
|
|
19
21
|
-af "loudnorm=I=$LUFS:TP=-1.5:LRA=11:measured_I=$(g input_i):measured_TP=$(g input_tp):measured_LRA=$(g input_lra):measured_thresh=$(g input_thresh):offset=$(g target_offset):linear=true" \
|
|
20
22
|
"$OUT/$NAME.mp4"
|
|
21
|
-
rm "$OUT/$NAME.raw.mp4" "$DIR
|
|
23
|
+
rm "$OUT/$NAME.raw.mp4"; rm -rf "$DIR/film/renders"
|
|
22
24
|
python3 "$SKILL/scripts/srt.py" "$DIR" "$OUT/$NAME.srt"
|
|
23
25
|
ffmpeg -v error -y -ss "$THUMB" -i "$OUT/$NAME.mp4" -frames:v 1 -q:v 2 "$OUT/$NAME-thumb.jpg"
|
|
24
|
-
|
|
25
|
-
echo "Voice & sound effects: see the voice provider in film.json (ElevenLabs commercial use requires a paid plan)." >> "$OUT/$NAME-credits.txt"
|
|
26
|
+
cp "$DIR/film/CREDITS.txt" "$OUT/CREDITS.txt"
|
|
26
27
|
ffprobe -v error -show_entries format=duration -of csv=p=0 "$OUT/$NAME.mp4" | xargs -I{} echo "done: $OUT/$NAME.mp4 ({} s, $LUFS LUFS)"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Pixel art: a text grid and its palette into a crisp PNG, for mascots, icons and scene pictures.
|
|
2
|
+
|
|
3
|
+
python3 scripts/pixel.py <art.txt> <out.png> [--scale N]
|
|
4
|
+
|
|
5
|
+
art.txt: palette lines "X #rrggbb" (or "X #rrggbbaa"), a blank line, then the grid, one character per pixel;
|
|
6
|
+
"." and any character not in the palette are transparent. Rows may differ in length (short rows are padded).
|
|
7
|
+
The grid is upscaled N times (default 32) with nearest-neighbour, so edges stay sharp.
|
|
8
|
+
"""
|
|
9
|
+
import sys
|
|
10
|
+
from PIL import Image
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def render(text, scale=32):
|
|
14
|
+
head, _, body = text.strip("\n").partition("\n\n")
|
|
15
|
+
pal = {}
|
|
16
|
+
for line in head.splitlines():
|
|
17
|
+
k, v = line.split()
|
|
18
|
+
v = v.lstrip("#")
|
|
19
|
+
pal[k] = tuple(int(v[i:i + 2], 16) for i in range(0, len(v), 2)) + ((255,) if len(v) == 6 else ())
|
|
20
|
+
rows = body.strip("\n").splitlines()
|
|
21
|
+
img = Image.new("RGBA", (max(map(len, rows)), len(rows)), (0, 0, 0, 0))
|
|
22
|
+
for y, r in enumerate(rows):
|
|
23
|
+
for x, ch in enumerate(r):
|
|
24
|
+
if ch in pal:
|
|
25
|
+
img.putpixel((x, y), pal[ch])
|
|
26
|
+
return img.resize((img.width * scale, img.height * scale), Image.NEAREST)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
if sys.argv[1:] == ["--check"]: # self-test
|
|
31
|
+
im = render("R #ff0000\nB #0000ff80\n\nR.\n.B", 2)
|
|
32
|
+
assert im.size == (4, 4) and im.getpixel((0, 0)) == (255, 0, 0, 255) and im.getpixel((2, 0))[3] == 0
|
|
33
|
+
assert im.getpixel((3, 3)) == (0, 0, 255, 128) and im.getpixel((1, 1)) == (255, 0, 0, 255)
|
|
34
|
+
print("ok")
|
|
35
|
+
sys.exit()
|
|
36
|
+
if len(sys.argv) < 3:
|
|
37
|
+
sys.exit(__doc__)
|
|
38
|
+
scale = int(sys.argv[sys.argv.index("--scale") + 1]) if "--scale" in sys.argv else 32
|
|
39
|
+
render(open(sys.argv[1]).read(), scale).save(sys.argv[2])
|
|
40
|
+
print(f"wrote {sys.argv[2]}")
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Films a web product in use, for app-promo (references/promo.md).
|
|
2
|
+
//
|
|
3
|
+
// node scripts/record.mjs videos/<name> # reads videos/<name>/record.json
|
|
4
|
+
//
|
|
5
|
+
// record.json: {"url": "http://...", "clips": [{"name": "idea", "device": "phone"|"tablet"|"desktop",
|
|
6
|
+
// "path": "/optional/start/path", "steps": [["wait", ms], ["tap", "css" | "text:Label"], ["type", "css", "text", msPerKey?],
|
|
7
|
+
// ["key", "Enter"], ["scroll", px], ["goto", "/path"]], "prep": [same steps, run before filming starts, e.g. a sign-in]}]}
|
|
8
|
+
// Writes videos/<name>/rec/<clip>.mp4 (30 fps, the device's full pixels) and rec/<clip>.json
|
|
9
|
+
// ({device, cssW, cssH, taps: [{t, x, y}]}, x/y in CSS px of the page, t in seconds of the clip).
|
|
10
|
+
// Frames are full-resolution screenshots taken in a loop while the steps run (Chromium's own screencast
|
|
11
|
+
// is capped at CSS pixels). Point "url" at a sandbox or a demo account: everything on screen is filmed.
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
import { execFileSync } from "child_process";
|
|
14
|
+
import fs from "fs";
|
|
15
|
+
import os from "os";
|
|
16
|
+
import path from "path";
|
|
17
|
+
|
|
18
|
+
const DEVICES = {
|
|
19
|
+
phone: { width: 430, height: 932, deviceScaleFactor: 2.5, isMobile: true, hasTouch: true },
|
|
20
|
+
tablet: { width: 820, height: 1180, deviceScaleFactor: 2, isMobile: true, hasTouch: true },
|
|
21
|
+
desktop: { width: 1440, height: 900, deviceScaleFactor: 2, isMobile: false, hasTouch: false },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// puppeteer-core ships with the HyperFrames CLI in the npx cache; find it rather than add a dependency.
|
|
25
|
+
function puppeteer() {
|
|
26
|
+
const root = path.join(os.homedir(), ".npm", "_npx");
|
|
27
|
+
for (const d of fs.existsSync(root) ? fs.readdirSync(root) : []) {
|
|
28
|
+
const m = path.join(root, d, "node_modules", "puppeteer-core");
|
|
29
|
+
if (fs.existsSync(m)) return createRequire(path.join(root, d, "node_modules", "x.js"))("puppeteer-core");
|
|
30
|
+
}
|
|
31
|
+
throw new Error("puppeteer-core not found: run `npx -y hyperframes@0.8.176 --version` once, then retry");
|
|
32
|
+
}
|
|
33
|
+
const chromium = () => ["/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/google-chrome", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find((p) => fs.existsSync(p))
|
|
34
|
+
|| (() => { throw new Error("no Chromium found"); })();
|
|
35
|
+
|
|
36
|
+
const vdir = process.argv[2];
|
|
37
|
+
if (!vdir) { console.error("usage: node record.mjs videos/<name>"); process.exit(2); }
|
|
38
|
+
const spec = JSON.parse(fs.readFileSync(path.join(vdir, "record.json"), "utf8"));
|
|
39
|
+
const out = path.join(vdir, "rec");
|
|
40
|
+
fs.mkdirSync(out, { recursive: true });
|
|
41
|
+
const W = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
42
|
+
const b = await puppeteer().launch({ executablePath: chromium(), args: ["--no-sandbox"] });
|
|
43
|
+
|
|
44
|
+
for (const clip of spec.clips) {
|
|
45
|
+
const dev = DEVICES[clip.device];
|
|
46
|
+
if (!dev) throw new Error(`clip ${clip.name}: unknown device ${clip.device}`);
|
|
47
|
+
const p = await b.newPage();
|
|
48
|
+
await p.setViewport(dev);
|
|
49
|
+
await p.goto(new URL(clip.path || "/", spec.url).href, { waitUntil: "networkidle2" });
|
|
50
|
+
await W(800);
|
|
51
|
+
const taps = [];
|
|
52
|
+
let t0 = Date.now();
|
|
53
|
+
// A visible element by CSS or by its exact text ("text:Add").
|
|
54
|
+
const find = async (q) => {
|
|
55
|
+
const all = q.startsWith("text:") ? await p.$$(`xpath/.//*[self::button or self::a or self::label or @role='tab' or @role='button'][normalize-space()=${JSON.stringify(q.slice(5))}]`) : await p.$$(q);
|
|
56
|
+
for (const e of all) if (await e.evaluate((n) => n.getBoundingClientRect().width > 0)) return e;
|
|
57
|
+
throw new Error(`clip ${clip.name}: nothing visible matches ${q}`);
|
|
58
|
+
};
|
|
59
|
+
const steps = async (list, log) => {
|
|
60
|
+
for (const [op, a, b2, c] of list) {
|
|
61
|
+
if (op === "wait") await W(a);
|
|
62
|
+
else if (op === "tap") {
|
|
63
|
+
const el = await find(a);
|
|
64
|
+
const r = await el.evaluate((e) => { const x = e.getBoundingClientRect(); return { x: x.x + x.width / 2, y: x.y + x.height / 2 }; });
|
|
65
|
+
if (log) taps.push({ t: (Date.now() - t0) / 1000 + 0.35, x: r.x, y: r.y });
|
|
66
|
+
await W(log ? 350 : 0);
|
|
67
|
+
await el.evaluate((e) => e.click());
|
|
68
|
+
} else if (op === "type") { await (await find(a)).focus(); await p.keyboard.type(b2, { delay: log ? (c ?? 55) : 0 }); }
|
|
69
|
+
else if (op === "key") await p.keyboard.press(a);
|
|
70
|
+
else if (op === "scroll") await p.mouse.wheel({ deltaY: a });
|
|
71
|
+
else if (op === "goto") await p.goto(new URL(a, spec.url).href, { waitUntil: "networkidle2" });
|
|
72
|
+
else throw new Error(`clip ${clip.name}: unknown step ${op}`);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (clip.prep) { await steps(clip.prep, false); await W(800); }
|
|
76
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), `rec-${clip.name}-`));
|
|
77
|
+
const frames = [];
|
|
78
|
+
t0 = Date.now();
|
|
79
|
+
let on = true, n = 0;
|
|
80
|
+
const loop = (async () => {
|
|
81
|
+
while (on) {
|
|
82
|
+
const file = path.join(dir, `${String(n++).padStart(5, "0")}.jpg`);
|
|
83
|
+
const t = (Date.now() - t0) / 1000;
|
|
84
|
+
await p.screenshot({ path: file, type: "jpeg", quality: 90 });
|
|
85
|
+
frames.push({ file, t });
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
await steps(clip.steps, true);
|
|
89
|
+
await W(300);
|
|
90
|
+
on = false;
|
|
91
|
+
await loop;
|
|
92
|
+
await p.close();
|
|
93
|
+
// Variable-rate frames to a 30 fps clip: each frame holds until the next was taken.
|
|
94
|
+
const list = frames.map((f, i) => `file '${f.file}'\nduration ${((frames[i + 1]?.t ?? f.t + 0.5) - f.t).toFixed(4)}`).join("\n") + `\nfile '${frames.at(-1).file}'\n`;
|
|
95
|
+
fs.writeFileSync(path.join(dir, "list.txt"), list);
|
|
96
|
+
const mp4 = path.join(out, `${clip.name}.mp4`);
|
|
97
|
+
execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "concat", "-safe", "0", "-i", path.join(dir, "list.txt"),
|
|
98
|
+
"-vf", "fps=30,crop=trunc(iw/2)*2:trunc(ih/2)*2:0:0,format=yuv420p", "-c:v", "libx264", "-crf", "16", "-g", "15", mp4]);
|
|
99
|
+
fs.writeFileSync(path.join(out, `${clip.name}.json`), JSON.stringify({ device: clip.device, cssW: dev.width, cssH: dev.height, seconds: frames.at(-1).t, taps }, null, 1));
|
|
100
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
101
|
+
console.log(`recorded ${mp4}: ${frames.length} frames, ${(frames.length / frames.at(-1).t).toFixed(1)} fps, ${taps.length} taps`);
|
|
102
|
+
}
|
|
103
|
+
await b.close();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"""Build the sound-effect / room-tone library
|
|
1
|
+
"""Build the sound-effect / room-tone library on this machine (~/.kaizen/kaizen-video/sfx/; override KAIZEN_VIDEO_HOME).
|
|
2
2
|
Usage: python3 scripts/sfx.py [--provider synth|elevenlabs] [--force]
|
|
3
3
|
synth (default without ELEVENLABS_API_KEY) — synthesized locally with ffmpeg; free, no licence limits.
|
|
4
4
|
elevenlabs (default with a key) — generated sound effects; commercial use needs a paid ElevenLabs plan.
|
|
5
|
-
Only missing files are made unless --force. Names are what
|
|
5
|
+
Only missing files are made unless --force. Names are what a film preset's style.json and beats (sfx/ambience) use.
|
|
6
6
|
No sound files ship with the skill: every machine makes its own."""
|
|
7
7
|
import json, os, subprocess, sys, urllib.request
|
|
8
8
|
|
|
@@ -43,7 +43,7 @@ SYNTH = {
|
|
|
43
43
|
args = sys.argv[1:]
|
|
44
44
|
force = "--force" in args
|
|
45
45
|
provider = args[args.index("--provider") + 1] if "--provider" in args else ("elevenlabs" if os.environ.get("ELEVENLABS_API_KEY") else "synth")
|
|
46
|
-
SFX = os.path.expanduser(os.environ.get("
|
|
46
|
+
SFX = os.path.expanduser(os.environ.get("KAIZEN_VIDEO_HOME", "~/.kaizen/kaizen-video")) + "/sfx"
|
|
47
47
|
os.makedirs(SFX, exist_ok=True)
|
|
48
48
|
H = {"xi-api-key": os.environ.get("ELEVENLABS_API_KEY", ""), "Content-Type": "application/json"}
|
|
49
49
|
print("sfx provider:", provider)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Write an .srt from the cues make_film.py computed (<film-dir>/film/cues.json: [[start, end, text], ...]).
|
|
2
|
+
Usage: python3 scripts/srt.py <film-dir> <out.srt>"""
|
|
3
|
+
import json, sys
|
|
4
|
+
cues = json.load(open(f"{sys.argv[1]}/film/cues.json"))
|
|
5
|
+
def ts(sec):
|
|
6
|
+
ms = int(round(sec * 1000)); h, ms = divmod(ms, 3600000); m, ms = divmod(ms, 60000); s, ms = divmod(ms, 1000)
|
|
7
|
+
return f"{h:02}:{m:02}:{s:02},{ms:03}"
|
|
8
|
+
open(sys.argv[2], "w").write("\n".join(f"{i}\n{ts(s)} --> {ts(e)}\n{t}\n" for i, (s, e, t) in enumerate(cues, 1)))
|
|
9
|
+
print("srt", len(cues), "cues")
|