@biunow/agent-biutalk 0.0.0-stage → 1.1.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/bin/server.js +355 -0
- package/engine/AGENTS.md +1414 -0
- package/engine/CLAUDE.md +1 -0
- package/engine/LICENSE +21 -0
- package/engine/README.md +216 -0
- package/engine/bin/explainroo.js +19 -0
- package/engine/dev/audio-lab.mjs +268 -0
- package/engine/docs/media/contact-sheet.jpg +0 -0
- package/engine/docs/media/dns-poster.jpg +0 -0
- package/engine/docs/media/intro-poster.jpg +0 -0
- package/engine/docs/media/logo-dark.png +0 -0
- package/engine/docs/media/logo-light.png +0 -0
- package/engine/docs/media/looks-dark.webp +0 -0
- package/engine/docs/media/looks-light.webp +0 -0
- package/engine/docs/media/product-demo.webp +0 -0
- package/engine/docs/media/rebase-poster.jpg +0 -0
- package/engine/docs/media/sizes-dark.webp +0 -0
- package/engine/docs/media/sizes-light.webp +0 -0
- package/engine/engine/audio/dsp.js +69 -0
- package/engine/engine/audio/instruments.js +147 -0
- package/engine/engine/audio/music.js +576 -0
- package/engine/engine/audio/pcm.js +93 -0
- package/engine/engine/audio/rng.js +40 -0
- package/engine/engine/audio/sfx.js +287 -0
- package/engine/engine/audio/soundtrack.js +201 -0
- package/engine/engine/audio/synth.js +721 -0
- package/engine/engine/audio/theory.js +105 -0
- package/engine/engine/audio/wav.js +47 -0
- package/engine/engine/captions.js +131 -0
- package/engine/engine/clips.js +107 -0
- package/engine/engine/code.js +179 -0
- package/engine/engine/director.js +475 -0
- package/engine/engine/frame.html +135 -0
- package/engine/engine/icons/LICENSE-lucide.txt +43 -0
- package/engine/engine/icons/lucide-tags.json +1 -0
- package/engine/engine/icons/lucide.json +1 -0
- package/engine/engine/layout.js +69 -0
- package/engine/engine/pathdata.js +234 -0
- package/engine/engine/pen.js +240 -0
- package/engine/engine/player.html +67 -0
- package/engine/engine/player.js +219 -0
- package/engine/engine/readability.js +9 -0
- package/engine/engine/runtime.js +690 -0
- package/engine/engine/stage.js +2247 -0
- package/engine/engine/studio.html +216 -0
- package/engine/engine/text.js +81 -0
- package/engine/engine/themes.js +360 -0
- package/engine/engine/transitions.js +161 -0
- package/engine/engine/ui.js +1042 -0
- package/engine/engine/upload.js +32 -0
- package/engine/engine/util.js +204 -0
- package/engine/examples/callbacks-to-async-await/code-versions.js +34 -0
- package/engine/examples/callbacks-to-async-await/scenes.js +106 -0
- package/engine/examples/callbacks-to-async-await/script.md +22 -0
- package/engine/examples/callbacks-to-async-await/video.json +16 -0
- package/engine/examples/circle-area/scenes.js +228 -0
- package/engine/examples/circle-area/script.md +37 -0
- package/engine/examples/circle-area/video.json +14 -0
- package/engine/examples/explainroo-intro/scenes.js +133 -0
- package/engine/examples/explainroo-intro/script.md +27 -0
- package/engine/examples/explainroo-intro/video.json +8 -0
- package/engine/examples/how-dns-works/scenes.js +130 -0
- package/engine/examples/how-dns-works/script.md +28 -0
- package/engine/examples/how-dns-works/video.json +8 -0
- package/engine/examples/leap-years/scenes.js +156 -0
- package/engine/examples/leap-years/script.md +25 -0
- package/engine/examples/leap-years/video.json +16 -0
- package/engine/examples/leap-years-ja/scenes.js +194 -0
- package/engine/examples/leap-years-ja/script.md +32 -0
- package/engine/examples/leap-years-ja/video.json +17 -0
- package/engine/examples/merge-vs-rebase/scenes.js +129 -0
- package/engine/examples/merge-vs-rebase/script.md +22 -0
- package/engine/examples/merge-vs-rebase/video.json +8 -0
- package/engine/examples/password-storage-zh/scenes.js +185 -0
- package/engine/examples/password-storage-zh/script.md +25 -0
- package/engine/examples/password-storage-zh/video.json +19 -0
- package/engine/examples/sqlite-demo/README.md +19 -0
- package/engine/examples/sqlite-demo/scenes.js +423 -0
- package/engine/examples/sqlite-demo/script.md +35 -0
- package/engine/examples/sqlite-demo/video.json +17 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-400.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-500.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-600.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-700.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-OFL.txt +93 -0
- package/engine/examples/unspar-demo/assets/unspar-logo.svg +23 -0
- package/engine/examples/unspar-demo/scenes.js +367 -0
- package/engine/examples/unspar-demo/script.md +25 -0
- package/engine/examples/unspar-demo/video.json +21 -0
- package/engine/examples/why-is-the-sky-blue-es/scenes.js +160 -0
- package/engine/examples/why-is-the-sky-blue-es/script.md +22 -0
- package/engine/examples/why-is-the-sky-blue-es/video.json +15 -0
- package/engine/fonts/ArchitectsDaughter-400-latin-ext.woff2 +0 -0
- package/engine/fonts/ArchitectsDaughter-400-latin.woff2 +0 -0
- package/engine/fonts/CabinSketch-400-latin.woff2 +0 -0
- package/engine/fonts/CabinSketch-700-latin.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-italic-latin-ext.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-italic-latin.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-normal-latin-ext.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-normal-latin.woff2 +0 -0
- package/engine/fonts/Inter-400-latin-ext.woff2 +0 -0
- package/engine/fonts/Inter-400-latin.woff2 +0 -0
- package/engine/fonts/JetBrainsMono-400-latin-ext.woff2 +0 -0
- package/engine/fonts/JetBrainsMono-400-latin.woff2 +0 -0
- package/engine/fonts/Kalam-400-latin-ext.woff2 +0 -0
- package/engine/fonts/Kalam-400-latin.woff2 +0 -0
- package/engine/fonts/Kalam-700-latin-ext.woff2 +0 -0
- package/engine/fonts/Kalam-700-latin.woff2 +0 -0
- package/engine/fonts/NotoSansDevanagari-400.ttf +0 -0
- package/engine/fonts/NotoSansDevanagari-700.ttf +0 -0
- package/engine/fonts/PatrickHand-400-latin-ext.woff2 +0 -0
- package/engine/fonts/PatrickHand-400-latin.woff2 +0 -0
- package/engine/fonts/PlusJakartaSans-600-latin-ext.woff2 +0 -0
- package/engine/fonts/PlusJakartaSans-600-latin.woff2 +0 -0
- package/engine/fonts/SpaceGrotesk-500-latin-ext.woff2 +0 -0
- package/engine/fonts/SpaceGrotesk-500-latin.woff2 +0 -0
- package/engine/fonts/fonts.json +216 -0
- package/engine/fonts/licenses/ArchitectsDaughter-OFL.txt +93 -0
- package/engine/fonts/licenses/CabinSketch-OFL.txt +93 -0
- package/engine/fonts/licenses/InstrumentSerif-OFL.txt +93 -0
- package/engine/fonts/licenses/Inter-OFL.txt +93 -0
- package/engine/fonts/licenses/JetBrainsMono-OFL.txt +93 -0
- package/engine/fonts/licenses/Kalam-OFL.txt +93 -0
- package/engine/fonts/licenses/NotoSansDevanagari-OFL.txt +118 -0
- package/engine/fonts/licenses/PatrickHand-OFL.txt +93 -0
- package/engine/fonts/licenses/PlusJakartaSans-OFL.txt +93 -0
- package/engine/fonts/licenses/SpaceGrotesk-OFL.txt +93 -0
- package/engine/package-lock.json +1201 -0
- package/engine/package.json +67 -0
- package/engine/scripts/build-icons.mjs +74 -0
- package/engine/scripts/fetch-fonts.mjs +68 -0
- package/engine/skills/explainroo/SKILL.md +51 -0
- package/engine/src/align.js +357 -0
- package/engine/src/browser.js +121 -0
- package/engine/src/capture.js +315 -0
- package/engine/src/chapters.js +32 -0
- package/engine/src/cli.js +421 -0
- package/engine/src/clips.js +19 -0
- package/engine/src/elevenlabs.js +90 -0
- package/engine/src/env.js +16 -0
- package/engine/src/export.js +187 -0
- package/engine/src/ffmpeg.js +103 -0
- package/engine/src/fonts.js +86 -0
- package/engine/src/g2p.py +76 -0
- package/engine/src/images.js +151 -0
- package/engine/src/licenses/misaki-Apache-2.0.txt +201 -0
- package/engine/src/math.js +83 -0
- package/engine/src/models.js +161 -0
- package/engine/src/phonemes.js +162 -0
- package/engine/src/pipeline.js +63 -0
- package/engine/src/project.js +331 -0
- package/engine/src/qa.js +186 -0
- package/engine/src/recordings.js +89 -0
- package/engine/src/render.js +156 -0
- package/engine/src/script.js +266 -0
- package/engine/src/server.js +288 -0
- package/engine/src/subtitles.js +78 -0
- package/engine/src/timeline.js +55 -0
- package/engine/src/voice.js +240 -0
- package/engine/src/wav.js +98 -0
- package/engine/templates/starter/scenes.js +31 -0
- package/engine/templates/starter/script.md +14 -0
- package/engine/test/align.test.js +108 -0
- package/engine/test/brand.test.js +41 -0
- package/engine/test/browser.test.js +89 -0
- package/engine/test/camera-browser.test.js +225 -0
- package/engine/test/caption-phrases.test.js +35 -0
- package/engine/test/capture-browser.test.js +90 -0
- package/engine/test/capture-fixture.js +46 -0
- package/engine/test/capture.test.js +62 -0
- package/engine/test/chapters.test.js +41 -0
- package/engine/test/cjk-browser.test.js +101 -0
- package/engine/test/cjk.test.js +232 -0
- package/engine/test/cli-exit.test.js +25 -0
- package/engine/test/cli.test.js +116 -0
- package/engine/test/clips-browser.test.js +125 -0
- package/engine/test/clips.test.js +67 -0
- package/engine/test/code-morph-browser.test.js +99 -0
- package/engine/test/code-morph.test.js +110 -0
- package/engine/test/contrast-browser.test.js +63 -0
- package/engine/test/contrast.test.js +80 -0
- package/engine/test/director.test.js +316 -0
- package/engine/test/engine-pure.test.js +29 -0
- package/engine/test/export-browser.test.js +224 -0
- package/engine/test/export.test.js +96 -0
- package/engine/test/fixtures/capture.html +55 -0
- package/engine/test/formats-pace.test.js +104 -0
- package/engine/test/languages-browser.test.js +78 -0
- package/engine/test/languages.test.js +140 -0
- package/engine/test/looks-browser.test.js +109 -0
- package/engine/test/looks-preview.test.js +57 -0
- package/engine/test/looks.test.js +130 -0
- package/engine/test/math-browser.test.js +114 -0
- package/engine/test/math.test.js +54 -0
- package/engine/test/multi-size-browser.test.js +133 -0
- package/engine/test/multi-size.test.js +116 -0
- package/engine/test/phonemes.test.js +92 -0
- package/engine/test/readability-browser.test.js +36 -0
- package/engine/test/readability.test.js +20 -0
- package/engine/test/render-options.test.js +52 -0
- package/engine/test/script.test.js +67 -0
- package/engine/test/server.test.js +256 -0
- package/engine/test/stills-browser.test.js +70 -0
- package/engine/test/subtitles.test.js +83 -0
- package/engine/test/timeline.test.js +31 -0
- package/engine/test/transparent-browser.test.js +123 -0
- package/engine/test/ui-kit.test.js +96 -0
- package/engine/test/upload-browser.test.js +55 -0
- package/engine/test/voice-providers.test.js +338 -0
- package/lib/host.mjs +480 -0
- package/manifest.json +54 -0
- package/package.json +8 -4
- package/skills/biutalk/SKILL.md +21 -0
- package/studio/app.js +209 -0
- package/studio/assert-panel-permit.mjs +67 -0
- package/studio/composer.css +354 -0
- package/studio/composer.js +169 -0
- package/studio/index.html +82 -0
- package/studio/looks/blueprint.svg +21 -0
- package/studio/looks/chalk.svg +15 -0
- package/studio/looks/clean.svg +20 -0
- package/studio/looks/editorial.svg +18 -0
- package/studio/looks/midnight.svg +17 -0
- package/studio/looks/paper.svg +11 -0
- package/studio/select-menu.js +268 -0
- package/studio/styles.css +4 -0
- package/README.md +0 -3
package/engine/AGENTS.md
ADDED
|
@@ -0,0 +1,1414 @@
|
|
|
1
|
+
# explainroo for coding agents
|
|
2
|
+
|
|
3
|
+
This file tells you, the coding agent, how to make a video with explainroo.
|
|
4
|
+
The user usually gives you a topic, and maybe a length or a style. You write
|
|
5
|
+
the words and the pictures. explainroo makes the video.
|
|
6
|
+
|
|
7
|
+
explainroo turns two files into an MP4 video with narration. `script.md`
|
|
8
|
+
holds what the voice says. `scenes.js` draws what the viewer sees. Every
|
|
9
|
+
drawing can appear on a word the voice says. A voice model (Kokoro) reads
|
|
10
|
+
the script on this computer, or the narration comes from ElevenLabs or your
|
|
11
|
+
own recording. Whisper listens to the narration and writes down when each
|
|
12
|
+
word is spoken. Chrome draws the frames in the background.
|
|
13
|
+
explainroo adds music and sound effects, and ffmpeg makes the MP4. You need
|
|
14
|
+
no API key for local voices or recordings. ElevenLabs and AI images need
|
|
15
|
+
keys.
|
|
16
|
+
|
|
17
|
+
The full documentation for people is at https://www.explainroo.com/docs/.
|
|
18
|
+
|
|
19
|
+
## Before you start
|
|
20
|
+
|
|
21
|
+
Maybe the user pasted the prompt from the README or from explainroo.com, and
|
|
22
|
+
you are not in an explainroo folder yet. Then clone it into the current
|
|
23
|
+
folder first. If the user named another place, use that.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/vincentsch/explainroo.git
|
|
27
|
+
cd explainroo
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Run this once in the explainroo folder:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
node bin/explainroo.js doctor --fetch
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`doctor` checks Node, ffmpeg and Chrome, and the extra programs some
|
|
38
|
+
languages need. It also downloads the English speech models, about 400 MB,
|
|
39
|
+
the first time only. Other languages fetch their speech check model on first
|
|
40
|
+
use. If the user ran `npm link`, you
|
|
41
|
+
can write `explainroo` instead of `node bin/explainroo.js` in the commands
|
|
42
|
+
below. Commands that work on a video take the project folder first, and every
|
|
43
|
+
command accepts `--json`.
|
|
44
|
+
|
|
45
|
+
### When to ask the user
|
|
46
|
+
|
|
47
|
+
Decide the normal things yourself, like the look, the length, the voice, the
|
|
48
|
+
layout and the wording. Ask only when you cannot go on without an answer.
|
|
49
|
+
When you ask, put everything you need in one message. Typical reasons to ask:
|
|
50
|
+
|
|
51
|
+
- The topic is unclear, or you need a fact you cannot check.
|
|
52
|
+
- The user wants AI images and there is no OpenRouter key (see Images).
|
|
53
|
+
- The user wants ElevenLabs and there is no ElevenLabs key (see Voices).
|
|
54
|
+
- The user wants something explainroo cannot do, like video shot with a
|
|
55
|
+
camera.
|
|
56
|
+
|
|
57
|
+
## Making a video, step by step
|
|
58
|
+
|
|
59
|
+
1. **Learn the subject.** Read the code, docs or pages the user points to.
|
|
60
|
+
Write down the facts you will use. Never make up numbers, quotes or claims.
|
|
61
|
+
If a number matters and you cannot check it, leave it out.
|
|
62
|
+
|
|
63
|
+
2. **Create the project.**
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
node bin/explainroo.js init videos/<name> --theme paper --title "..."
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Projects go in `videos/`. Git ignores that folder. Pick the look that fits
|
|
70
|
+
the audience: `paper` (friendly, hand drawn, the default), `clean`
|
|
71
|
+
(products and business), `chalk` (teaching), `blueprint` (engineering),
|
|
72
|
+
`midnight` (developer tools) or `editorial` (essays, history, money and
|
|
73
|
+
other thoughtful topics). Pick the size for the place the video goes,
|
|
74
|
+
for example `--size tiktok` or `--size linkedin`. The sizes are listed in
|
|
75
|
+
"Sizes for each platform" below. Add `--pace 1.2` when the user wants a
|
|
76
|
+
quicker video.
|
|
77
|
+
|
|
78
|
+
3. **Write `script.md`.** The narration comes first. It sets the timing for
|
|
79
|
+
everything else. See "How to write the narration" below.
|
|
80
|
+
|
|
81
|
+
4. **Make the voice.**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
node bin/explainroo.js voice videos/<name>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The command prints how long each scene is and how many words the speech
|
|
88
|
+
check confirmed. If a word is not confirmed, the voice probably said it
|
|
89
|
+
wrong. Fix it with `{shown|spoken}` in the script and run the command
|
|
90
|
+
again. For a recording, make script.md say what was actually said.
|
|
91
|
+
Only the scenes you changed are made again. `check`, `still`, `sheet`,
|
|
92
|
+
`render` and `preview` also make missing narration, so start them after
|
|
93
|
+
`voice` has finished, not at the same time.
|
|
94
|
+
|
|
95
|
+
5. **Plan the pictures.** For each scene, decide what is on screen when each
|
|
96
|
+
marker or important word is spoken. Decide where each thing sits and what
|
|
97
|
+
leaves the screen. Keep things in the same place from scene to scene.
|
|
98
|
+
Answer four questions for each scene. What is the one thing the viewer
|
|
99
|
+
should look at? Which relationship does the layout show: an order, a
|
|
100
|
+
comparison, the parts of a whole or a cause? What appears and what leaves
|
|
101
|
+
on each cue? What stays in the same place in the next scene? "Layouts that
|
|
102
|
+
work" below has four layouts to start from.
|
|
103
|
+
|
|
104
|
+
6. **Make images, if the video needs them.** Icons and diagrams cover most
|
|
105
|
+
technical topics. Everyday how-to topics like cooking, cars or gardening
|
|
106
|
+
work better with pictures. See "Images" below.
|
|
107
|
+
|
|
108
|
+
7. **Write `scenes.js`.** Write one function per scene. Tie every picture to
|
|
109
|
+
the narration with `at: 'word'` or `at: '#marker'`. The scene API is at
|
|
110
|
+
the end of this file.
|
|
111
|
+
|
|
112
|
+
8. **Check.**
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
node bin/explainroo.js check videos/<name>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Fix every error and every warning. You decide what to do with the hints.
|
|
119
|
+
|
|
120
|
+
9. **Look at the frames.** You cannot watch the video, so this is how you see
|
|
121
|
+
it.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
node bin/explainroo.js still videos/<name> # the end of each scene
|
|
125
|
+
node bin/explainroo.js still videos/<name> intro@2.5 12.0 # any moment
|
|
126
|
+
node bin/explainroo.js sheet videos/<name> --scene intro # one scene over time
|
|
127
|
+
node bin/explainroo.js sheet videos/<name> # the whole video
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Open the images and judge them like a viewer would. Is the text big
|
|
131
|
+
enough? Is anything cut off or on top of something else? Is half the frame
|
|
132
|
+
empty? Does the sheet show something new every few seconds? Fix what is
|
|
133
|
+
wrong and look again.
|
|
134
|
+
|
|
135
|
+
For Reddit and other feeds, also run `check videos/<name> --view-width
|
|
136
|
+
854`. It warns when visible text shrinks below 16px in that player.
|
|
137
|
+
This is a size check, not a guarantee about platform compression. Show
|
|
138
|
+
only the current query or result, use bigger type, and zoom into details.
|
|
139
|
+
Review a still at `--scale 0.4448` too (about 480p for a 1080p video).
|
|
140
|
+
Never upload `draft.mp4`. After uploading, check the platform's lower
|
|
141
|
+
quality copy as well as its full-size copy.
|
|
142
|
+
|
|
143
|
+
10. **Make the video and check the file.**
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
node bin/explainroo.js render videos/<name> --draft # quick half-size version
|
|
147
|
+
node bin/explainroo.js render videos/<name> # final video
|
|
148
|
+
node bin/explainroo.js verify videos/<name>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`render` also writes subtitle files (`.srt` and `.vtt`) and a cover
|
|
152
|
+
image (`.cover.jpg`) next to the video. When scenes name chapters, it
|
|
153
|
+
writes `.chapters.txt` for the YouTube description and adds the chapters
|
|
154
|
+
to the MP4. `--format gif` makes a silent GIF instead, for a README or a
|
|
155
|
+
post. `verify` checks the MP4. It measures the loudness and looks for
|
|
156
|
+
black frames and silence. It also runs the speech check on the finished
|
|
157
|
+
sound to make sure the voice is still clear over the music.
|
|
158
|
+
|
|
159
|
+
11. **Tell the user** where the video and its subtitle files, chapters and
|
|
160
|
+
cover are, how long the video is, what verify said, and what you could
|
|
161
|
+
not check.
|
|
162
|
+
|
|
163
|
+
## How to write the narration
|
|
164
|
+
|
|
165
|
+
Unless the user asks for another style, write the way a person explains
|
|
166
|
+
something to a friend at a table.
|
|
167
|
+
|
|
168
|
+
- Use regular, down-to-earth English and everyday words. Explain things in
|
|
169
|
+
simple terms. If you need a technical word, say what it means the first
|
|
170
|
+
time.
|
|
171
|
+
- Keep sentences short, about 8 to 18 words, one idea each.
|
|
172
|
+
- Say who does what: "The browser asks a resolver."
|
|
173
|
+
- Every sentence adds a fact. Cut half sentences that repeat something.
|
|
174
|
+
- Do not use em dashes or dashes between phrases. Use a comma or a new
|
|
175
|
+
sentence.
|
|
176
|
+
- Leave out slogans and punchlines ("Just code."), "not X, but Y" twists,
|
|
177
|
+
colon reveals, chains of three short sentences, metaphors, and filler words
|
|
178
|
+
like "just", "simply", "really", "actually" and "exactly".
|
|
179
|
+
- Do not tell the viewer to do obvious things ("Let's dive in", "Stay tuned").
|
|
180
|
+
- End with a plain sentence that sums up the main point.
|
|
181
|
+
|
|
182
|
+
Length and pace:
|
|
183
|
+
|
|
184
|
+
- Aim for 45 to 120 seconds unless the user says otherwise. A finished video
|
|
185
|
+
has about 150 words a minute, pauses included. In Japanese it is about 270
|
|
186
|
+
characters a minute, and in Chinese about 200.
|
|
187
|
+
- Start with the question or problem. Explain it in small steps. Give one
|
|
188
|
+
concrete example, then sum up.
|
|
189
|
+
- One idea per scene, usually 1 to 3 sentences (4 to 15 seconds).
|
|
190
|
+
- Lists read aloud ("A, B, C and D") only work when each item appears on
|
|
191
|
+
screen.
|
|
192
|
+
|
|
193
|
+
Script syntax:
|
|
194
|
+
|
|
195
|
+
```markdown
|
|
196
|
+
# Title of the video
|
|
197
|
+
|
|
198
|
+
## scene-id {hold=1.5}
|
|
199
|
+
Narration for this scene. [#marker] A marker names a moment you can animate on.
|
|
200
|
+
[pause 0.6] adds silence. {SQL|sequel} shows "SQL" in captions but says "sequel".
|
|
201
|
+
> Lines starting with > are notes for you and are not spoken.
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
- `## scene-id` starts a scene. The id must match a function in `scenes.js`.
|
|
205
|
+
- Put a `[#marker]` wherever a picture should change. Every sentence should
|
|
206
|
+
trigger at least one picture.
|
|
207
|
+
- Use `{shown|spoken}` for anything the voice may misread: acronyms
|
|
208
|
+
(`{CLI|C L I}`), versions (`{v2.1|version two point one}`), symbols and
|
|
209
|
+
domains (`{example.com|example dot com}`, otherwise the voice says "example
|
|
210
|
+
comm").
|
|
211
|
+
- A scene can have these settings in the braces after its id: `hold`
|
|
212
|
+
(seconds after the voice, default 0.7), `min` (the shortest the scene can
|
|
213
|
+
be, in seconds), `lead` (seconds before the voice, default 0.35) and
|
|
214
|
+
`transition` (`fade`, `slide`, `wipe`, `zoom`, `brush`, `cut`).
|
|
215
|
+
- A scene without narration lasts `min` seconds (default 3).
|
|
216
|
+
- `chapter="How the resolver finds it"` in a scene's braces starts a
|
|
217
|
+
chapter at that scene. It lasts until the next chapter. Titles have 1 to
|
|
218
|
+
60 characters. If the first scene names no chapter, the first chapter is
|
|
219
|
+
the video title. YouTube shows chapters only when there are at least 3
|
|
220
|
+
and each lasts 10 seconds or more.
|
|
221
|
+
|
|
222
|
+
## What makes the pictures good
|
|
223
|
+
|
|
224
|
+
- **Show it when it is said.** A picture appears as the voice mentions it.
|
|
225
|
+
Use word cues.
|
|
226
|
+
- **Something changes every 2 to 4 seconds.** A new element, an arrow or a
|
|
227
|
+
highlight. The camera adds its own moves. `check` points out long stretches
|
|
228
|
+
where nothing new appears.
|
|
229
|
+
- **Short screen text.** Labels, numbers and key phrases of a few words. The
|
|
230
|
+
whole narration never goes on screen. When the narration should be readable,
|
|
231
|
+
turn on captions (`"captions": true`). Then do not also show the sentence
|
|
232
|
+
the voice is saying as text.
|
|
233
|
+
- **Few things at once.** At most five or six elements. Take things off the
|
|
234
|
+
screen with `out` before the next idea.
|
|
235
|
+
- **Big and readable.** Titles 80 to 110 px, labels 40 to 56 px, small text
|
|
236
|
+
at least 32 px on a 1920 x 1080 canvas. Stay inside `s.safe`.
|
|
237
|
+
- **Same meaning, same color.** Give each thing one color and one place and
|
|
238
|
+
keep them. Use the accent color for the one thing that matters most.
|
|
239
|
+
- **Real examples.** A command you can run, a number with its source or a
|
|
240
|
+
picture of the real screen is better than three boxes with general words.
|
|
241
|
+
- **A clear last frame** that shows the main point.
|
|
242
|
+
|
|
243
|
+
### Layouts that work
|
|
244
|
+
|
|
245
|
+
These four layouts cover many scenes: one big number, a comparison, steps in
|
|
246
|
+
order, and one main thing with its parts. Start from the one that fits and
|
|
247
|
+
change the words, colors and cues. Each one also works in tall and square
|
|
248
|
+
frames.
|
|
249
|
+
|
|
250
|
+
```js
|
|
251
|
+
export default {
|
|
252
|
+
// One big number with a short caption under it.
|
|
253
|
+
number(s) {
|
|
254
|
+
const u = Math.max(s.W, s.H) / 100;
|
|
255
|
+
// The number also has to fit across a narrow, tall frame.
|
|
256
|
+
const n = s.number(1000000, { y: s.cy - u * 2, size: Math.min(u * 10, s.safe.w / 6), at: '#number' });
|
|
257
|
+
s.text('requests a day', { y: n.bottom + u * 3, size: u * 3.6, color: 'muted', at: '#caption' });
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
// Two things side by side, or stacked in a tall frame.
|
|
261
|
+
compare(s) {
|
|
262
|
+
const u = Math.max(s.W, s.H) / 100;
|
|
263
|
+
const cells = s.grid(s.portrait ? 1 : 2, s.portrait ? 2 : 1, { gap: u * 4 });
|
|
264
|
+
const sides = [
|
|
265
|
+
{ title: 'Callbacks', note: 'one function inside another', color: 'orange', at: '#left' },
|
|
266
|
+
{ title: 'async / await', note: 'reads from top to bottom', color: 'green', at: '#right' },
|
|
267
|
+
];
|
|
268
|
+
sides.forEach(({ title, note, color, at }, i) => {
|
|
269
|
+
const c = cells[i];
|
|
270
|
+
// The note hangs from the card, so a note that wraps grows downward.
|
|
271
|
+
const card = s.box(title, { x: c.x, y: c.y - u * 3, w: c.w * 0.8, size: u * 4, color, at });
|
|
272
|
+
s.text(note, { x: c.x, y: card.bottom + u * 1.2, valign: 'top', size: u * 2.6, color: 'muted', maxWidth: c.w * 0.85, at });
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
// Steps in order, left to right, or top to bottom in a tall frame.
|
|
277
|
+
steps(s) {
|
|
278
|
+
const u = Math.max(s.W, s.H) / 100;
|
|
279
|
+
const labels = ['Browser', 'Resolver', 'Address'];
|
|
280
|
+
const xs = s.portrait ? labels.map(() => s.cx) : s.row(labels.length, { width: s.safe.w * 0.72 });
|
|
281
|
+
const ys = s.portrait ? s.col(labels.length) : labels.map(() => s.cy);
|
|
282
|
+
labels.forEach((label, i) => {
|
|
283
|
+
const at = i ? `#step${i + 1}` : 0.3;
|
|
284
|
+
s.box(label, { id: `step${i}`, x: xs[i], y: ys[i], size: u * 3.6, at });
|
|
285
|
+
if (i) s.arrow(`step${i - 1}`, `step${i}`, { at });
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
// One main thing with its parts around it. A tall frame has no room
|
|
290
|
+
// beside it, so the parts sit in a row underneath.
|
|
291
|
+
hub(s) {
|
|
292
|
+
const u = Math.max(s.W, s.H) / 100;
|
|
293
|
+
const parts = ['Email', 'Calendar', 'Files'];
|
|
294
|
+
const hubY = s.portrait ? s.cy - s.safe.h * 0.18 : s.cy;
|
|
295
|
+
const spots = s.portrait
|
|
296
|
+
? s.row(parts.length, { width: s.safe.w * 0.72 }).map((x) => ({ x, y: s.cy + s.safe.h * 0.16 }))
|
|
297
|
+
: [-90, 30, 150].map((d) => ({ x: s.cx + Math.cos((d * Math.PI) / 180) * s.safe.w * 0.34, y: s.cy + Math.sin((d * Math.PI) / 180) * s.safe.h * 0.3 }));
|
|
298
|
+
s.box('Login server', { id: 'hub', x: s.cx, y: hubY, size: u * 4, color: 'accent', at: '#hub' });
|
|
299
|
+
parts.forEach((label, i) => {
|
|
300
|
+
const at = `#spoke${i + 1}`;
|
|
301
|
+
s.box(label, { id: `part${i}`, ...spots[i], size: u * (s.portrait ? 2.4 : 3.2), at });
|
|
302
|
+
s.arrow('hub', `part${i}`, { at });
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Text sizes come from the frame's long side, so they look about the same in
|
|
309
|
+
wide and tall frames. A big number also has to fit across a narrow frame.
|
|
310
|
+
|
|
311
|
+
### The camera
|
|
312
|
+
|
|
313
|
+
explainroo films each scene with a camera that follows the narration. It
|
|
314
|
+
opens on the picture. When a scene starts small, the camera starts close and
|
|
315
|
+
widens as new things need room. Something new that already fits the shot
|
|
316
|
+
needs no move. Now and then the camera moves in on what the voice talks
|
|
317
|
+
about, for example a new card and the one it relates to, when the viewer has
|
|
318
|
+
time to look. Then it follows new things at that distance. Near the end of
|
|
319
|
+
the scene it pulls back, so the last frame shows the whole idea. During each
|
|
320
|
+
scene it also pushes in very slowly.
|
|
321
|
+
|
|
322
|
+
While a shot holds, every card and label is either fully in the shot or out
|
|
323
|
+
of it. Arrows and lines may run off the edge, but their labels stay whole, and
|
|
324
|
+
so do the labels of charts. While the camera moves from
|
|
325
|
+
one shot to the next, things may pass the edge of the frame for a moment.
|
|
326
|
+
Shots stay clear of the captions and of the parts the app covers on Shorts,
|
|
327
|
+
TikTok and Reels.
|
|
328
|
+
|
|
329
|
+
Lay out each scene as one picture on the full frame, the way it should look
|
|
330
|
+
at the end, and let the camera find the close-ups:
|
|
331
|
+
|
|
332
|
+
- Put the next element near the one it follows, so one shot shows both.
|
|
333
|
+
- A scene that starts with one thing and grows gets the most camera moves.
|
|
334
|
+
The camera starts close and widens with the picture.
|
|
335
|
+
- Keep a box with its label, or an icon with its caption, together as one
|
|
336
|
+
unit. Things far apart get their own shots.
|
|
337
|
+
- Lines, arrows and things added inside an element already on screen, like
|
|
338
|
+
a line in a chart, get no close-up of their own. Neither does an icon
|
|
339
|
+
without a label or a box without words, because up close it shows nothing
|
|
340
|
+
new. Give it a label, or use `s.focus` when one should get a close-up.
|
|
341
|
+
- When a scene goes on with the same picture, draw the carried elements with
|
|
342
|
+
`at: -1` in the same places. The camera then goes on from where it
|
|
343
|
+
stopped, and the two scenes fade into each other.
|
|
344
|
+
|
|
345
|
+
The camera measures every element, including what `s.draw` draws, and
|
|
346
|
+
follows the `at` and `out` times. It measures each element where it is at
|
|
347
|
+
the end of the scene. When something travels across the frame during a
|
|
348
|
+
scene, keep that scene's camera still with `s.camera([])`. Anything drawn straight on `s.ctx` counts
|
|
349
|
+
as one block that is there for the whole scene, so the camera keeps it whole
|
|
350
|
+
and cannot film it on its own. Use `s.draw` for a drawing that appears on a
|
|
351
|
+
cue. Highlighted code lines and terminal commands get close-ups of their own
|
|
352
|
+
when they are small in the shot. `s.focus` points the camera at any part of
|
|
353
|
+
the picture.
|
|
354
|
+
|
|
355
|
+
`s.camera([...])` in a scene takes over that scene's camera, and
|
|
356
|
+
`s.camera([])` keeps the scene still. `"camera": "still"` in `video.json`
|
|
357
|
+
turns the camera off for the whole video. `check` checks the layout as you
|
|
358
|
+
wrote it, without the camera. Stills, sheets and renders show the camera.
|
|
359
|
+
|
|
360
|
+
The final render adds motion blur to frames where something moves, like a
|
|
361
|
+
film camera. Drafts skip it. `"motionBlur": false` turns it off.
|
|
362
|
+
|
|
363
|
+
## Voices
|
|
364
|
+
|
|
365
|
+
Kokoro runs on this computer and needs no key. Pick a voice with
|
|
366
|
+
`explainroo voices`. A string in `video.json` keeps using Kokoro:
|
|
367
|
+
|
|
368
|
+
```json
|
|
369
|
+
"voice": "af_heart"
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
`{ "provider": "kokoro", "id": "af_heart" }` means the same thing.
|
|
373
|
+
|
|
374
|
+
ElevenLabs offers premium and cloned voices. It costs money on the user's
|
|
375
|
+
account and receives the script text. If the user wants it and there is no
|
|
376
|
+
key, ask them for an API key from elevenlabs.io. Set `ELEVENLABS_API_KEY` in
|
|
377
|
+
the environment, or save `ELEVENLABS_API_KEY=...` in a `.env` file in the
|
|
378
|
+
project folder or the explainroo folder. The environment takes priority,
|
|
379
|
+
then the project file. Never print the key, and never put it in a script,
|
|
380
|
+
a commit or a log. Keep `.env` out of git.
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
node bin/explainroo.js voices videos/<name> --elevenlabs
|
|
384
|
+
node bin/explainroo.js voices videos/<name> --elevenlabs --json
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
The list shows the names, ids and labels available to that key. Use an id
|
|
388
|
+
in `video.json`:
|
|
389
|
+
|
|
390
|
+
```json
|
|
391
|
+
"voice": { "provider": "elevenlabs", "id": "JBFqnCBsd6RMkjVDRZzb", "model": "eleven_multilingual_v2" }
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
`model` is optional and defaults to `eleven_multilingual_v2`. The voice
|
|
395
|
+
command reports the characters used. Each request is saved in
|
|
396
|
+
`build/voice/elevenlabs-usage.jsonl`, without the key or script text.
|
|
397
|
+
ElevenLabs uses `speed` times `pace`, limited to 0.7 through 1.2.
|
|
398
|
+
The voice command tells you when it uses that limit.
|
|
399
|
+
|
|
400
|
+
You can also record the narration yourself. Use a quiet room and read
|
|
401
|
+
script.md as written. Put one take for the whole video in `assets/`:
|
|
402
|
+
|
|
403
|
+
```json
|
|
404
|
+
"voice": { "provider": "recording", "src": "assets/narration.m4a" }
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Or put one file per scene in a folder:
|
|
408
|
+
|
|
409
|
+
```json
|
|
410
|
+
"voice": { "provider": "recording", "src": "assets/narration/" }
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Each scene with narration needs `<scene-id>.<ext>`, for example `intro.wav`.
|
|
414
|
+
Supported formats are wav, mp3, m4a, aac, flac, ogg and opus. Files must stay
|
|
415
|
+
inside `assets/`, with no `..` in the path.
|
|
416
|
+
|
|
417
|
+
One take is split into scenes using the words in script.md. Each cut keeps
|
|
418
|
+
about 0.15 seconds around the speech. Pauses within a scene stay as recorded.
|
|
419
|
+
The scene's `lead` and `hold` add the gaps between scenes. Recordings are
|
|
420
|
+
made mono and their volume is brought close to Kokoro's. Their sample rate
|
|
421
|
+
is kept up to 48 kHz. Changing `pace` or an explicit `speed` changes their
|
|
422
|
+
tempo without changing pitch.
|
|
423
|
+
|
|
424
|
+
`[pause]`, `sentenceGap` and `paragraphGap` do not add silence to recordings.
|
|
425
|
+
Markers `[#name]`, captions, cues and `{shown|spoken}` still work. If the
|
|
426
|
+
speech check reports a mismatch, make script.md say what was actually said.
|
|
427
|
+
Replacing a scene recording makes that scene again. Replacing a whole take
|
|
428
|
+
makes all its scenes again.
|
|
429
|
+
|
|
430
|
+
ElevenLabs narration and recordings work in every supported language.
|
|
431
|
+
Run `voice`, `check` and `render` as usual with any of the three sources.
|
|
432
|
+
|
|
433
|
+
## Videos in other languages
|
|
434
|
+
|
|
435
|
+
Set `language` in `video.json` to `en`, `es`, `fr`, `it`, `pt-br`, `hi`,
|
|
436
|
+
`ja` or `zh`. English is the default. `pt-br` means Brazilian Portuguese and
|
|
437
|
+
`zh` Mandarin Chinese. You can also start with
|
|
438
|
+
`explainroo init videos/my-video --language es`.
|
|
439
|
+
|
|
440
|
+
When `voice` is left out, the language picks its Kokoro voice:
|
|
441
|
+
|
|
442
|
+
| Language | Default voice |
|
|
443
|
+
|---|---|
|
|
444
|
+
| English (`en`) | `af_heart` |
|
|
445
|
+
| Spanish (`es`) | `ef_dora` |
|
|
446
|
+
| French (`fr`) | `ff_siwis` |
|
|
447
|
+
| Italian (`it`) | `if_sara` |
|
|
448
|
+
| Brazilian Portuguese (`pt-br`) | `pf_dora` |
|
|
449
|
+
| Hindi (`hi`) | `hf_alpha` |
|
|
450
|
+
| Japanese (`ja`) | `jf_alpha` |
|
|
451
|
+
| Mandarin Chinese (`zh`) | `zf_xiaobei` |
|
|
452
|
+
|
|
453
|
+
Run `explainroo voices --language es` to see voices for one language.
|
|
454
|
+
A Kokoro voice must match the video's language. If a project already has
|
|
455
|
+
`voice` set, change it too, or remove it to use the default.
|
|
456
|
+
|
|
457
|
+
Write the narration in that language as a person would say it. Do not
|
|
458
|
+
translate English word for word. The writing rules above apply in spirit.
|
|
459
|
+
Cue words and `[#markers]` work the same. `at: 'qué'` matches "Qué".
|
|
460
|
+
Hindi sentences can end with `।`. Captions and subtitle files keep the
|
|
461
|
+
written text. The looks include a Hindi font, so no system font is needed.
|
|
462
|
+
|
|
463
|
+
Spanish, French, Italian, Portuguese and Hindi need the espeak-ng program.
|
|
464
|
+
Install it on Linux
|
|
465
|
+
with `sudo apt install espeak-ng`, or on macOS with `brew install espeak-ng`.
|
|
466
|
+
On Windows, use the installer from the
|
|
467
|
+
[espeak-ng releases page](https://github.com/espeak-ng/espeak-ng/releases).
|
|
468
|
+
If the program is in another place, set `EXPLAINROO_ESPEAK` to its binary.
|
|
469
|
+
English, Japanese, Chinese, ElevenLabs and recordings do not need it.
|
|
470
|
+
|
|
471
|
+
### Japanese and Chinese
|
|
472
|
+
|
|
473
|
+
Japanese and Chinese need Python 3 with misaki, the pronunciation library
|
|
474
|
+
Kokoro's voices were trained with. Install what the language needs:
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
python3 -m pip install "misaki[ja]" # Japanese
|
|
478
|
+
python3 -m unidic download # Japanese dictionary, about 526 MB
|
|
479
|
+
python3 -m pip install "misaki[zh]" # Chinese
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
On Windows, write `python` instead of `python3`. If misaki is in a virtual
|
|
483
|
+
environment, set `EXPLAINROO_PYTHON` to that environment's Python.
|
|
484
|
+
ElevenLabs and recordings need neither.
|
|
485
|
+
|
|
486
|
+
Write the narration as usual, without spaces between words. explainroo
|
|
487
|
+
finds the words itself, so cue words and markers work: `at: '解析'` matches
|
|
488
|
+
the word 解析, and a phrase like `at: '名前の解析'` works too. A cue must
|
|
489
|
+
match whole words. Put a `[#marker]` where you need a moment inside a word.
|
|
490
|
+
Sentences end with `。`, `!` or `?`.
|
|
491
|
+
|
|
492
|
+
Latin words such as API or JavaScript are read in English. For a Japanese
|
|
493
|
+
reading, write it out: `{API|エーピーアイ}`. Numbers can stay in digits,
|
|
494
|
+
including decimals like 365.2422. The Japanese reader sometimes picks the
|
|
495
|
+
wrong reading for a word, such as ついたち for 一日 (write `1日` for
|
|
496
|
+
いちにち) or こよみ for 暦 in グレゴリオ暦 (write `{グレゴリオ暦|グレゴリオれき}`).
|
|
497
|
+
When the speech check flags a word, compare what it heard with the script
|
|
498
|
+
before you change anything.
|
|
499
|
+
|
|
500
|
+
Whisper often writes a word with other characters that sound the same, so
|
|
501
|
+
the speech check compares sounds. Japanese is compared by its kana reading,
|
|
502
|
+
so 世紀 heard as 正規 still counts. Chinese is compared by pinyin without
|
|
503
|
+
tones, and Traditional and Simplified characters count as the same. So do
|
|
504
|
+
not reword a sentence only because Whisper chose other characters. Captions
|
|
505
|
+
and subtitles join words without spaces, with up to 18 characters per
|
|
506
|
+
subtitle line, and never break inside a word. Keep the shown text of an
|
|
507
|
+
override short.
|
|
508
|
+
|
|
509
|
+
The looks' fonts have no Japanese or Chinese characters. The first `voice`,
|
|
510
|
+
`still` or `render` downloads Noto Sans JP or Noto Sans SC, regular and bold,
|
|
511
|
+
about 33 MB, and checks the files. They are saved in
|
|
512
|
+
`~/.cache/explainroo/fonts/` (or `$EXPLAINROO_CACHE/fonts/`) and used in
|
|
513
|
+
every look, in captions and in app screens. After that first download,
|
|
514
|
+
`EXPLAINROO_OFFLINE=1` works. A web player made with `export` keeps only
|
|
515
|
+
the characters the video shows, so its fonts stay small.
|
|
516
|
+
|
|
517
|
+
The first speech check in another language downloads multilingual Whisper
|
|
518
|
+
small. `doctor --fetch` still fetches only the English models. `verify`
|
|
519
|
+
uses the video's language to check the finished sound too.
|
|
520
|
+
|
|
521
|
+
If a symbol, short form or word sounds wrong, use `{shown|spoken}` in
|
|
522
|
+
`script.md` and run `voice` again. Put the pronunciation in the same
|
|
523
|
+
language. The speech check accepts digits for numbers. It does not try to
|
|
524
|
+
match spelled numbers to digits outside English. Write the digits, or use
|
|
525
|
+
an override whose spoken text has digits when that helps the check.
|
|
526
|
+
|
|
527
|
+
In Hindi, the speech check confirms fewer words than in the other languages,
|
|
528
|
+
because the speech model knows Hindi less well. A few unconfirmed words are
|
|
529
|
+
normal there. Fix a word when it stays unconfirmed in several scenes, or
|
|
530
|
+
when the user hears it wrong.
|
|
531
|
+
|
|
532
|
+
## Images
|
|
533
|
+
|
|
534
|
+
explainroo can make illustrations with AI image models through OpenRouter.
|
|
535
|
+
This is optional. It costs money on the user's OpenRouter account, roughly 7
|
|
536
|
+
to 13 cents per image at the time of writing.
|
|
537
|
+
|
|
538
|
+
If the user wants images and there is no key, ask them for an OpenRouter API
|
|
539
|
+
key (from openrouter.ai/keys). Save it in a `.env` file in the explainroo
|
|
540
|
+
folder as `OPENROUTER_API_KEY=...`, or set it as an environment variable. Git
|
|
541
|
+
ignores `.env`. Never print the key, and never put it in a script, a commit
|
|
542
|
+
or a log.
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
node bin/explainroo.js image videos/<name> cables "Two cars parked nose to nose with their hoods open, jumper cables between the batteries"
|
|
546
|
+
node bin/explainroo.js images videos/<name> # what was made and what it cost
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
This saves `assets/cables.png`. Use it in a scene with
|
|
550
|
+
`s.image('assets/cables.png', { w: 1100, frame: 'card', at: 'cables' })`.
|
|
551
|
+
|
|
552
|
+
- `--model best` (default) uses OpenAI GPT Image 2. It does what you ask and
|
|
553
|
+
is worth the price for most images.
|
|
554
|
+
- `--model cheap` uses Google Gemini 3.1 Flash Image. It costs about half,
|
|
555
|
+
but it often ignores parts of the prompt.
|
|
556
|
+
- `--aspect` sets the shape of the image: `16:9` (default for landscape
|
|
557
|
+
videos), `9:16`, `1:1`, `4:3`, `3:2` and their portrait forms.
|
|
558
|
+
- `--ref assets/a.png` sends an earlier image along, so a person or object
|
|
559
|
+
keeps the same look. Separate several files with commas.
|
|
560
|
+
- Every image gets a default style (flat, soft colors, no text). Set your own
|
|
561
|
+
in `video.json` with `"images": { "style": "...", "model": "best" }`, or
|
|
562
|
+
turn the style off with `--no-style`.
|
|
563
|
+
|
|
564
|
+
**Always open every image and check it.** Image models get details wrong:
|
|
565
|
+
extra fingers, cables on the wrong terminal, text that looks like writing but
|
|
566
|
+
is not. If anything is wrong, change the prompt and make the image again.
|
|
567
|
+
Keep text out of images. Put words on screen with `s.text` instead. Use
|
|
568
|
+
images for things icons cannot show, and keep one style through the whole
|
|
569
|
+
video.
|
|
570
|
+
|
|
571
|
+
## Product demos
|
|
572
|
+
|
|
573
|
+
A product demo is the kind of video software companies make to show their
|
|
574
|
+
app. You rebuild the app's screens with `s.ui`, which has cards, fields,
|
|
575
|
+
buttons, dropdowns, toggles and status labels in the app's colors and fonts.
|
|
576
|
+
A mouse pointer clicks through the screens and types into the fields, and the
|
|
577
|
+
camera zooms in on what the voice talks about. `examples/unspar-demo` is a
|
|
578
|
+
complete one.
|
|
579
|
+
|
|
580
|
+
**Capture the live site first.**
|
|
581
|
+
|
|
582
|
+
```bash
|
|
583
|
+
node bin/explainroo.js capture videos/<name> https://example.com --mobile
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
`capture` opens the page in a fresh browser, without cookies or logins, and
|
|
587
|
+
saves what a demo needs in `assets/capture/<hostname>/`:
|
|
588
|
+
|
|
589
|
+
- `page.png` (the first screen) and `full.png` (the whole page, up to 8000
|
|
590
|
+
pixels tall), at twice the pixel density, so they stay sharp when the
|
|
591
|
+
camera zooms in. `--mobile` adds `mobile.png` and `mobile-full.png`.
|
|
592
|
+
- `capture.json` with the colors, fonts, logo candidates and the page's
|
|
593
|
+
wording: headings, navigation, buttons and form labels. Copy the wording
|
|
594
|
+
exactly. The live site is the source of truth for claims and wording.
|
|
595
|
+
- Up to three logo files, and the font files that come from Google Fonts, in
|
|
596
|
+
the weights the page uses.
|
|
597
|
+
|
|
598
|
+
It prints a `brand` and `fonts` block to paste into `video.json`. Check it
|
|
599
|
+
against the screenshots. Fonts built into explainroo need no files. For other
|
|
600
|
+
fonts, get the files, check the license and copy the license file next to
|
|
601
|
+
them. Cookie banners and chat widgets can appear in the screenshots, as they
|
|
602
|
+
do for any visitor. Use a screenshot, or a part of one, without them.
|
|
603
|
+
Capturing the same site again replaces its folder.
|
|
604
|
+
|
|
605
|
+
You can also show a real screen recording with `s.clip` in a `browser`
|
|
606
|
+
frame. Use `s.camera` to zoom in on the detail the voice mentions.
|
|
607
|
+
|
|
608
|
+
**Keep it true.** A demo is advertising, so everything in it has to be right.
|
|
609
|
+
|
|
610
|
+
- Take the wording from the app itself: its templates and language files
|
|
611
|
+
(for example `lang/en/*.php`, `locales/`, or the components). Copy labels,
|
|
612
|
+
buttons and status names exactly.
|
|
613
|
+
- Show only features that exist and that customers can use. Leave out admin
|
|
614
|
+
screens, debug views and plans that are not built yet.
|
|
615
|
+
- Example data must look like example data: `example.com`, a made up project,
|
|
616
|
+
a made up article title. Never invent customers, numbers or results.
|
|
617
|
+
- Claims in the narration come from the product's live website. Show prices
|
|
618
|
+
only if the website shows them.
|
|
619
|
+
- Ask the user if the website and the app say different things.
|
|
620
|
+
|
|
621
|
+
**Set up the brand** in `video.json`. Use the `clean` look.
|
|
622
|
+
|
|
623
|
+
```json
|
|
624
|
+
{
|
|
625
|
+
"theme": "clean",
|
|
626
|
+
"brand": {
|
|
627
|
+
"accent": "#245cff",
|
|
628
|
+
"background": "#f8f6f1",
|
|
629
|
+
"font": "Figtree",
|
|
630
|
+
"headline": "Instrument Serif",
|
|
631
|
+
"logo": "assets/logo.svg"
|
|
632
|
+
},
|
|
633
|
+
"fonts": [
|
|
634
|
+
{ "family": "Figtree", "src": "assets/fonts/Figtree-600.woff2", "weight": 600 }
|
|
635
|
+
]
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
- `accent` is the main button color. Find it in the app's Tailwind config or
|
|
640
|
+
CSS. `background` is the color behind the screens, `ink` the color of text
|
|
641
|
+
drawn right on it.
|
|
642
|
+
- `font` is the app's font. Inter is built in; other fonts go in
|
|
643
|
+
`assets/fonts/` and in `fonts` (`.woff2`, `.woff`, `.ttf` or `.otf`, one
|
|
644
|
+
entry per weight, or `"weight": "100 900"` for a variable font, and
|
|
645
|
+
`"style": "italic"`). Copy the font's license file next to it.
|
|
646
|
+
- `headline` is the font for big headlines. Instrument Serif is built in. If
|
|
647
|
+
the brand has no serif, use its own font and pass `{ weight: 700,
|
|
648
|
+
italic: false }` to `u.headline()`.
|
|
649
|
+
- `logo` is the product's logo from the app or website, best as SVG.
|
|
650
|
+
|
|
651
|
+
**Build a scene** in this order: background, camera, headline, screens,
|
|
652
|
+
cursor last so it stays on top.
|
|
653
|
+
|
|
654
|
+
```js
|
|
655
|
+
hook(s) {
|
|
656
|
+
const u = s.ui;
|
|
657
|
+
u.backdrop();
|
|
658
|
+
u.floaters();
|
|
659
|
+
s.camera([{ at: '#site', x: 900, y: 600, zoom: 1.3 }]);
|
|
660
|
+
u.headline('Tell it what to *write about*', s.W / 2, 178, { size: 84, at: 0.15 });
|
|
661
|
+
u.panel(410, 270, 1100, 600, { at: 0.3 }, (x, y, w, h) => {
|
|
662
|
+
u.input(x + 56, y + 296, 560, 62, { label: 'Website URL', value: u.typed('https://example.com', '#site', 24), focus: 1, caret: true });
|
|
663
|
+
u.button('Get ideas', x + 760, y + 516, 280, 60, { press: u.press('#go') });
|
|
664
|
+
});
|
|
665
|
+
u.cursor([
|
|
666
|
+
{ at: 0.5, x: 1500, y: 900 },
|
|
667
|
+
{ at: s.time('#site') - 0.7, x: 740, y: 596 },
|
|
668
|
+
{ at: '#site', click: true },
|
|
669
|
+
]);
|
|
670
|
+
}
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
Draw the headline after `s.camera()`, or the zoomed screens slide under it.
|
|
674
|
+
When the camera zooms in, either keep the headline fully in view (zoom up to
|
|
675
|
+
about 1.1) or zoom far enough that it leaves the frame (about 1.3 and more).
|
|
676
|
+
In between it gets cut in half.
|
|
677
|
+
|
|
678
|
+
Time every click to a `[#mark]` in the script, so it happens when the voice
|
|
679
|
+
says it. A cursor move starts at its `at` and arrives `dur` seconds later
|
|
680
|
+
(0.7 by default), so start the move a little more than `dur` before the
|
|
681
|
+
click. The first 0.7 seconds of a scene are covered by the transition from
|
|
682
|
+
the scene before, so put no clicks there.
|
|
683
|
+
|
|
684
|
+
The watermark sits in the bottom right corner. When the camera zooms in, it
|
|
685
|
+
can cover what is there, so keep important text out of that corner.
|
|
686
|
+
|
|
687
|
+
Use the product's name as plain text in the first frame. The first frame is
|
|
688
|
+
also the video's cover.
|
|
689
|
+
|
|
690
|
+
**`s.ui` reference.** Positions are in the frame (1920 wide for 16:9). Times
|
|
691
|
+
take seconds, spoken words or `"#marks"`, like everywhere else.
|
|
692
|
+
|
|
693
|
+
| Call | What it draws |
|
|
694
|
+
|---|---|
|
|
695
|
+
| `u.backdrop(color?)`, `u.floaters({ alpha, tint })` | the brand background, and faint cards drifting around the edges (`tint: 'white'` on a colored background) |
|
|
696
|
+
| `u.panel(x, y, w, h, { at, out, from, rise, sfx, fill, border, lift }, fn)` | a card that pops in at `at`; `fn(x, y, w, h)` draws inside it |
|
|
697
|
+
| `u.card(x, y, w, h, o)` | a card without an entrance |
|
|
698
|
+
| `u.browser(x, y, w, h, { url, at }, fn)` | a panel with a browser bar; `fn` gets the page area |
|
|
699
|
+
| `u.modal(x, y, w, h, { at, out }, fn)`, `u.over(fn)` | a dialog over a dimmed frame, and a layer for your own menus or popups; `check` does not report text in one layer as overlapping text in another |
|
|
700
|
+
| `u.toast(text, { at, out, icon, tone })` | a message that slides up, with a chime |
|
|
701
|
+
| `u.headline(text, x, y, { size, at, out, align, weight, italic, color, accent, tracking })` | big text that blurs in word by word; `*stars*` mark words in the `accent` color |
|
|
702
|
+
| `u.text(text, x, y, { size, weight, color, align, base, font, italic, tracking, alpha, maxW, check })`, `u.para(text, x, y, maxW, o)`, `u.eyebrow(text, x, y)` | text, wrapped text (`\n` starts a new line), and a small uppercase label; `font` is `'ui'`, `'headline'` or a family; `check: false` hides text from `check`; `u.measure(text, size, weight)` gives the width |
|
|
703
|
+
| `u.button(label, x, y, w, h, { variant, press, icon, loading, color, caps })` | `primary`, `secondary` or `ghost` |
|
|
704
|
+
| `u.input(x, y, w, h, { label, value, placeholder, focus, caret, icon })`, `u.textarea(x, y, w, h, o)` | a text field, and a taller one where the text wraps |
|
|
705
|
+
| `u.select(x, y, w, h, { label, value, open, options, hover, selected })` | a dropdown; returns the y of each option row |
|
|
706
|
+
| `u.toggle(x, y, on)`, `u.checkbox(x, y, on)`, `u.radio(x, y, on)` | `on` goes from 0 to 1, so it can animate |
|
|
707
|
+
| `u.chip(label, x, y, { selected })`, `u.chipWidth(label, o, selected)` | option chips; a selected chip grows by its check mark, so leave room |
|
|
708
|
+
| `u.pill(label, x, y, tone, { align, dot, pulse })` | a status badge: `gray`, `blue`, `yellow`, `green`, `red`, `purple` or `accent` |
|
|
709
|
+
| `u.spinner(x, y, r)`, `u.progress(x, y, w, p)`, `u.avatar(x, y, r, initials, { image })`, `u.icon(name, x, y, size, color)`, `u.lines(x, y, w, n)`, `u.logo(x, y, w)` | small parts; `lines` draws grey bars in place of body text |
|
|
710
|
+
| `u.pop(at, cx, cy, fn, { sfx })` | pops anything in around a point |
|
|
711
|
+
| `u.wipe(at, { color })` | the accent color spreads out until it fills the frame |
|
|
712
|
+
| `u.cursor(keys, { out })` | the mouse; a key `{ at, x, y, dur, arc }` moves it (`arc` bends the path, 0 is straight), `{ at, click: true }` clicks with a sound |
|
|
713
|
+
| `u.press(at)`, `u.typed(text, at, cps, { gain, sfx })`, `u.stream(text, at, wps)`, `u.count(to, at, dur)` | a button press (0 to 1 and back), text typed so far with typing sounds, text appearing word by word like an AI reply, a number counting up |
|
|
714
|
+
| `u.colors` | `accent`, `accentDark`, `accentTint`, `background`, `ink`, `text`, `soft`, `muted`, `faint`, `line`, `field`, `surface`, `panel`; `brand.colors` in `video.json` replaces the grays, for example `{ "text": "#141413", "line": "#e8e6dc" }` for a warm brand |
|
|
715
|
+
|
|
716
|
+
`check` sees the text of `s.ui` too. It reports text that runs off the frame
|
|
717
|
+
(not while the camera zooms in), text that is too small and text that
|
|
718
|
+
overlaps. A dropdown or dialog may cover what is under it. Look at stills at
|
|
719
|
+
the moments the camera is zoomed in, and check the cursor does not hide the
|
|
720
|
+
word it points at.
|
|
721
|
+
|
|
722
|
+
Panels and headlines from `s.ui` make no sound unless you pass `sfx`.
|
|
723
|
+
`check` does not see clipping: text you hide by clipping still counts, so
|
|
724
|
+
do not draw text that should not show. Try a product name with its plain
|
|
725
|
+
spelling first; only respell it when the speech check mishears it.
|
|
726
|
+
|
|
727
|
+
Many sounds under the voice make it hard to follow, and `verify` then
|
|
728
|
+
understands less of it. Keep long typing quiet (`u.typed(text, at, cps, {
|
|
729
|
+
gain: 0.25 })`) and give each moment one sound, not three.
|
|
730
|
+
|
|
731
|
+
A blur filter on every frame makes rendering slow. The kit blurs things once
|
|
732
|
+
and reuses them. Do the same if you add your own blur.
|
|
733
|
+
|
|
734
|
+
## Sizes for each platform
|
|
735
|
+
|
|
736
|
+
Set `size` to the place the video goes. `explainroo formats` lists the sizes.
|
|
737
|
+
|
|
738
|
+
| Size | Pixels | For |
|
|
739
|
+
|---|---|---|
|
|
740
|
+
| `youtube` (or `16:9`) | 1920 x 1080 | YouTube and other wide players |
|
|
741
|
+
| `shorts` | 1080 x 1920 | YouTube Shorts |
|
|
742
|
+
| `tiktok` | 1080 x 1920 | TikTok |
|
|
743
|
+
| `reels` | 1080 x 1920 | Instagram and Facebook Reels |
|
|
744
|
+
| `vertical` | 1080 x 1920 | one file for Shorts, TikTok and Reels |
|
|
745
|
+
| `instagram` | 1080 x 1350 | Instagram and Facebook feed posts |
|
|
746
|
+
| `linkedin` | 1080 x 1350 | the LinkedIn feed |
|
|
747
|
+
| `square` (or `1:1`) | 1080 x 1080 | square posts on X, LinkedIn and Facebook |
|
|
748
|
+
|
|
749
|
+
`9:16`, `4:5` and `WIDTHxHEIGHT` also work.
|
|
750
|
+
|
|
751
|
+
YouTube and LinkedIn take the `.srt` file as captions when you upload the
|
|
752
|
+
video.
|
|
753
|
+
|
|
754
|
+
Shorts, TikTok and Reels put their own buttons, the account name and the post
|
|
755
|
+
text on top of the video. With `shorts`, `tiktok`, `reels` and `vertical`,
|
|
756
|
+
explainroo keeps your content away from those spots. `s.safe` is the part the
|
|
757
|
+
app leaves free, and `s.cx` and `s.cy` are its center. The captions sit right
|
|
758
|
+
above the app's bottom band, and the watermark moves to the top right corner.
|
|
759
|
+
`check` warns about any text outside that area. Plain `9:16` has no such
|
|
760
|
+
margins, so use it only when the video is not meant for those apps.
|
|
761
|
+
|
|
762
|
+
Vertical videos have little room. Stack things instead of putting them side
|
|
763
|
+
by side, use fewer words on screen, and place everything from `s.safe`.
|
|
764
|
+
`explainroo formats` prints the content area of each size in pixels, for
|
|
765
|
+
example 745 x 746 on TikTok.
|
|
766
|
+
|
|
767
|
+
### Where the captions sit
|
|
768
|
+
|
|
769
|
+
Captions are on by default for vertical, 4:5 and square videos. On Shorts,
|
|
770
|
+
TikTok and Reels they sit right above the app's bottom band. On 4:5, square
|
|
771
|
+
and wide videos they sit at the bottom, above the watermark. On a plain
|
|
772
|
+
`9:16` video they sit about a quarter of the way up. In every case `s.safe`
|
|
773
|
+
ends above them. So anything placed inside `s.safe` stays clear of them, and
|
|
774
|
+
`check` warns about text in the caption band. Do not put the same sentence on
|
|
775
|
+
screen as text while the captions show it.
|
|
776
|
+
|
|
777
|
+
The first frame is often the cover picture on social apps. When the first
|
|
778
|
+
elements draw themselves in, frame one is empty. Give the title
|
|
779
|
+
`enter: 'none'` so it is there from the first frame, or pick another cover
|
|
780
|
+
frame in the app.
|
|
781
|
+
|
|
782
|
+
## One project, several sizes
|
|
783
|
+
|
|
784
|
+
Use `--size <size>` on `preview`, `still`, `sheet`, `check` and `render`
|
|
785
|
+
to use another size for one run. It leaves `video.json` alone. The narration
|
|
786
|
+
and word times are shared between sizes. Captions set to `"auto"` follow
|
|
787
|
+
the size you choose.
|
|
788
|
+
|
|
789
|
+
Place things from `s.safe`, `s.cx`, `s.cy`, `s.row`, `s.col` and `s.grid`
|
|
790
|
+
instead of fixed pixel positions. Use `s.portrait` to stack things in tall
|
|
791
|
+
frames. Keep text sizes relative to the frame, for example `s.W * 0.05`.
|
|
792
|
+
`examples/merge-vs-rebase` works in `9:16` and in `youtube`; its scenes.js
|
|
793
|
+
shows one way to do it.
|
|
794
|
+
|
|
795
|
+
```js
|
|
796
|
+
intro(s) {
|
|
797
|
+
const cells = s.grid(s.portrait ? 1 : 2, s.portrait ? 2 : 1);
|
|
798
|
+
['Question', 'Answer'].forEach((label, i) => {
|
|
799
|
+
const { x, y, w, h } = cells[i];
|
|
800
|
+
s.box(label, { x, y, w: w * 0.8, h: h * 0.6,
|
|
801
|
+
size: s.W * 0.05, at: i ? '#answer' : 0 });
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
For every size, run `check --size <size>` and look at
|
|
807
|
+
`sheet --size <size>`. Fix cut-off text and overlaps. Then run
|
|
808
|
+
`render --size <size>` for each size.
|
|
809
|
+
|
|
810
|
+
`render --size tiktok` writes `out/video-tiktok.mp4` and matching subtitle,
|
|
811
|
+
cover and chapter files. With `--draft`, it writes `draft-tiktok.mp4`.
|
|
812
|
+
Stills go in `out/stills-tiktok/`. A sheet is `out/sheet-tiktok.jpg`, or
|
|
813
|
+
`out/sheet-intro-tiktok.jpg` with `--scene intro`. Ratios use a hyphen in
|
|
814
|
+
file names, for example `video-9-16.mp4`. Without `--size`, names stay the
|
|
815
|
+
same. `render --out` still sets the file name you choose.
|
|
816
|
+
|
|
817
|
+
## Pace
|
|
818
|
+
|
|
819
|
+
`pace` makes the whole video quicker or slower. At 1.3 the voice speaks about
|
|
820
|
+
30% faster. The voice model does not speed up exactly, so check the length
|
|
821
|
+
`voice` reports. The pauses, the time before and after each scene, the transitions and
|
|
822
|
+
every animation also get 30% shorter. Word and marker cues follow the voice.
|
|
823
|
+
So if you tie pictures to words, the rhythm stays right at any pace. Times in
|
|
824
|
+
seconds are real seconds of the scene, like `s.t` and `s.cue()`. So
|
|
825
|
+
`at: s.cue('word') + 0.3` means 0.3 seconds after the word at any pace. A
|
|
826
|
+
fixed time like `at: 4` does not move with the pace. That is one more reason
|
|
827
|
+
to use cues. 1 is the normal pace. 1.15 to 1.3 suits social media and viewers
|
|
828
|
+
who know the topic. Above 1.4 the video gets hard to follow. `speed` changes
|
|
829
|
+
only the voice. Its default is 0.9 for Kokoro and 1 for the other sources.
|
|
830
|
+
|
|
831
|
+
## The watermark
|
|
832
|
+
|
|
833
|
+
Every video gets a small "explainroo.com" in the bottom right corner. On
|
|
834
|
+
Shorts, TikTok and Reels it sits in the top right corner, because the app
|
|
835
|
+
covers the bottom one. The user can turn it off with `"watermark": false` in
|
|
836
|
+
`video.json`, or change it to their own text. If the user asks about it, tell
|
|
837
|
+
them it is their choice, and that keeping it helps more people find this free
|
|
838
|
+
project.
|
|
839
|
+
|
|
840
|
+
## Project files and settings
|
|
841
|
+
|
|
842
|
+
```
|
|
843
|
+
videos/<name>/
|
|
844
|
+
video.json look, size, language, voice, music, captions, watermark
|
|
845
|
+
script.md the narration, one "## scene-id" per scene
|
|
846
|
+
scenes.js one drawing function per scene
|
|
847
|
+
assets/ images: screenshots, logos, generated illustrations
|
|
848
|
+
build/ voice, timing and audio made by explainroo (safe to delete)
|
|
849
|
+
out/ video.mp4, draft.mp4, stills/, sheets, report.json
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
`video.json` settings, all optional:
|
|
853
|
+
|
|
854
|
+
| Setting | Default | What it does |
|
|
855
|
+
|---|---|---|
|
|
856
|
+
| `title` | from the script | shown in the preview |
|
|
857
|
+
| `theme` | `paper` | a built-in look, or a relative path to a `.json` look file (see Custom looks) |
|
|
858
|
+
| `size` | `16:9` | a platform (`youtube`, `shorts`, `tiktok`, `reels`, `vertical`, `instagram`, `linkedin`, `square`), `16:9`, `9:16`, `1:1`, `4:5` or `WIDTHxHEIGHT` |
|
|
859
|
+
| `fps` | 30 | 24, 25, 30, 50 or 60 |
|
|
860
|
+
| `language` | `en` | narration language: `en`, `es`, `fr`, `it`, `pt-br`, `hi`, `ja` or `zh`; see Videos in other languages |
|
|
861
|
+
| `voice` | the language's voice | a Kokoro id or a provider object for Kokoro, ElevenLabs or a recording; English uses `af_heart`; see Voices |
|
|
862
|
+
| `speed` | 0.9 for Kokoro, 1 otherwise | voice speed only, 0.6 to 1.6; ElevenLabs limits speed times pace to 0.7 through 1.2 |
|
|
863
|
+
| `pace` | 1 | speed of the whole video (voice, pauses, animations), 0.7 to 1.6 |
|
|
864
|
+
| `music` | `true` | `true` (the look's style), `warm`, `upbeat`, `calm`, `tech`, `playful`, `{ "style", "volume" }` or `false` |
|
|
865
|
+
| `sfx` | `true` | sound effects: `true`, `"minimal"` or `false` |
|
|
866
|
+
| `captions` | `"auto"` | text of the narration at the bottom; auto turns it on for vertical and square videos |
|
|
867
|
+
| `cover` | `"auto"` | full-size JPEG, without captions, at the end of the first scene, or a still spec: `12.5`, `"intro"`, `"intro@2.4"`, `"intro@end"` |
|
|
868
|
+
| `transition` | `"auto"` | the look's default, or `fade`, `slide`, `wipe`, `zoom`, `brush`, `cut` |
|
|
869
|
+
| `camera` | `"auto"` | `"auto"` films each scene with a camera that follows the narration; `"still"` keeps every frame as written |
|
|
870
|
+
| `motionBlur` | `true` | motion blur on moving frames in the final render |
|
|
871
|
+
| `lead`, `hold`, `end` | 0.35, 0.7, 1.4 | seconds before the voice, after it, and extra at the very end |
|
|
872
|
+
| `sentenceGap`, `paragraphGap` | 0.3, 0.55 | pauses in generated narration; recordings keep their own pauses |
|
|
873
|
+
| `loudness` | -14 | target loudness in LUFS |
|
|
874
|
+
| `boil` | 0 | redraws per second of hand-drawn lines; 0 keeps them still |
|
|
875
|
+
| `watermark` | `"explainroo.com"` | small text in a corner, or `false` |
|
|
876
|
+
| `images` | none | `{ "model": "best" or "cheap", "style": "..." }` |
|
|
877
|
+
| `brand` | none | colors, fonts and logo for `s.ui`, see [Product demos](#product-demos) |
|
|
878
|
+
| `fonts` | none | the video's own font files, see [Product demos](#product-demos) |
|
|
879
|
+
|
|
880
|
+
The looks:
|
|
881
|
+
|
|
882
|
+
| Look | What it looks like | Transition | Music |
|
|
883
|
+
|---|---|---|---|
|
|
884
|
+
| `paper` | marker drawings on warm paper | brush | warm |
|
|
885
|
+
| `clean` | flat cards with soft shadows | slide | upbeat |
|
|
886
|
+
| `chalk` | chalk on a green board | brush | calm |
|
|
887
|
+
| `blueprint` | white drawings on blueprint blue | wipe | tech |
|
|
888
|
+
| `midnight` | dark background with glowing colors | zoom | tech |
|
|
889
|
+
| `editorial` | serif headlines and fine lines on warm paper, like a magazine | fade | calm |
|
|
890
|
+
|
|
891
|
+
### Custom looks
|
|
892
|
+
|
|
893
|
+
A look file gives a project its own colors, fonts and texture without
|
|
894
|
+
changing explainroo. Set `"theme": "../brand/acme-look.json"` in `video.json`.
|
|
895
|
+
The path is relative to the video folder, so a file outside it can give
|
|
896
|
+
several videos the same look.
|
|
897
|
+
|
|
898
|
+
```json
|
|
899
|
+
{
|
|
900
|
+
"extends": "clean",
|
|
901
|
+
"name": "acme",
|
|
902
|
+
"bg": "#fbfaf7",
|
|
903
|
+
"ink": "#1d1b16",
|
|
904
|
+
"accent": "orange",
|
|
905
|
+
"colors": { "orange": "#e8590c" },
|
|
906
|
+
"background": "dots",
|
|
907
|
+
"transition": "fade",
|
|
908
|
+
"music": "calm"
|
|
909
|
+
}
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
`extends` names the built-in look to start from. Every other key is
|
|
913
|
+
optional and changes only what it lists: `name`, `dark`, `bg`, `ink`, `muted`,
|
|
914
|
+
`surface`, `accent`, `colors`, `fonts`, `background`, `stroke`, `radius`,
|
|
915
|
+
`transition`, `music`, `code`, `terminal` and `caption`. In the nested ones,
|
|
916
|
+
like `colors` or `caption`, list only the values you change. `name` defaults
|
|
917
|
+
to the file name and cannot be a built-in name. Set `"dark": true` when you
|
|
918
|
+
give a light look a dark `bg`, so fills and shadows suit it.
|
|
919
|
+
|
|
920
|
+
Use colors like `"#e8590c"`. `caption.bg` and `code.highlight` also accept
|
|
921
|
+
`rgba(...)`. `accent` names one of the ten colors: red, orange, yellow,
|
|
922
|
+
green, teal, blue, purple, pink, gray or ink.
|
|
923
|
+
|
|
924
|
+
`fonts` sets the `display`, `body`, `hand` and `mono` roles. Each takes a
|
|
925
|
+
`family` and a numeric `weight`, for example
|
|
926
|
+
`"body": { "family": "Inter", "weight": 500 }`. Families must be built in
|
|
927
|
+
or listed in `video.json` under `fonts`. The look file does not load fonts.
|
|
928
|
+
|
|
929
|
+
`background` picks a texture: `paper` (paper grain), `dots` (a dot grid),
|
|
930
|
+
`chalk` (board smudges), `grid` (drafting lines), `glow` (two glows) or
|
|
931
|
+
`plain` (one flat color). Each uses your `bg`. Leave it out to keep the base
|
|
932
|
+
texture. `transition` and `music` set the look's defaults. Settings in
|
|
933
|
+
`video.json` still win. `preview` picks up look edits, and `check` warns
|
|
934
|
+
when `ink` or `muted` has too little contrast against `bg`.
|
|
935
|
+
|
|
936
|
+
## Commands
|
|
937
|
+
|
|
938
|
+
| Command | What it does |
|
|
939
|
+
|---|---|
|
|
940
|
+
| `init <dir>` | creates a project (`--theme`, `--size`, `--pace`, `--language`, `--voice`, `--title`) |
|
|
941
|
+
| `voice [project]` | makes the narration and the word times, saved per scene so only changed scenes are made again |
|
|
942
|
+
| `preview [project]` | a live preview in the browser that reloads when you save (`--size`) |
|
|
943
|
+
| `still [project] [times]` | PNG pictures at `12.5`, `scene`, `scene@2.4` or `scene@end` (`--size`, `--transparent` keeps alpha) |
|
|
944
|
+
| `sheet [project]` | one image with many frames of the video or of one scene (`--scene`, `--every`, `--size`) |
|
|
945
|
+
| `check [project]` | finds layout, timing and pronunciation problems (`--size`) |
|
|
946
|
+
| `render [project]` | the video plus subtitle files, chapters and a cover (`--format mp4`, `gif`, `webm` or `mov`, `--transparent`, `--size`, `--draft`, `--from`, `--to`, `--workers`, `--out`) |
|
|
947
|
+
| `verify [project]` | checks the finished MP4, WebM or MOV: loudness, black frames, silence, clear voice (`--file` picks another file) |
|
|
948
|
+
| `export [project]` | writes a web player folder (`--out dir`, `--json`), by default `out/player/` |
|
|
949
|
+
| `capture [project] <url>` | saves screenshots, wording, colors, fonts and logos from a live site (`--mobile`, `--json`) |
|
|
950
|
+
| `image [project] <name> "<prompt>"` | makes an illustration with OpenRouter |
|
|
951
|
+
| `images [project]` | lists the images and what they cost |
|
|
952
|
+
| `voices`, `say "text"` | lists Kokoro voices with their languages (`--language es`, `ja` or `zh` filters voices), or makes a sample in the chosen voice's language |
|
|
953
|
+
| `voices [project] --elevenlabs` | lists the names, ids and labels available to the key (`--json` also works) |
|
|
954
|
+
| `themes`, `formats`, `icons <word>` | lists the looks and the sizes, searches the 1,854 icons |
|
|
955
|
+
| `doctor` | checks Node, ffmpeg, Chrome, the models, and espeak-ng and Python with misaki for other languages (`--fetch` downloads only English models) |
|
|
956
|
+
|
|
957
|
+
The extra files share the video's name, also with `--out`: `video.srt`,
|
|
958
|
+
`video.vtt`, `video.cover.jpg` and `video.chapters.txt`. A GIF has no sound,
|
|
959
|
+
runs at 15 frames per second and is at most 960 pixels on its long side.
|
|
960
|
+
With `--out`, the file ending must match the format. A render of part of the
|
|
961
|
+
video (`--from`, `--to`) skips the chapters and the cover. A video without
|
|
962
|
+
narration gets no subtitle files.
|
|
963
|
+
|
|
964
|
+
### Transparent video for editors
|
|
965
|
+
|
|
966
|
+
To put a diagram or a lower third over camera footage, render with an alpha
|
|
967
|
+
channel: `render --transparent --format mov` for video editors (ProRes 4444)
|
|
968
|
+
or `--format webm` for the web (VP9). The look's background texture is left
|
|
969
|
+
out. Everything the scene paints stays, including `s.bg()` and
|
|
970
|
+
`s.ui.backdrop()`, and cards, captions and the watermark keep their own
|
|
971
|
+
backgrounds. Keep elements readable on footage: use cards or the `bg` option
|
|
972
|
+
of text.
|
|
973
|
+
|
|
974
|
+
The files are `out/video.mov` or `out/video.webm` (`draft.*` with
|
|
975
|
+
`--draft`), and the cover stays an opaque JPEG. `slide`, `wipe` and `brush`
|
|
976
|
+
transitions become `fade` in a transparent video. Check frames with
|
|
977
|
+
`still --transparent`, which keeps the alpha, and the file with
|
|
978
|
+
`verify --file out/video.mov`, which skips the black-frame check for
|
|
979
|
+
transparent video. Without `--transparent`, WebM and MOV are ordinary opaque
|
|
980
|
+
videos.
|
|
981
|
+
|
|
982
|
+
## Web player
|
|
983
|
+
|
|
984
|
+
Use `export` for a video on a docs site or in an iframe. The canvas draws
|
|
985
|
+
at the screen's resolution, so text stays sharp when the player grows.
|
|
986
|
+
The folder has its own engine, fonts, assets, soundtrack, cover and subtitles.
|
|
987
|
+
It needs no explainroo server. The voice is made first if needed.
|
|
988
|
+
|
|
989
|
+
```bash
|
|
990
|
+
node bin/explainroo.js export videos/my-video
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
Serve `out/player/` with any static web server. Opening `index.html` as a
|
|
994
|
+
local file does not work. Copy the folder to your site, keeping its files
|
|
995
|
+
together. It works in a subfolder too.
|
|
996
|
+
|
|
997
|
+
For a 1920 x 1080 video, embed it like this. Change the aspect ratio to
|
|
998
|
+
match your video's width and height.
|
|
999
|
+
|
|
1000
|
+
```html
|
|
1001
|
+
<div style="aspect-ratio: 1920 / 1080; width: 100%">
|
|
1002
|
+
<iframe src="/videos/my-video/index.html" title="My video"
|
|
1003
|
+
style="width: 100%; height: 100%; border: 0"
|
|
1004
|
+
allow="autoplay; fullscreen" allowfullscreen></iframe>
|
|
1005
|
+
</div>
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
`index.html?autoplay=1&muted=1` starts muted playback, subject to the
|
|
1009
|
+
browser's autoplay rules. `index.html?t=12.5` starts at 12.5 seconds.
|
|
1010
|
+
Click the picture to play or pause. Space or K does the same. The arrow
|
|
1011
|
+
keys seek five seconds. F opens fullscreen, and M mutes the sound.
|
|
1012
|
+
CC shows text captions above the controls. It starts off and remembers
|
|
1013
|
+
your choice in the browser. Captions drawn in the canvas stay as they are.
|
|
1014
|
+
|
|
1015
|
+
Clips use the browser's video decoder. Use a format the browser can play.
|
|
1016
|
+
Their timing can differ a little from the MP4. Math formulas are included
|
|
1017
|
+
as typeset paths. Project modules must use relative local imports. Dotfiles,
|
|
1018
|
+
JSON and text files from the project are kept out of the export.
|
|
1019
|
+
|
|
1020
|
+
The MP4 remains the file to upload to video platforms.
|
|
1021
|
+
|
|
1022
|
+
## Scene API
|
|
1023
|
+
|
|
1024
|
+
Each scene function draws one frame. explainroo calls it for every frame with
|
|
1025
|
+
a fresh `s`, so everything in the scene depends only on the time. Do not keep
|
|
1026
|
+
values between calls and do not use timers. Give each element an `at` time,
|
|
1027
|
+
and the look animates it in. Give it an `out` time, and the look animates it
|
|
1028
|
+
out.
|
|
1029
|
+
|
|
1030
|
+
```js
|
|
1031
|
+
export default {
|
|
1032
|
+
intro(s) {
|
|
1033
|
+
s.title('How DNS works', { at: 0 });
|
|
1034
|
+
s.icon('globe', { y: 700, at: 'browser' });
|
|
1035
|
+
},
|
|
1036
|
+
};
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
The canvas is 1920 x 1080 for 16:9. It is 1080 x 1920 for the vertical sizes,
|
|
1040
|
+
1080 x 1080 for square, and 1080 x 1350 for `instagram`, `linkedin` and 4:5.
|
|
1041
|
+
Positions are in pixels, counted from the top left corner. `x` and `y` are
|
|
1042
|
+
the center of an element unless the method says otherwise.
|
|
1043
|
+
|
|
1044
|
+
### Time
|
|
1045
|
+
|
|
1046
|
+
| Member | Meaning |
|
|
1047
|
+
|---|---|
|
|
1048
|
+
| `s.t` | seconds since the scene started |
|
|
1049
|
+
| `s.T` | seconds since the video started |
|
|
1050
|
+
| `s.dur` | length of the scene in seconds |
|
|
1051
|
+
| `s.voice` | `{ start, end }` of the narration in the scene |
|
|
1052
|
+
| `s.words` | the spoken words: `{ text, start, end }` in scene seconds |
|
|
1053
|
+
| `s.cue(word, n = 1)` | when the n-th time a word or phrase is spoken starts |
|
|
1054
|
+
| `s.cueEnd(word, n = 1)` | when it ends |
|
|
1055
|
+
| `s.mark(name)` | the time of a `[#name]` marker |
|
|
1056
|
+
| `s.time(v)` | turns a number, a word or `"#marker"` into seconds |
|
|
1057
|
+
| `s.pace` | the video's pace (1 is normal) |
|
|
1058
|
+
| `s.p(at, dur = 0.6, ease = 'inOut')` | 0 to 1 progress for your own animation |
|
|
1059
|
+
| `s.since(at)`, `s.between(a, b)` | seconds since a time, or whether now is between two times |
|
|
1060
|
+
| `s.video` | `{ duration, frames, fps, width, height, scenes }` of the whole video |
|
|
1061
|
+
|
|
1062
|
+
Every `at` and `out` accepts seconds (`2.4`), a spoken word (`'resolver'`) or
|
|
1063
|
+
a marker (`'#ask'`). Word cues ignore case and punctuation. A phrase works
|
|
1064
|
+
too. A wrong word or marker stops with an error that lists the closest words.
|
|
1065
|
+
|
|
1066
|
+
An easing sets how a movement speeds up and slows down. The easing names are
|
|
1067
|
+
`linear`, `in`, `out`, `inOut`, `outBack`, `outElastic`, `outQuart` and
|
|
1068
|
+
`inOutSine`. `s.ease.out(p)`, `s.lerp(a, b, p)` and `s.clamp(v, lo, hi)` are
|
|
1069
|
+
there for your own math.
|
|
1070
|
+
|
|
1071
|
+
### Layout
|
|
1072
|
+
|
|
1073
|
+
| Member | Meaning |
|
|
1074
|
+
|---|---|
|
|
1075
|
+
| `s.W`, `s.H`, `s.cx`, `s.cy` | canvas size and its center (on Shorts, TikTok and Reels the center of `s.safe`) |
|
|
1076
|
+
| `s.portrait` | true when the frame is taller than wide |
|
|
1077
|
+
| `s.safe` | `{ x, y, w, h, left, top, right, bottom }`: the area for content (a 7% margin, or the part a platform leaves free) |
|
|
1078
|
+
| `s.row(n, { width, x })` | n x positions spread over a width |
|
|
1079
|
+
| `s.col(n, { height, y })` | n y positions spread over a height, centered in `s.safe` |
|
|
1080
|
+
| `s.grid(cols, rows, { x, y, w, h, gap })` | cells `{ x, y, w, h }`, row by row, filling `s.safe` |
|
|
1081
|
+
| `s.get(id)` | size and position of an element drawn earlier with that `id` |
|
|
1082
|
+
|
|
1083
|
+
Most elements return `{ x, y, w, h, left, right, top, bottom }`, so you can
|
|
1084
|
+
place the next thing below or beside them.
|
|
1085
|
+
|
|
1086
|
+
### Options most elements take
|
|
1087
|
+
|
|
1088
|
+
| Option | Meaning |
|
|
1089
|
+
|---|---|
|
|
1090
|
+
| `at`, `out` | when it appears and when it leaves |
|
|
1091
|
+
| `enter` | `draw`, `write`, `type`, `words`, `sync`, `pop`, `rise`, `fade`, `zoom`, `drop`, `slide-left`, `slide-right`, `slide-up`, `slide-down`, `none` |
|
|
1092
|
+
| `exit` | `fade`, `pop`, `rise`, `drop`, `slide-left`, `slide-right`, `none` |
|
|
1093
|
+
| `dur` | length of the entrance in seconds (shortened by the pace) |
|
|
1094
|
+
| `outDur` | length of the exit in seconds (0.45) |
|
|
1095
|
+
|
|
1096
|
+
`out` is when the exit starts, so an element is still fading while the next
|
|
1097
|
+
one comes in. To swap one label for another in the same place, give the old
|
|
1098
|
+
one `exit: 'none'` and the new one the same time as its `at`.
|
|
1099
|
+
| `id` | a name for arrows, `annotate` and `s.get` |
|
|
1100
|
+
| `color` | a color name (`blue`, `accent`, `ink`, `muted`, ...) or any CSS color |
|
|
1101
|
+
| `opacity`, `scale`, `rotate` | extra changes, `rotate` in degrees |
|
|
1102
|
+
| `float` | pixels of slow drift that keeps a still element alive |
|
|
1103
|
+
| `sfx` | the sound on entrance, or `false` |
|
|
1104
|
+
|
|
1105
|
+
In `paper`, `chalk` and `blueprint`, shapes are drawn line by line and text
|
|
1106
|
+
is written out. In `clean` and `midnight`, shapes pop and text rises. In
|
|
1107
|
+
`editorial`, shapes fade in and text rises. Use
|
|
1108
|
+
`at: -1` for things that were already on screen in the previous scene. They
|
|
1109
|
+
are there from the start and make no sound.
|
|
1110
|
+
|
|
1111
|
+
### Text
|
|
1112
|
+
|
|
1113
|
+
```js
|
|
1114
|
+
s.title('How DNS works', { at: 0 }); // display font, 104 px, at 44% height
|
|
1115
|
+
s.subtitle('the phone book of the internet', { at: 1 }); // 46 px, muted, at 60% height
|
|
1116
|
+
s.text('Every site has an *address*', { y: 300, size: 64, at: 'address' });
|
|
1117
|
+
s.note('about 20 ms', { x: 1400, y: 820, at: 3 }); // 32 px, muted
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
`s.text(str, options)` takes these options: `x`, `y`, `size` (48), `font`
|
|
1121
|
+
(`display`, `body`, `hand`, `mono`), `weight` or `bold: true`, `align`
|
|
1122
|
+
(`left` means x is the left edge), `valign` (`top` means y is the top),
|
|
1123
|
+
`maxWidth`, `lineHeight`, `color`, `mark` (color of `*starred*` words), `bg`
|
|
1124
|
+
(a card behind the text), `padding`, `radius`, `border`. Text can also enter
|
|
1125
|
+
with `write`, `type` (with `cps`), `words` and `sync`. `sync` shows each word
|
|
1126
|
+
as the voice says it. Words in `*stars*` get the accent color. `\n` starts a
|
|
1127
|
+
new line.
|
|
1128
|
+
|
|
1129
|
+
### Math
|
|
1130
|
+
|
|
1131
|
+
```js
|
|
1132
|
+
s.math('E = mc^2', { y: 420, size: 96, at: 'energy' });
|
|
1133
|
+
s.math(String.raw`\int_0^1 x^2\,dx = \tfrac{1}{3}`, { x: 960, y: 700, size: 72, color: 'accent', at: '#integral', id: 'area' });
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
`s.math(tex, options)` draws a TeX formula. Options: `x`, `y` (the center),
|
|
1137
|
+
`size` (72), `color` (ink), `align` (`center` or `left`, where x is the left
|
|
1138
|
+
edge), `display` (true for display style), and the common element options.
|
|
1139
|
+
It returns a box like text. Its `id` works with arrows and `s.annotate`.
|
|
1140
|
+
In `paper`, `chalk` and `blueprint`, the outlines draw first, then fill in.
|
|
1141
|
+
Other looks use their text entrance. You can also use `fade`, `pop` or `rise`.
|
|
1142
|
+
|
|
1143
|
+
Double each backslash in a regular JS string, for example `'\\frac{1}{2}'`.
|
|
1144
|
+
`String.raw` keeps backslashes as written, as in the second example above.
|
|
1145
|
+
Only fixed TeX strings work. Always call `s.math`, and use `at` and `out` for
|
|
1146
|
+
timing. `check` reports formulas that change with `s.t` or appear only later.
|
|
1147
|
+
Formulas are typeset on this computer and cached in `build/math/`.
|
|
1148
|
+
|
|
1149
|
+
### Shapes and arrows
|
|
1150
|
+
|
|
1151
|
+
```js
|
|
1152
|
+
s.box('Resolver', { id: 'res', x: 960, y: 540, icon: 'server', color: 'blue', at: 'resolver' });
|
|
1153
|
+
s.circle({ id: 'you', x: 400, y: 540, r: 90, label: 'You', at: 0.5 });
|
|
1154
|
+
s.arrow('you', 'res', { label: 'asks', at: 'asks' });
|
|
1155
|
+
s.arrow([300, 900], [1600, 900], { bend: 0.3, dashed: true, at: 5 });
|
|
1156
|
+
s.line([[200, 800], [900, 700]], { color: 'accent', at: 2 });
|
|
1157
|
+
s.path('M0 0 C 200 -150 400 150 600 0', { x: 660, y: 540, at: 3 });
|
|
1158
|
+
```
|
|
1159
|
+
|
|
1160
|
+
`s.box(label, options)` is a card that fits its label. Options: `w`, `h`,
|
|
1161
|
+
`minW`, `minH`, `size`, `font`, `icon`, `iconSize`, `iconColor`, `color`
|
|
1162
|
+
(outline and a light fill), `fill`, `stroke`, `width`, `dashed`,
|
|
1163
|
+
`border: false`, `radius`, `shape: 'ellipse'`, `textColor`, `fillStyle`
|
|
1164
|
+
(hand-drawn looks: `solid`, `hachure`, `cross-hatch`, `zigzag`, `dots`).
|
|
1165
|
+
`s.circle({ r, label })` takes the same options.
|
|
1166
|
+
|
|
1167
|
+
`s.line(points, options)` and `s.path(d, options)` take `color`, `width`,
|
|
1168
|
+
`dashed`, `fill` and `glow`. `s.path` also takes `fillStyle`, and
|
|
1169
|
+
`single: true` draws a hand-drawn path with one stroke instead of two.
|
|
1170
|
+
|
|
1171
|
+
`s.arrow(from, to, options)` draws an arrow. `from` and `to` are `[x, y]`,
|
|
1172
|
+
`{ x, y }` or the `id` of an element drawn earlier. With an `id`, the arrow
|
|
1173
|
+
stops at the edge of that element. Options: `bend` (about -1 to 1), `head`
|
|
1174
|
+
(`end`, `start`, `both`, `none`), `label`, `labelSize`, `labelColor`,
|
|
1175
|
+
`labelFont` (the handwritten font by default; `'body'` suits `clean`),
|
|
1176
|
+
`labelOffset`, `gap`, `dashed`, `width`, `headSize`. `s.connect` does the
|
|
1177
|
+
same.
|
|
1178
|
+
|
|
1179
|
+
### Icons, images and video clips
|
|
1180
|
+
|
|
1181
|
+
```js
|
|
1182
|
+
s.icon('database', { x: 1500, y: 540, size: 140, color: 'purple', at: 'database' });
|
|
1183
|
+
s.icon('lock', { bg: 'circle', color: 'green', label: 'Encrypted', at: 4 });
|
|
1184
|
+
s.image('assets/app.png', { w: 1100, frame: 'browser', url: 'app.example.com', at: 0.5 });
|
|
1185
|
+
s.image('assets/cables.png', { w: 1000, frame: 'card', at: 'cables', kenburns: true });
|
|
1186
|
+
```
|
|
1187
|
+
|
|
1188
|
+
The 1,854 icons come from Lucide. Search them with `explainroo icons <word>`.
|
|
1189
|
+
Old Lucide names work too. Icon options: `size` (120), `color`, `weight` (2),
|
|
1190
|
+
`bg` (`true`, `'circle'`, `'square'` or a color), `bgScale`, `label`,
|
|
1191
|
+
`labelSize`, `labelColor`, `labelFont`.
|
|
1192
|
+
|
|
1193
|
+
`s.image(src, options)` draws a file from `assets/`. Options: `w` and/or `h`
|
|
1194
|
+
(the image keeps its shape), `fit` (`cover` or `contain`), `radius`, `frame`
|
|
1195
|
+
(`none`, `card`, `browser`, `window`, `phone`), `url` (for the browser frame),
|
|
1196
|
+
`border`, `shadow: false`, `kenburns: true` for a slow zoom.
|
|
1197
|
+
|
|
1198
|
+
`s.clip(src, options)` draws a video from `assets/`. It takes the same
|
|
1199
|
+
layout, frame and timing options as `s.image` and returns the same box.
|
|
1200
|
+
Use `.mp4`, `.mov`, `.webm` or `.m4v` files.
|
|
1201
|
+
|
|
1202
|
+
```js
|
|
1203
|
+
s.clip('assets/signup.mp4', { w: 1200, frame: 'browser', url: 'app.example.com', at: 'signup' });
|
|
1204
|
+
s.clip('assets/demo.mov', { x: 1400, y: 540, h: 600, from: 12.5, speed: 1.5, at: '#demo', out: 9 });
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
- `from` (0) is the second in the clip where playback starts.
|
|
1208
|
+
- `speed` (1) goes from 0.25 to 4. Playback starts at `at`.
|
|
1209
|
+
- `loop` (false) repeats the whole clip. Otherwise it holds the last frame.
|
|
1210
|
+
`check` gives a hint when that freeze lasts more than a second.
|
|
1211
|
+
- `volume` (0) goes from 0 to 1. Sound plays only at `speed: 1`.
|
|
1212
|
+
It stops at `out`, the clip's end or the scene's end. Loops repeat the
|
|
1213
|
+
sound too. Music ducks under clip sound as it does under the voice.
|
|
1214
|
+
|
|
1215
|
+
Frames are extracted once at the project's fps and saved in `build/clips/`.
|
|
1216
|
+
They are at most 1920 pixels wide. Renders, stills and sheets use these
|
|
1217
|
+
frames. The preview may show a nearby frame while the right one loads.
|
|
1218
|
+
`s.video` still holds the whole video's duration, frames, fps and size.
|
|
1219
|
+
Playback starts at `at`, so `at: -1` starts a clip one second into it. To
|
|
1220
|
+
show a clip from its first frame when the scene starts, use
|
|
1221
|
+
`at: 0, enter: 'none'`. `check` cannot read text inside a clip, so look at
|
|
1222
|
+
stills of those moments.
|
|
1223
|
+
|
|
1224
|
+
### Pointing things out
|
|
1225
|
+
|
|
1226
|
+
```js
|
|
1227
|
+
s.text('It is *not* magic', { id: 'claim', y: 400, at: 0 });
|
|
1228
|
+
s.annotate('claim', { type: 'underline', at: 'magic' });
|
|
1229
|
+
s.annotate({ x: 960, y: 700, w: 400, h: 90 }, { type: 'circle', color: 'red', at: 3 });
|
|
1230
|
+
```
|
|
1231
|
+
|
|
1232
|
+
`s.annotate(target, options)` marks an element or a box. `type` is
|
|
1233
|
+
`underline`, `circle`, `box`, `highlight`, `strike`, `cross` or `bracket`.
|
|
1234
|
+
Options: `color`, `padding`, `width`, `dur`.
|
|
1235
|
+
|
|
1236
|
+
### Lists, numbers and charts
|
|
1237
|
+
|
|
1238
|
+
```js
|
|
1239
|
+
s.list(['Browser cache', 'Resolver', 'Root server'], { x: 360, y: 280, at: 'first', stagger: 1.1 });
|
|
1240
|
+
s.number(1500000, { suffix: ' requests', at: 'million', y: 480 });
|
|
1241
|
+
s.bars([{ label: '2023', value: 19 }, { label: '2024', value: 31 }], { at: 1, suffix: 'k' });
|
|
1242
|
+
s.lineChart([3, 5, 4, 8, 13, 21], { labels: ['M', 'T', 'W', 'T', 'F', 'S'], at: 1 });
|
|
1243
|
+
s.pie([{ label: 'Images', value: 55 }, { label: 'Other', value: 45 }], { donut: 0.55, at: 1 });
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
- `s.list(items, options)`: items are text or `{ text, at, icon, color, out }`.
|
|
1247
|
+
`x` is the left edge and `y` the top. Options: `size` (50), `width`, `gap`,
|
|
1248
|
+
`bullet` (`dot`, `dash`, `number`, `check`, `arrow` or an icon name),
|
|
1249
|
+
`bulletColor`, `at` (a start time or a list of times), `stagger` (0.7),
|
|
1250
|
+
`enter`.
|
|
1251
|
+
- `s.number(value, options)` counts up with ticking sounds. Options: `from`,
|
|
1252
|
+
`dur` (1.4), `prefix`, `suffix`, `decimals`, `separator`, `group: false`,
|
|
1253
|
+
plus the text options.
|
|
1254
|
+
- `s.bars(data, options)`: items are `{ label, value, color, at }`. A bar
|
|
1255
|
+
with its own `at` grows when that word is spoken. Options: `x`, `y`, `w`,
|
|
1256
|
+
`h`, `max`, `stagger`, `growDur`, `values: false`, `prefix`, `suffix`,
|
|
1257
|
+
`format(v)`, `labelSize`, `valueSize`, `fillStyle`.
|
|
1258
|
+
- `s.lineChart(values, options)`: `x`, `y`, `w`, `h`, `min`, `max`,
|
|
1259
|
+
`labels`, `dots: false`, `area: false`, `color`, `dur`.
|
|
1260
|
+
- `s.pie(data, options)`: `x`, `y`, `r`, `donut` (0 to 0.8), `labels: false`,
|
|
1261
|
+
`labelOffset`, `dur`.
|
|
1262
|
+
|
|
1263
|
+
### Code and terminal
|
|
1264
|
+
|
|
1265
|
+
```js
|
|
1266
|
+
s.code("const res = await fetch(url);", { lang: 'js', title: 'app.js', at: 0.5 });
|
|
1267
|
+
s.terminal(['$ npm install', 'added 42 packages in 3s'], { at: 1 });
|
|
1268
|
+
```
|
|
1269
|
+
|
|
1270
|
+
`s.code(source, options)` shows code. Options: `x` and `y` (the center of
|
|
1271
|
+
the window), `lang` (`js`, `ts`, `py`,
|
|
1272
|
+
`go`, `rust`, `php`, `sh`, `sql`, `json`, `md`), `size` (32), `w`, `title`
|
|
1273
|
+
(or `false`), `lineNumbers: false`, `reveal` (`type`, `lines`, `none`),
|
|
1274
|
+
`cps`, `lineDelay`, `highlight` (line numbers) and `highlightAt`. `check`
|
|
1275
|
+
reports lines that are wider than the window.
|
|
1276
|
+
|
|
1277
|
+
Use steps to show a change, a refactor or a fix:
|
|
1278
|
+
|
|
1279
|
+
```js
|
|
1280
|
+
s.code([
|
|
1281
|
+
{ code: 'const total = items.length;', at: 0.5 },
|
|
1282
|
+
{ code: 'const total = items\n .filter((i) => i.active)\n .length;', at: 'filter', highlight: [2] },
|
|
1283
|
+
{ code: 'const activeCount = items\n .filter((i) => i.active)\n .length;', at: '#rename' },
|
|
1284
|
+
], { lang: 'js', title: 'stats.js' });
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
Parts that stay slide to their new place, removed parts fade out and new
|
|
1288
|
+
parts fade in. Each later step starts at its own `at`, and the change takes
|
|
1289
|
+
`morphDur` seconds (0.8, shortened by `pace`). The element's `at` defaults to
|
|
1290
|
+
the first step's. `reveal` applies to the first step only. A step's
|
|
1291
|
+
`highlight` replaces the earlier one. The window is as wide as the widest
|
|
1292
|
+
step, up to 86% of the frame, unless you set `w`, and its height follows the
|
|
1293
|
+
line count. `check` checks the lines of every step.
|
|
1294
|
+
|
|
1295
|
+
`s.terminal(lines, options)` shows a terminal. Lines that start with `$ ` are
|
|
1296
|
+
typed as commands. Other lines are output. A line can also be `{ cmd, at }`
|
|
1297
|
+
or `{ out, at, color }`. Options: `w`, `size`, `rows`, `title`, `prompt`,
|
|
1298
|
+
`cps` (22), `outputDelay`, `lineGap`.
|
|
1299
|
+
|
|
1300
|
+
### Camera, groups and your own drawing
|
|
1301
|
+
|
|
1302
|
+
- `s.camera([{ at, x, y, zoom, dur, rotate }])` moves the view by hand
|
|
1303
|
+
instead of the automatic camera (see The camera). Call it first in the
|
|
1304
|
+
scene function. `s.camera([])` keeps the scene still.
|
|
1305
|
+
- `s.focus(target, { at, out })` points the automatic camera at an element
|
|
1306
|
+
or a region on a cue, for example one row of a table. `target` is an `id`
|
|
1307
|
+
drawn earlier, `{ x, y, w, h }` (center and size) or `[x, y, w, h]`. It
|
|
1308
|
+
draws nothing. Highlighted code lines and terminal commands get a
|
|
1309
|
+
close-up on their own when they are small in the shot.
|
|
1310
|
+
- `s.group({ x, y, scale, rotate, at, out, enter }, () => { ... })` moves a
|
|
1311
|
+
set of elements together. Inside the group, positions count from `x`, `y`.
|
|
1312
|
+
- `s.draw({ x, y, at, out }, (ctx, life) => { ... })` gives you the canvas 2D
|
|
1313
|
+
context, so you can draw anything the other methods cannot. `life.p` is the
|
|
1314
|
+
entrance progress from 0 to 1, and `life.local` the seconds since `at`, for
|
|
1315
|
+
motion that keeps going. `s.ctx` is also available.
|
|
1316
|
+
- `s.burst({ x, y, at, count, colors })` fires confetti.
|
|
1317
|
+
- `s.bg(color)` paints over the background.
|
|
1318
|
+
- `s.rand(i)`, `s.noise(x)` and `s.wiggle(amount, speed)` give random values
|
|
1319
|
+
that come out the same every time you render.
|
|
1320
|
+
|
|
1321
|
+
### Sound
|
|
1322
|
+
|
|
1323
|
+
Elements make a sound when they enter. The look picks the sound. Drawn lines
|
|
1324
|
+
scribble, cards pop, arrows whoosh, list items play rising notes, numbers
|
|
1325
|
+
tick, typing clicks, and scenes change with a swipe. `sfx: false` silences
|
|
1326
|
+
one element. `"sfx": "minimal"` in `video.json` keeps only the transitions
|
|
1327
|
+
and the sounds you add yourself.
|
|
1328
|
+
|
|
1329
|
+
`s.sfx(name, at, { gain, dur, pitch })` adds a sound: `pop`, `click`,
|
|
1330
|
+
`whoosh`, `swipe`, `tick`, `type`, `ding`, `chime`, `thud`, `scribble`,
|
|
1331
|
+
`chalk`, `rise`, `sparkle`, `blip`, `error`. `dur` sets the length of `type`,
|
|
1332
|
+
`scribble`, `chalk` and `rise` (`rise` ends at `at + dur`). The music is made
|
|
1333
|
+
to fit the video, and it gets quieter while the voice speaks.
|
|
1334
|
+
|
|
1335
|
+
### Colors and fonts
|
|
1336
|
+
|
|
1337
|
+
For product demos in a brand's own colors and fonts, see
|
|
1338
|
+
[Product demos](#product-demos).
|
|
1339
|
+
|
|
1340
|
+
Color names: `accent`, `ink`, `muted`, `bg`, `surface`, `red`, `orange`,
|
|
1341
|
+
`yellow`, `green`, `teal`, `blue`, `purple`, `pink`, `gray`. Each look has its
|
|
1342
|
+
own version of each color, so scenes keep working when you change the look.
|
|
1343
|
+
`s.color(name)` returns the CSS color and `s.tint(name)` the light fill. The
|
|
1344
|
+
font roles are `display`, `body`, `hand` and `mono`.
|
|
1345
|
+
|
|
1346
|
+
## Things that break
|
|
1347
|
+
|
|
1348
|
+
- Calling an element only sometimes, like `if (s.t > 3) s.box(...)`. Always
|
|
1349
|
+
call it, and use `at` and `out` for the timing. The sound effects and the
|
|
1350
|
+
checks depend on this.
|
|
1351
|
+
- Changing the TeX in `s.math` over time. Use fixed strings for each formula,
|
|
1352
|
+
and give each one its own `at` and `out`.
|
|
1353
|
+
- An arrow or annotation that points to an `id` drawn later in the function.
|
|
1354
|
+
- `s.camera()` after other elements. It has to come first.
|
|
1355
|
+
- An `at` later than the end of the scene. Make the scene longer with
|
|
1356
|
+
`{hold=2}` or `{min=6}` in the script.
|
|
1357
|
+
- Random values from anything other than `s.rand()`, `s.noise()` or
|
|
1358
|
+
`Math.random()` inside the scene function. Only those three come out the
|
|
1359
|
+
same on every render.
|
|
1360
|
+
- Text in AI images. Put words on screen with `s.text`.
|
|
1361
|
+
- A cue word that is spoken twice. `at: 'writes'` means the first time. Use
|
|
1362
|
+
`s.cue('writes', 2)` or a `[#marker]` for a later one. `check` lists such
|
|
1363
|
+
words as hints.
|
|
1364
|
+
- Apostrophes in cue words. Cues ignore punctuation, so "visitor's" is heard
|
|
1365
|
+
as "visitors". `at: 'visitor'` then waits for the next plain "visitor".
|
|
1366
|
+
Use a `[#marker]` there.
|
|
1367
|
+
- Elements inside `s.group`. Each one makes its sound at its own `at`, even
|
|
1368
|
+
while the group is still hidden. Give them the group's `at`, or
|
|
1369
|
+
`sfx: false`.
|
|
1370
|
+
- Words that sound like other words. The speech check hears "won" as "one"
|
|
1371
|
+
and "plain" as "plane", and `{shown|spoken}` cannot fix that. Reword the
|
|
1372
|
+
sentence. For acronyms that are spelled out letter by letter, write
|
|
1373
|
+
`{API|A, P, I}`. Do not write `A.P.I.`, because the voice reads the dots
|
|
1374
|
+
like a web address.
|
|
1375
|
+
- Growing a shape by changing `w` or `h` over time in the hand-drawn looks.
|
|
1376
|
+
The outline is drawn fresh every frame, so it wobbles. Animate `scale`
|
|
1377
|
+
instead.
|
|
1378
|
+
- A scene change in the middle of one diagram. The default transition of
|
|
1379
|
+
`clean` slides the whole frame. Give scenes that share a diagram
|
|
1380
|
+
`{transition=fade}` or `{transition=cut}`.
|
|
1381
|
+
- Arrows from an icon that has a label. The `id` of an icon covers the icon
|
|
1382
|
+
only, not its label, so an arrow that leaves downward crosses the label.
|
|
1383
|
+
- Colored text in `paper` and `clean`. Green, orange and red are light enough
|
|
1384
|
+
for shapes but often too light for text. `check` warns about low contrast.
|
|
1385
|
+
It suggests a readable color and shows its contrast ratio.
|
|
1386
|
+
- Long video clips fill `build/clips/` with frames. Trim footage to the part
|
|
1387
|
+
you show before you add it. Deleting `build/clips/` is safe.
|
|
1388
|
+
- Screen recordings often have a variable frame rate. explainroo converts
|
|
1389
|
+
them to the project's fps, so a frame can repeat or drop. Record at a fixed
|
|
1390
|
+
frame rate when the motion matters.
|
|
1391
|
+
- Exact geometry in `paper`, `chalk` and `blueprint`. Their outlines are
|
|
1392
|
+
hand drawn, so a circle's edge wanders a little from its radius. When a
|
|
1393
|
+
line has to meet an outline exactly, like a radius that ends on the
|
|
1394
|
+
circle, draw both with `s.draw`.
|
|
1395
|
+
- A render that stops with a closed browser or `EPIPE` on a busy computer.
|
|
1396
|
+
Run it again with fewer pages, for example `render --workers 2`.
|
|
1397
|
+
|
|
1398
|
+
`check` looks at text and math formulas. It finds text off the frame, too
|
|
1399
|
+
close to the edge (3.5%), too small, with low contrast (against the page, or
|
|
1400
|
+
against the text's own `bg`), on top of other text, or under the captions.
|
|
1401
|
+
It does not see shapes, arrows and icons, or drawings made with `s.draw`.
|
|
1402
|
+
Look at the stills for those.
|
|
1403
|
+
|
|
1404
|
+
## Working on explainroo itself
|
|
1405
|
+
|
|
1406
|
+
- `src/` is the part that runs in Node: script, voice, word timing, timeline,
|
|
1407
|
+
server, rendering, checks and images. `engine/` is the part that runs in
|
|
1408
|
+
the browser page: the scene API (`stage.js`), drawing (`pen.js`), looks,
|
|
1409
|
+
transitions, captions and audio (`engine/audio/`).
|
|
1410
|
+
- Run `npm test` after changes. After engine changes, also render the videos
|
|
1411
|
+
in `examples/` and look at their stills and sheets.
|
|
1412
|
+
- `dev/audio-lab.mjs` renders every music style and sound and measures them.
|
|
1413
|
+
- `npm run build:icons` rebuilds the icons from `lucide-static`, and
|
|
1414
|
+
`npm run build:fonts` downloads the fonts again.
|