@motionhub/oms 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/dist/LICENSE +201 -0
- package/dist/OFL.txt +91 -0
- package/dist/player.js +1 -0
- package/dist/resources/preview/core.js +66 -0
- package/dist/resources/preview/pick.js +1 -0
- package/dist/starter.tsx +35 -0
- package/dist/worker.cjs +3144 -0
- package/oms.mjs +235 -0
- package/package.json +34 -3
- package/skills/oms/SKILL.md +27 -0
- package/skills/oms/example/film.tsx +97 -0
- package/skills/oms/film-format.md +54 -0
- package/skills/oms/references/assets.md +15 -0
- package/skills/oms/references/craft.md +49 -0
- package/skills/oms/references/drawing.md +29 -0
- package/skills/oms/references/look.md +35 -0
- package/skills/oms/references/review.md +33 -0
package/oms.mjs
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { constants, existsSync } from 'node:fs';
|
|
3
|
+
import { cp, copyFile, mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { homedir, tmpdir } from 'node:os';
|
|
6
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { parseArgs } from 'node:util';
|
|
9
|
+
|
|
10
|
+
const root = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const usage = 'oms install <claude|codex> | init <folder> | check <folder> [--json] | still <folder> --at <seconds> --out <new.png> | render <folder> --out <new.mp4> | player <folder> --out <new folder> | pack <folder> [--out <file.oms>] | preview <folder> [--port <n>] | motion search <words…> [--json] | motion use <@scope/slug> <folder> | sound <folder> --cues <at:role,…> --seconds <s> --out <new.wav> [--motion <id>] | font <folder> --family <name[:400,700]>… [--weights 400,700] | voice <folder> [--recording <file> [--transcribe <minimax|openai|elevenlabs>]] | voice --list <minimax|elevenlabs|openai|azure>';
|
|
12
|
+
|
|
13
|
+
/** `oms motion search <words…> [--json]` and `oms motion use <@scope/slug> <folder>`: motions from motionhub, on demand. */
|
|
14
|
+
async function motion(args) {
|
|
15
|
+
const { values, positionals } = parseArgs({ args, options: { json: { type: 'boolean' } }, allowPositionals: true });
|
|
16
|
+
const [action, ...rest] = positionals;
|
|
17
|
+
const worker = createRequire(import.meta.url)(join(root, 'dist/worker.cjs'));
|
|
18
|
+
if (action === 'search') {
|
|
19
|
+
const found = await worker.searchMotions(rest.join(' '));
|
|
20
|
+
if (values.json) return console.log(JSON.stringify(found));
|
|
21
|
+
if (!found.length) return console.log(`No motion has any of those words. The words motions are tagged with: ${(await worker.motionWords()).slice(0, 40).join(', ')}. Or run oms motion search with none to list them all.`);
|
|
22
|
+
for (const m of found) console.log(`${m.id}: ${m.name}. ${m.line}${m.fit ? ` For: ${m.fit}` : ''}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (action === 'use' && rest.length === 2) {
|
|
26
|
+
const used = await worker.useMotion(resolve(rest[1]), rest[0]);
|
|
27
|
+
return console.log(`Took ${used.id} into ${used.path}. Read its MOTION.md and tokens.json before drawing in it.`);
|
|
28
|
+
}
|
|
29
|
+
throw new Error(usage);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `oms sound <folder> --cues <at:role,…> --seconds <s> --out <new.wav> [--motion <id>]`: the project's motion's sound
|
|
34
|
+
* for those cues, a track the film's length, written as a new WAV inside the project (--out is a path from the current
|
|
35
|
+
* directory, as still's and render's are) for a <Sound> to play.
|
|
36
|
+
*/
|
|
37
|
+
async function sound(args) {
|
|
38
|
+
const { values, positionals } = parseArgs({ args, options: { cues: { type: 'string' }, seconds: { type: 'string' }, out: { type: 'string' }, motion: { type: 'string' } }, allowPositionals: true });
|
|
39
|
+
if (positionals.length !== 1 || !values.cues || !values.seconds || !values.out?.toLowerCase().endsWith('.wav')) throw new Error(usage);
|
|
40
|
+
const dir = resolve(positionals[0]);
|
|
41
|
+
// Like still's and render's, --out is a path from where oms runs; the track must be inside the project.
|
|
42
|
+
const file = resolve(values.out);
|
|
43
|
+
if (!file.startsWith(dir + sep)) throw new Error(`${file} is outside the project ${dir}: a film plays only its own files. Give a path inside it, as "${join(positionals[0], 'media', 'effects.wav')}".`);
|
|
44
|
+
if (existsSync(file)) throw new Error(`${file} is there already: name a new file.`);
|
|
45
|
+
const worker = createRequire(import.meta.url)(join(root, 'dist/worker.cjs'));
|
|
46
|
+
const { motion, wav, report } = await worker.effectsTrack(dir, worker.parseCues(values.cues), Number(values.seconds), values.motion);
|
|
47
|
+
await mkdir(dirname(file), { recursive: true });
|
|
48
|
+
await writeFile(file, wav, { flag: 'wx' });
|
|
49
|
+
const src = relative(dir, file).split(sep).join('/');
|
|
50
|
+
const db = (value) => (value === -Infinity ? 'silent' : `${value.toFixed(1)} dBFS`);
|
|
51
|
+
console.log(`Wrote ${src} from ${motion}'s sound (roles: ${report.roles.join(', ')}). Play it across the film: <Sound src="${src}" />`);
|
|
52
|
+
console.log(`Track: peak ${db(report.peak)}, average ${db(report.rms)}.`);
|
|
53
|
+
for (const cue of report.cues) console.log(` ${cue.at}s ${cue.role}${cue.dur ? ` (${cue.dur}s)` : ''}: peak ${db(cue.peak)}${cue.silent ? ' <- not heard: its voice made no sound here' : ''}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* `oms font <folder> --family <name> [--weights 400,700]`: a face from Google Fonts cut to the characters the film
|
|
58
|
+
* writes (its sources and what it imports from outside the project), into its media/fonts/ with its licence; run again
|
|
59
|
+
* when the words change.
|
|
60
|
+
*/
|
|
61
|
+
async function font(args) {
|
|
62
|
+
const { values, positionals } = parseArgs({ args, options: { family: { type: 'string', multiple: true }, weights: { type: 'string' } }, allowPositionals: true });
|
|
63
|
+
if (positionals.length !== 1 || !values.family?.length) throw new Error(usage);
|
|
64
|
+
const dir = resolve(positionals[0]);
|
|
65
|
+
if (!existsSync(join(dir, 'film.tsx'))) throw new Error(`${dir} holds no film.tsx: name the project folder.`);
|
|
66
|
+
const weightsOf = (text) => text.split(',').map((w) => Number(w.trim()));
|
|
67
|
+
// Each --family as "Name" (in --weights, 400 and 700 without) or "Name:300,500".
|
|
68
|
+
const asked = values.family.map((given) => {
|
|
69
|
+
const at = given.lastIndexOf(':');
|
|
70
|
+
return at > 0 ? { family: given.slice(0, at), weights: weightsOf(given.slice(at + 1)) } : { family: given, weights: weightsOf(values.weights ?? '400,700') };
|
|
71
|
+
});
|
|
72
|
+
const worker = createRequire(import.meta.url)(join(root, 'dist/worker.cjs'));
|
|
73
|
+
const { readFile } = await import('node:fs/promises');
|
|
74
|
+
const ofl = await readFile(worker.OFL, 'utf8');
|
|
75
|
+
const name = (file) => file.replace(/^.*\//, '').replace(/\.ttf$/, '').replace(/-/g, '_').replace(/^(\d)/, '_$1');
|
|
76
|
+
const declared = [];
|
|
77
|
+
const scratch = await mkdtemp(join(tmpdir(), 'oms-font-'));
|
|
78
|
+
try {
|
|
79
|
+
for (const { family, weights } of asked) {
|
|
80
|
+
const { files, characters, licence, unbuilt } = await worker.font(dir, scratch, family, weights, ofl);
|
|
81
|
+
console.log(`Wrote ${files.join(', ')}: ${family} cut to the ${characters} characters the ${unbuilt ? 'project' : 'film'} writes (${licence}).`);
|
|
82
|
+
if (unbuilt) console.warn(`The film does not build, so words it imports from outside its folder are not in this face; run this again once it builds:\n${unbuilt}`);
|
|
83
|
+
for (const file of files.filter((f) => f.endsWith('.ttf'))) declared.push({ family, file, weight: /-(\d+)\.ttf$/.exec(file)[1] });
|
|
84
|
+
}
|
|
85
|
+
} finally {
|
|
86
|
+
await rm(scratch, { recursive: true, force: true, maxRetries: 4 });
|
|
87
|
+
}
|
|
88
|
+
console.log('Run this again when the words change. Declare them where the film draws:');
|
|
89
|
+
for (const { file } of declared) console.log(` import ${name(file)} from './${file}';`);
|
|
90
|
+
console.log(' <style>{`');
|
|
91
|
+
for (const { family, file, weight } of declared) console.log(` @font-face { font-family: '${family}'; font-weight: ${weight}; src: url(\${${name(file)}}); }`);
|
|
92
|
+
console.log(' `}</style>');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* `oms voice <folder>`: the film's lines spoken in its <Film voice> into voice/, only those whose words changed, with the
|
|
97
|
+
* key from the environment. `oms voice --list <provider>`: the voices that provider offers.
|
|
98
|
+
*/
|
|
99
|
+
async function voice(args) {
|
|
100
|
+
const { values, positionals } = parseArgs({ args, options: { list: { type: 'string' }, recording: { type: 'string' }, transcribe: { type: 'string' } }, allowPositionals: true });
|
|
101
|
+
const worker = createRequire(import.meta.url)(join(root, 'dist/worker.cjs'));
|
|
102
|
+
if (values.list) {
|
|
103
|
+
if (positionals.length || !Object.hasOwn(worker.VOICE_ENV, values.list)) throw new Error(usage);
|
|
104
|
+
// A tab after the voice, which may hold blanks and brackets itself (minimax:Chinese (Mandarin)_News_Anchor).
|
|
105
|
+
for (const choice of await worker.voices(values.list)) console.log(`${values.list}:${choice.id}${choice.name && choice.name !== choice.id ? `\t${choice.name}` : ''}${choice.language ? `\t(${choice.language})` : ''}`);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (positionals.length !== 1 || (values.transcribe && !values.recording)) throw new Error(usage);
|
|
109
|
+
const dir = resolve(positionals[0]);
|
|
110
|
+
const scratch = await mkdtemp(join(tmpdir(), 'oms-voice-'));
|
|
111
|
+
try {
|
|
112
|
+
if (values.recording) {
|
|
113
|
+
const done = await worker.record(dir, scratch, resolve(values.recording), values.transcribe, (text) => console.error(text));
|
|
114
|
+
return console.log(worker.recordingReport(done, values.recording).join('\n'));
|
|
115
|
+
}
|
|
116
|
+
const done = await worker.voice(dir, scratch, (n, of) => process.stderr.isTTY && process.stderr.write(`\rSpeaking ${n}/${of}`));
|
|
117
|
+
if (process.stderr.isTTY) process.stderr.write('\n');
|
|
118
|
+
console.log(`Spoke ${done.spoken} line${done.spoken === 1 ? '' : 's'} (${done.characters} characters, ${done.seconds.toFixed(1)} s of speech) into voice/; ${done.kept} kept as they were. Run oms check: each voiced line now lasts as long as its speech.`);
|
|
119
|
+
for (const m of done.misread ?? []) console.log(`warning: in line ${m.line}, the voice read "${m.written}" as "${m.said}". Write it so it cannot be read otherwise (spell it out, or move it from the line's end), then voice again.`);
|
|
120
|
+
} finally {
|
|
121
|
+
await rm(scratch, { recursive: true, force: true, maxRetries: 4 });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function run() {
|
|
126
|
+
const [command, ...args] = process.argv.slice(2);
|
|
127
|
+
if (!command || command === '--help') return console.log(usage);
|
|
128
|
+
if (command === 'motion') return motion(args);
|
|
129
|
+
if (command === 'sound') return sound(args);
|
|
130
|
+
if (command === 'font') return font(args);
|
|
131
|
+
if (command === 'voice') return voice(args);
|
|
132
|
+
const options = command === 'still' ? { at: { type: 'string' }, out: { type: 'string' } }
|
|
133
|
+
: command === 'render' || command === 'player' || command === 'pack' ? { out: { type: 'string' } }
|
|
134
|
+
: command === 'preview' ? { port: { type: 'string' } }
|
|
135
|
+
: command === 'check' ? { json: { type: 'boolean' } } : {};
|
|
136
|
+
const { values, positionals } = parseArgs({ args, options, allowPositionals: true });
|
|
137
|
+
if (positionals.length !== 1) throw new Error(usage);
|
|
138
|
+
const [target] = positionals;
|
|
139
|
+
if (command === 'install') {
|
|
140
|
+
const homes = { claude: process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude'),
|
|
141
|
+
codex: process.env.CODEX_HOME || join(homedir(), '.codex') };
|
|
142
|
+
if (!Object.hasOwn(homes, target)) throw new Error(usage);
|
|
143
|
+
const skills = join(homes[target], 'skills');
|
|
144
|
+
const dest = join(skills, 'oms');
|
|
145
|
+
await mkdir(skills, { recursive: true });
|
|
146
|
+
await mkdir(dest).catch(error => {
|
|
147
|
+
if (error.code === 'EEXIST') throw new Error(`OMS is already installed in ${dest}. To install this version, move that folder aside and run this again.`);
|
|
148
|
+
throw error;
|
|
149
|
+
});
|
|
150
|
+
try {
|
|
151
|
+
// The skill folder is whole as it is: its film format and example film are in it, as `npx skills add` takes it.
|
|
152
|
+
await cp(join(root, 'skills/oms'), dest, { recursive: true });
|
|
153
|
+
} catch (error) {
|
|
154
|
+
await rm(dest, { recursive: true, force: true });
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
return console.log(dest);
|
|
158
|
+
}
|
|
159
|
+
const dir = resolve(target);
|
|
160
|
+
if (command === 'init') {
|
|
161
|
+
await mkdir(dir, { recursive: true });
|
|
162
|
+
if ((await readdir(dir)).length) throw new Error('Choose an empty or new project folder.');
|
|
163
|
+
await copyFile(join(root, 'dist/starter.tsx'), join(dir, 'film.tsx'), constants.COPYFILE_EXCL);
|
|
164
|
+
// What oms and the Studio make beside the film, never its own media: renders, their subtitles and stills at the top
|
|
165
|
+
// of the folder, and the Studio's state.
|
|
166
|
+
await writeFile(join(dir, '.gitignore'), '/*.mp4\n/*.srt\n/*.png\n.motion-studio/\n', { flag: 'wx' });
|
|
167
|
+
return console.log(dir);
|
|
168
|
+
}
|
|
169
|
+
if (command === 'pack') {
|
|
170
|
+
// The film as one file for the Studio's Import (ADR 0019): beside the folder unless --out names another place.
|
|
171
|
+
const out = resolve(values.out ?? `${dir}.oms`);
|
|
172
|
+
const worker = createRequire(import.meta.url)(join(root, 'dist/worker.cjs'));
|
|
173
|
+
const { files, bytes, leftOut } = await worker.pack(dir, out);
|
|
174
|
+
console.log(out);
|
|
175
|
+
const mb = (n) => `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
176
|
+
if (leftOut.length) console.error(`Left out ${leftOut.map((folder) => `${folder.path} (${mb(folder.bytes)})`).join(', ')}: a film keeps nothing in a folder whose name starts with a dot.`);
|
|
177
|
+
return console.error(`Packed ${files} file${files === 1 ? '' : 's'} (${mb(bytes)}). In OpenMotionStudio, Import project opens it as a new project; renders, stills, dot-folders and the Studio's state are left out.`);
|
|
178
|
+
}
|
|
179
|
+
if (!['still', 'check', 'render', 'player', 'preview'].includes(command)) throw new Error(usage);
|
|
180
|
+
if (command === 'player' && !values.out) throw new Error(usage);
|
|
181
|
+
const port = values.port === undefined ? 4173 : Number(values.port);
|
|
182
|
+
if (command === 'preview' && !(Number.isInteger(port) && port > 0 && port < 65536)) throw new Error(usage);
|
|
183
|
+
if (command === 'render') {
|
|
184
|
+
if (!values.out?.toLowerCase().endsWith('.mp4')) throw new Error(usage);
|
|
185
|
+
// A render is moved into place whole; it never replaces a video, or the subtitles beside it.
|
|
186
|
+
const subtitles = resolve(values.out).replace(/\.mp4$/i, '') + '.srt';
|
|
187
|
+
for (const file of [resolve(values.out), subtitles]) if (existsSync(file)) throw new Error(`${file} is there already: name a new file.`);
|
|
188
|
+
}
|
|
189
|
+
if (command === 'still' && (!values.at?.trim() || !Number.isFinite(Number(values.at)) || !values.out?.toLowerCase().endsWith('.png'))) throw new Error(usage);
|
|
190
|
+
// The worker builds the film with the Studio's own code and draws it in headless Chrome (worker.ts, chrome.ts).
|
|
191
|
+
const worker = createRequire(import.meta.url)(join(root, 'dist/worker.cjs'));
|
|
192
|
+
const scratch = await mkdtemp(join(tmpdir(), 'oms-preview-'));
|
|
193
|
+
try {
|
|
194
|
+
if (command === 'render') {
|
|
195
|
+
let shown = -1;
|
|
196
|
+
// Ctrl-C stops the render cleanly: its Chromes closed, its finished segments kept for the next run.
|
|
197
|
+
const stop = new AbortController();
|
|
198
|
+
process.once('SIGINT', () => stop.abort());
|
|
199
|
+
const { drawnOn } = await worker.render(dir, scratch, resolve(values.out), (done) => {
|
|
200
|
+
const percent = Math.floor(done * 100);
|
|
201
|
+
if (percent !== shown && process.stderr.isTTY) process.stderr.write(`\rRendering ${(shown = percent)}%`);
|
|
202
|
+
}, stop.signal);
|
|
203
|
+
if (process.stderr.isTTY) process.stderr.write('\n');
|
|
204
|
+
console.error(`Drawn on ${drawnOn}. OMS_RENDER_GPU=0 draws on the CPU, =1 on the GPU.`);
|
|
205
|
+
return console.log(resolve(values.out));
|
|
206
|
+
}
|
|
207
|
+
if (command === 'player') {
|
|
208
|
+
const { soundtrack } = await worker.player(dir, scratch, resolve(values.out));
|
|
209
|
+
console.log(resolve(values.out));
|
|
210
|
+
return console.error(`A web player${soundtrack ? ', with its soundtrack' : ''}: put the folder on any static web host and open index.html, or open it here with \`oms preview "${target}"\`.`);
|
|
211
|
+
}
|
|
212
|
+
if (command === 'preview') {
|
|
213
|
+
const stop = await worker.preview(dir, scratch, port, (text) => console.error(text));
|
|
214
|
+
console.log(`http://127.0.0.1:${port}/`);
|
|
215
|
+
console.error('Playing; it builds again when a file in the project changes. Ctrl-C stops it.');
|
|
216
|
+
await new Promise((done) => process.once('SIGINT', done));
|
|
217
|
+
return await stop();
|
|
218
|
+
}
|
|
219
|
+
if (command === 'still') {
|
|
220
|
+
const png = await worker.still(dir, scratch, Number(values.at));
|
|
221
|
+
await writeFile(resolve(values.out), png, { flag: 'wx' });
|
|
222
|
+
return console.log(resolve(values.out));
|
|
223
|
+
}
|
|
224
|
+
const review = await worker.check(dir, scratch);
|
|
225
|
+
if (values.json) console.log(JSON.stringify(review));
|
|
226
|
+
else {
|
|
227
|
+
console.log(`Checked ${review.checkedFrames} frames${review.film ? ' of ' + review.film.seconds + 's' : ''}.`);
|
|
228
|
+
for (const issue of review.issues) console.log(`${issue.severity}: ${issue.text}`);
|
|
229
|
+
}
|
|
230
|
+
if (review.issues.some(issue => issue.severity === 'error')) process.exitCode = 1;
|
|
231
|
+
} finally {
|
|
232
|
+
await rm(scratch, { recursive: true, force: true, maxRetries: 4 });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
run().catch(error => { console.error(error.message); process.exitCode = 1; });
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionhub/oms",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Make motion videos from Claude Code or Codex: author, check, still and render OpenMotionStudio films.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/motionhubdev/openmotionstudio.git",
|
|
9
|
+
"directory": "apps/cli"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/motionhubdev/openmotionstudio/tree/main/apps/cli#readme",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"oms": "oms.mjs"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"oms.mjs",
|
|
20
|
+
"dist",
|
|
21
|
+
"skills",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.12.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@motionhub/cli": "0.8.1",
|
|
29
|
+
"@puppeteer/browsers": "3.2.7",
|
|
30
|
+
"esbuild": "0.28.2",
|
|
31
|
+
"three": "0.187.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"vitest": "5.1.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {}
|
|
6
37
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oms
|
|
3
|
+
description: Make, inspect, revise or render OpenMotionStudio (OMS) motion videos from a brief and local assets, end to end to an MP4. Use for requests to make a video with OMS, to render or update an existing film.tsx, or to create a project to refine in Studio, in any language.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Making a film is a creative task. It is finished when someone who has not read the script would be glad to publish it, not when `oms check` is clean. Each scene needs a visual idea of its own subject (a metaphor, a drawing driven by its data, one object that transforms, a move of the frame) and motion that carries meaning.
|
|
7
|
+
|
|
8
|
+
Its commands come from the `oms` package: when `oms` is not found, install it with `npm install -g @motionhub/oms` (Node 22.12 or newer).
|
|
9
|
+
|
|
10
|
+
Read the bundled [film format](film-format.md) first, then the [example film](example/film.tsx) (copy its structure, not its look). Read each reference below when its step comes.
|
|
11
|
+
|
|
12
|
+
## Order of work
|
|
13
|
+
|
|
14
|
+
1. **Start or read.** For an existing project, read film.tsx, its parts, media and motion rules, and keep edits and identifiers outside the request; reread the on-disk source on every later turn. For a new one run `oms init "<new folder>"`.
|
|
15
|
+
2. **Facts, then script.** Gather what the film says; never invent a figure. Write the lines for 75 to 90 percent of the length asked, one idea a line ([craft](references/craft.md), "Script").
|
|
16
|
+
3. **Board each scene before drawing it.** Its lines; its base picture as layers with boxes in px; for each line, what changes and when. Think of at least two ideas that differ in kind and take the one a newcomer would understand.
|
|
17
|
+
4. **Settle the look.** By default the film has a look of its own: write it in `parts/kit.tsx` from the subject's own world ([look](references/look.md)), its faces taken with `oms font` (a Chinese film needs one for its script; import its files by the paths it prints). Use a motion only when the project already has one or the person asks for one by name or by look ("in ink-scroll", "use a motion"): then find it with `oms motion search <words>` (motions with any of the words, those with more first; it lists the words motions are tagged with when none matches) and take it with `oms motion use <@scope/slug> "<folder>"` (downloaded then, once). Do not search motionhub otherwise.
|
|
18
|
+
5. **Draw one scene, look at it, then the rest.** Write no second scene before the first has passed `oms check` and you have looked at a still of it: what is wrong with one scene (sizes, the layout, the faces, the caption) is then fixed once, not in every scene. film.tsx holds the scenes, layers and lines; each scene's picture is its own `parts/<scene>.tsx` ([drawing](references/drawing.md)). After the first scene is drawn and looked at, draw the others simply, so a whole plain film exists within the first third of your time, then improve the weakest scenes. A complete plain film is a video; a half-polished one is not.
|
|
19
|
+
6. **Sound, when the film wants it.** Music the person gives goes into `media/` with its licence noted ([assets](references/assets.md)). Effects come from `oms sound`, in the motion's own sound when the film draws in one and in oms's own otherwise: list the moments the picture makes as cues, in the roles the sound has (of `land`, `move`, `draw`, `count`, `cut`, `out`; `oms sound` names them and refuses any other) and run `oms sound "<folder>" --cues "1.2:land, 3.4:move:0.6" --seconds <film.seconds from `oms check --json`> --out "<folder>/media/effects.wav"` (`--out` is a path from where you run it, as for `still` and `render`), then play it across the film with `<Sound src="media/effects.wav" />`, as it comes mixed, 3 to 6 dB lower under music. Read the levels it prints: a cue marked not heard needs another role ([craft](references/craft.md), "Sound"). A new `--out` each time the cues change. **A narration, when the person asks for one**: give `<Film>` its voice (`voice="minimax:male-qn-jingying"`, for Chinese a MiniMax voice, for English an ElevenLabs one; take the name from `oms voice --list`, which is what the account offers), finish the words first (each spoken line is paid for), run `oms voice "<folder>"`, then `oms check`: each voiced line now lasts as long as its speech, so fit the scenes and the picture to it, and use `<Film captions="words">` to light each word as it is said. A person who reads it themselves records one take of the lines, as written, and `oms voice "<folder>" --recording <file>` cuts it into the lines, in `<Film voice="recording:take">`: what to ask them for, and how to read what it prints (a line read otherwise is cut all the same, its caption showing the written words), are in [craft](references/craft.md), "Sound".
|
|
20
|
+
7. **Review in rounds, at most three.** A round is `oms check "<folder>" --json`, stills where you doubt, and one pass of fixes ([review](references/review.md)). Fix everything a viewer would notice in a scene in one edit.
|
|
21
|
+
8. **Render and report.** `oms render "<folder>" --out "<new path>.mp4"` needs the person's ffmpeg; if it says ffmpeg is missing or incomplete, pass on its install command. It also writes the lines as an `.srt` beside the MP4, and as a subtitle track in it only when the film does not draw them as captions. Return the MP4, the project folder and the duration. When the person wants the film on the web, `oms player "<folder>" --out "<new folder>"` writes a folder any static host plays without a render, or its index.html opened from disk (`oms preview "<folder>"` plays it on this machine and follows changes). The folder also opens in Studio, with its Import project action, for refining by hand; to send it to the Studio on another machine, or to a person, `oms pack "<folder>"` writes it as one film file beside it (`<folder>.oms`, without renders, stills, dot-folders or the Studio's state), which the Studio's Import project opens as a new project.
|
|
22
|
+
|
|
23
|
+
Assets the person gives or you fetch follow [assets](references/assets.md).
|
|
24
|
+
|
|
25
|
+
## In this host
|
|
26
|
+
|
|
27
|
+
The first `oms check`, `still`, `render` or `voice` downloads the Chrome it draws in once (about 100 MB, unless HyperFrames or Puppeteer already has it), and each may say Chrome runs without its sandbox where it cannot start one: neither is an error. The film format names the Studio's tools: here `check` is `oms check`, `still` is `oms still "<folder>" --at <seconds> --out "<new path>.png"` (a time strictly before the film's end; a new path each time), `search_motions` is `oms motion search`, `use_motion` is `oms motion use`, `use_font` is `oms font "<folder>" --family "<family>" --weights 400,700`, `list_voices` is `oms voice --list <minimax|elevenlabs|openai|azure>` and `voice_lines` is `oms voice "<folder>"`. A voice provider is set up not in Models but by its key in the environment oms runs in (`MINIMAX_API_KEY`, with `MINIMAX_REGION=china` or `MINIMAX_BASE_URL=https://api.minimaxi.com` for an account on minimaxi.com; `ELEVENLABS_API_KEY`; `OPENAI_API_KEY`; `AZURE_SPEECH_KEY` with `AZURE_SPEECH_REGION`): if the one the film needs is missing, `oms voice` says which variable, and you ask the person to set it; never ask for a key in the conversation or write one anywhere.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// A 20-second portrait film drawn from code alone: no media, so it shows the syntax a film uses.
|
|
2
|
+
// Images, fonts and sounds would be imported from the project (`import url from './media/shot.png'`), and a
|
|
3
|
+
// sound named by its path: <Sound src="media/chime.wav" at={0.2} volume={-12} />.
|
|
4
|
+
import {Film, Scene, Layer, Line, Sequence, useTime, useVideoConfig, interpolate, Easing, seededRandom} from '@motionhub/runtime';
|
|
5
|
+
|
|
6
|
+
/** The film's size and rate; its scenes decide its length. */
|
|
7
|
+
export const film = {width: 540, height: 960, fps: 24};
|
|
8
|
+
|
|
9
|
+
const INK = '#fff8ef';
|
|
10
|
+
const ACCENT = '#ffc59d';
|
|
11
|
+
const FACE = 'system-ui, sans-serif';
|
|
12
|
+
|
|
13
|
+
/** A headline that rises into place over its first half second; the cover's is there from frame 0, the thumbnail. */
|
|
14
|
+
function Headline({text, cover = false}: {text: string; cover?: boolean}) {
|
|
15
|
+
const now = useTime();
|
|
16
|
+
const t = cover ? 1 : now;
|
|
17
|
+
const y = interpolate(t, [0, 0.55], [24, 0], {easing: Easing.outCubic, clamp: true});
|
|
18
|
+
const opacity = interpolate(t, [0, 0.4], [0, 1], {clamp: true});
|
|
19
|
+
return <div style={{font: `700 62px/1.05 ${FACE}`, letterSpacing: '-0.04em', color: INK, opacity, transform: `translateY(${y}px)`}}>{text}</div>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A card that slides in; inside a <Sequence>, its time starts at the sequence's `from`. */
|
|
23
|
+
function Card({label, tint}: {label: string; tint: string}) {
|
|
24
|
+
const t = useTime();
|
|
25
|
+
const x = interpolate(t, [0, 0.7], [-60, 0], {easing: Easing.outBack, clamp: true});
|
|
26
|
+
const opacity = interpolate(t, [0, 0.3], [0, 1], {clamp: true});
|
|
27
|
+
return (
|
|
28
|
+
<div style={{height: 76, marginBottom: 18, borderRadius: 18, background: tint, opacity, transform: `translateX(${x}px)`,
|
|
29
|
+
display: 'flex', alignItems: 'center', padding: '0 28px', font: `600 40px ${FACE}`, color: '#202320'}}>
|
|
30
|
+
{label}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A field of dots placed by seededRandom, so every frame draws them in the same places, and one picked out. */
|
|
36
|
+
function Detail() {
|
|
37
|
+
const t = useTime();
|
|
38
|
+
const random = seededRandom(7);
|
|
39
|
+
const dots = Array.from({length: 36}, (_, i) => ({i, x: 20 + random() * 452, y: 20 + random() * 252}));
|
|
40
|
+
const picked = dots[11]!;
|
|
41
|
+
const ring = interpolate(t, [1.5, 2.5], [0, 1], {easing: Easing.inOutCubic, clamp: true});
|
|
42
|
+
const pulse = 1 + 0.08 * Math.sin(t * Math.PI * 2);
|
|
43
|
+
return (
|
|
44
|
+
<svg width="100%" height="100%" viewBox="0 0 492 292">
|
|
45
|
+
{dots.map((dot) => (
|
|
46
|
+
<circle key={dot.i} cx={dot.x} cy={dot.y} r={dot === picked ? 12 : 7} fill={dot === picked ? ACCENT : '#5b625b'} />
|
|
47
|
+
))}
|
|
48
|
+
<circle cx={picked.x} cy={picked.y} r={34 * ring * pulse} fill="none" stroke={ACCENT} strokeWidth={4} opacity={ring} />
|
|
49
|
+
</svg>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A bar that fills across the frame's width, read from the film's own size. */
|
|
54
|
+
function Progress() {
|
|
55
|
+
const t = useTime();
|
|
56
|
+
const {width} = useVideoConfig();
|
|
57
|
+
const fill = interpolate(t, [0.2, 1.6], [0, width - 68], {easing: Easing.inOutSine, clamp: true});
|
|
58
|
+
return <div style={{height: 10, width: fill, borderRadius: 5, background: ACCENT}} />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default function Main() {
|
|
62
|
+
return (
|
|
63
|
+
<Film>
|
|
64
|
+
{/* A layer directly in <Film> is drawn across every scene. */}
|
|
65
|
+
<Layer id="background">
|
|
66
|
+
<div style={{height: '100%', background: '#202320'}} />
|
|
67
|
+
</Layer>
|
|
68
|
+
|
|
69
|
+
<Scene id="compose" duration={9}>
|
|
70
|
+
{/* Lines are what a scene says: the script and the subtitles. `at` and `dur` time one in the scene. */}
|
|
71
|
+
<Line id="compose-line">Start with a scene.</Line>
|
|
72
|
+
<Layer id="title" x={34} y={130} w={472} h={155}><Headline text="Start with a scene." cover /></Layer>
|
|
73
|
+
<Layer id="cards" x={34} y={335} w={472} h={292}>
|
|
74
|
+
<Sequence from={0.4} duration={8.6}><Card label="Intro" tint="#d9e6d3" /></Sequence>
|
|
75
|
+
<Sequence from={0.8} duration={8.2}><Card label="Detail" tint="#f3dfc4" /></Sequence>
|
|
76
|
+
<Sequence from={1.2} duration={7.8}><Card label="Ending" tint="#e8d3e6" /></Sequence>
|
|
77
|
+
</Layer>
|
|
78
|
+
</Scene>
|
|
79
|
+
|
|
80
|
+
<Scene id="refine" duration={9}>
|
|
81
|
+
<Line id="refine-line" dur={4}>Pick a detail.</Line>
|
|
82
|
+
<Line id="refine-change" at={4.5}>Say what to change.</Line>
|
|
83
|
+
<Layer id="title" x={34} y={130} w={472} h={155}><Headline text="Pick a detail." /></Layer>
|
|
84
|
+
<Layer id="detail" x={24} y={335} w={492} h={292} z={1}><Detail /></Layer>
|
|
85
|
+
</Scene>
|
|
86
|
+
|
|
87
|
+
<Scene id="download" duration={2}>
|
|
88
|
+
<Line id="download-line">Make your film.</Line>
|
|
89
|
+
<Layer id="title" x={34} y={130} w={472} h={155}><Headline text="Make your film." /></Layer>
|
|
90
|
+
<Layer id="progress" x={34} y={600} w={472} h={10}><Progress /></Layer>
|
|
91
|
+
<Layer id="download-address" x={34} y={730} w={472} h={75}>
|
|
92
|
+
<span style={{font: `500 38px ${FACE}`, color: ACCENT}}>openmotion.studio</span>
|
|
93
|
+
</Layer>
|
|
94
|
+
</Scene>
|
|
95
|
+
</Film>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# The film
|
|
2
|
+
|
|
3
|
+
The film is `film.tsx` at the project's root. Its default export draws a `<Film>` of scenes; `film` gives its size and rate:
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import {Film, Layer, Line, Scene, Sound, interpolate, Easing, useTime} from '@motionhub/runtime';
|
|
7
|
+
|
|
8
|
+
export const film = {width: 1920, height: 1080, fps: 30};
|
|
9
|
+
|
|
10
|
+
export default function Main() {
|
|
11
|
+
return (
|
|
12
|
+
<Film>
|
|
13
|
+
<Sound src="media/bed.mp3" loop volume={-16} fadeOut={2} />
|
|
14
|
+
<Layer id="ground">…</Layer>
|
|
15
|
+
<Scene id="intro" duration={4}>
|
|
16
|
+
<Line id="intro-1">Heat moves uphill, if you push it.</Line>
|
|
17
|
+
<Layer id="title" x={160} y={300} w={1600} h={420}><Title /></Layer>
|
|
18
|
+
</Scene>
|
|
19
|
+
<Scene id="cycle" duration={7}>…</Scene>
|
|
20
|
+
</Film>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- **A scene is one idea, held for `duration` seconds.** Scenes play end to end; the film is as long as they are together, so `film` has no `seconds`. Give each an id that says what it is (`intro`, `cycle`, `cost`).
|
|
26
|
+
- **A layer is a box of the frame**: `x`, `y`, `w`, `h` in the frame's pixels (`check` warns of two placed boxes of a scene that overlap) (the whole frame when left out), stacked by `z`. Lay the scene out as layers that do not collide, each holding one thing (a title, a chart, a diagram). A component that draws in the frame's own coordinates (a motion's often does: read its `meta`) goes in a layer the size of the frame, with no `x`, `y`, `w`, `h`; its parts then share that layer. A layer is on screen for its whole scene. A layer directly in `<Film>` is drawn across every scene (a background, a logo). Name a layer for what it shows (`price-chart`, `runner-photo`, never `box2`): the person finds what to change by those names.
|
|
27
|
+
- **A line is what the scene says**: its words as children (`text` when the caption should differ). It draws nothing; write one for each thing the scene says, as the script the person reads, so a scene's picture and its words stay together. To show words, draw them in a layer. A scene's lines share it evenly; `at` (seconds into the scene) and `dur` say when one is said instead, in order and without overlapping. `<Film captions>` shows the line being said as a caption at the foot of the picture, styled by the motion's `caption` tokens; a film in no motion gives its own by wrapping the `<Film>` in `<MotionScope tokens={{caption: {font, size, weight, color, background, radius, 'padding-y', 'padding-x', bottom}}}>`, its lengths numbers of pixels (`size: 46`, `'padding-y': 14`), or its captions draw black on nothing; `<Caption line="id" />` shows one where you place it. Every export carries the lines as subtitles (an .srt beside the MP4, and a subtitle track in it unless the film draws them as captions), so write them as the words someone reads with the sound off.
|
|
28
|
+
- **A sound is music or an effect from the project's files**: `<Sound src="media/bed.mp3" loop volume={-14} fadeIn={1} fadeOut={2} />` directly in `<Film>` plays across the film (a bed under everything); one in a scene plays in that scene's time, `at` seconds after its start (`<Sound src="media/whoosh.wav" at={0.4} volume={-6} />`), and stops at its end. `volume` is in dB (0 is the file as it is: keep a bed around -14 to -18, a single effect file around -6 to -10); `dur` and `trim` take a part of the file; `loop` repeats it. Use only sounds the person brought into `media/` or asked for; time an effect to the motion it goes with. It draws nothing, and `check` lists every sound and fails on a file the project does not have. Give a music bed `duck={10}` to sink it 10 dB while the narration speaks.
|
|
29
|
+
- **A recorded clip is a `<Video>`**: import its file as an image is imported (`import clip from './media/demo.mp4'`) and draw `<Video src={clip} />` in a layer, which it fills (`objectFit` `cover`, the default, `contain` or `fill`); a path in place of the import is refused. It plays from the start of its scene, or of the `<Sequence>` around it: `startAt` (seconds) shows it later, `trimBefore` (seconds) starts its source further in, `playbackRate` changes its speed, and its last frame holds once it has ended. Every frame shows the clip's own frame at that time, in the preview, a still, the export and the web player. It plays muted. Use the person's own clips, as H.264 MP4 (a screen recording's MOV of H.264 plays too) or WebM, cut to the seconds the film needs: every place the film plays holds each whole clip in memory. A clip that will not load or play fails the film with its reason. To move in on part of it, scale and move the box holding it by `useTime()`, as any picture.
|
|
30
|
+
- **A narration speaks the lines**: `<Film voice="azure:zh-CN-XiaoxiaoNeural">` names the voice, as `provider:name` from `list_voices` (only from providers the person set up; if none is, ask them to set one up in Models, under Voices). `voice_lines` speaks every line whose words changed into `voice/` (each is paid for, so finish the words first), then a voiced line lasts as long as its speech: give it no `dur`, and let the scene be long enough. `check` marks voiced lines, names those not yet spoken, and says which speech is cut short by the next line or the scene's end. `<Film captions="words">` lights each word of a voiced caption as it is said; `useLine(id)` gives a line's `{start, end, words}` in its scene's time, to move the picture with what is said.
|
|
31
|
+
- **How things move is yours.** Inside a layer, `useTime()` counts from its scene's start (from the film's start in a film's own layer). Draw entrances, builds and exits from it with `interpolate`, `Easing` and `<Sequence from duration>`; end a scene's motion before its end, or carry it into the next on purpose. A scene's picture is in by about half a second after it opens (its layers brought in from the film's ground over that time; `check` warns of a scene still empty then) and each line changes it; ease every move (`easing`, `clamp: true`), and let its last picture hold for a second before it ends.
|
|
32
|
+
- Draw from `useTime()` only: never a clock, a timer, `requestAnimationFrame`, CSS animations or transitions, or `Math.random` (use `seededRandom(seed)`). The same time must always draw the same frame: the export photographs each frame in turn.
|
|
33
|
+
- `@motionhub/runtime` also gives `<Video>`, `useCompositionTime`, `useVideoConfig`, `useTokens`, `seededRandom`, `interpolate(t, input, output, {easing, clamp})`, `Easing` (`linear`, `bezier(x1,y1,x2,y2)`, `inOutSine`, `outCubic`, `outQuart`, `inOutCubic`, `outBack`), `<Sequence from duration>` (its children count time from its start), `<MotionRoot>`, `<MotionScope tokens>` and `<Caption>`.
|
|
34
|
+
- React, `@motionhub/runtime` and three.js (`three` 0.187.0 and its subpaths, such as `three/addons/…`, for real 3D) are provided. A page keeps at most 16 WebGL contexts: draw 3D with one renderer a layer (or one shared), and lose its context when its layer goes (`renderer.dispose(); renderer.forceContextLoss()`); a context the browser drops is the film's error. Anything else must be in the project; put the film's own components in `parts/`. Images, fonts and sounds in the project can be imported (`import url from './assets/map.png'`); a `<Sound>` may name its file by its path instead. A font of the project's is declared where the film draws, `` <style>{`@font-face { font-family: 'Name'; src: url(${url}); }`}</style> ``; the Studio loads it before any frame is drawn. `use_font` takes a face from Google Fonts into `media/fonts/`, cut to the characters the project writes, with its licence, and says what to declare: take every face the film names that its motion does not ship, and take it again when the words change.
|
|
35
|
+
- Keep text large enough to read on a phone: headlines 84 px or more, other text 40 px or more, unless a motion the film draws in gives its own sizes, which come first. Use four or five sizes in all, and let weight and colour do the rest. With `<Film captions>`, keep text and key graphics clear of the caption at the foot of the frame (below about 900 of 1080 px; in a portrait 1080 × 1920 frame, give the caption a `bottom` of about 280 and keep clear below about 1450).
|
|
36
|
+
|
|
37
|
+
# Motions
|
|
38
|
+
|
|
39
|
+
A motion is a look written down: `MOTION.md` (its rules), `tokens.json` (exact colours, faces, durations, curves) and often React components in `react/parts/`, each with a `meta` saying what it is for and what its parameters mean. A project keeps motions in `motions/`: from motionhub at `motions/@<scope>/<slug>/`, its own at `motions/<name>/`.
|
|
40
|
+
|
|
41
|
+
- When the person names a look or asks for one, find it with `search_motions` and take it with `use_motion`. Never change a copy in `motions/@<scope>/`; to adapt one, copy what you need into `parts/`.
|
|
42
|
+
- Before drawing in a motion, read all of its `MOTION.md` and its `tokens.json`, then the `meta` of the components you will use. Its rules are binding and come before this format's defaults (its type sizes, its spacing, how its components are placed): every colour, face, duration and easing comes from its tokens, by name; its Avoid list is checked before you finish. Its own components are drawn as it made them, even where one seems to break a rule of its own (an accent on a component's edge): its rules and its Avoid list govern what you draw around them.
|
|
43
|
+
- Draw in it by wrapping the `<Film>` in its tokens (or one scene, or one layer, for a film in several motions), so its components and `var(--color-<name>)` / `var(--font-<name>)` resolve:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import {MotionScope} from '@motionhub/runtime';
|
|
47
|
+
import tokens from './motions/@iamsuosi/plumb-line/tokens.json';
|
|
48
|
+
import {Heading} from './motions/@iamsuosi/plumb-line/react/parts/heading.tsx';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- A motion's own faces (its `react/fonts/`, when it ships them) are loaded for you before the film draws: set type with its `var(--font-<name>)`, never by a family name of your own. A motion that names faces it does not ship needs them declared from the project's files; `check` warns of any text, or any character of it, drawn in a face never loaded.
|
|
52
|
+
- A component's `progress` parameter runs from 0 to 1: drive it with `interpolate` on the time it should happen.
|
|
53
|
+
- A motion's `react/reel.tsx` shows how its components move. Read it for technique; never copy its story, words or layout.
|
|
54
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Assets: what you may use, and where it goes
|
|
2
|
+
|
|
3
|
+
## What you may keep
|
|
4
|
+
|
|
5
|
+
Public domain, CC0, CC BY with its attribution, CC BY-SA with its share-alike, for a font the SIL Open Font License (keep its licence file beside it; `oms font` writes it), or a brand kit whose terms allow the use. Never "free to look at", never a file of unknown origin, never a hotlink: a film loads only the project's own files. A licence you cannot name is a reason not to use the file. No book covers, film stills or portraits of real people without a licence that allows them.
|
|
6
|
+
|
|
7
|
+
Write each fetched file's source page and licence in a comment where the film imports it, and list the credits the licences ask for where the person will publish them.
|
|
8
|
+
|
|
9
|
+
## Where it goes
|
|
10
|
+
|
|
11
|
+
- Into `media/`, under a lower-case, hyphenated name for what it shows (`media/rocket-launch.jpg`). Reuse a file already there before fetching again.
|
|
12
|
+
- Note each image's size and aspect: they decide the layout.
|
|
13
|
+
- Prefer a photograph of the real place or event; draw what has no photograph.
|
|
14
|
+
- Cut a video clip to the seconds the film needs before using it.
|
|
15
|
+
- Line art reads on any ground when it is ink-coloured on a transparent ground and cropped. Never a figure or a word drawn into an illustration: words are drawn by the film, in its faces.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Craft: script, motion, pacing, sound, honesty
|
|
2
|
+
|
|
3
|
+
## Script
|
|
4
|
+
|
|
5
|
+
- Write for 75 to 90 percent of the length asked, not a fraction of it. Read at about 2.8 words a second in English and 4.5 characters a second in Chinese: 45 seconds is about 120 words, in four or five scenes. A narrated film is longer than its speech: each voiced line waits 0.4 s before it, and each scene holds a second after its last, so count those in (eight lines in four scenes add about 7 s).
|
|
6
|
+
- One `<Line>` a sentence, one idea a sentence. The lines are the script and the subtitles, so write them as words someone reads with the sound off.
|
|
7
|
+
- Never draw the spoken sentence word for word: the caption carries it. Layers carry what a viewer wants to keep in view: a heading, a key line, figures, labels, a formula.
|
|
8
|
+
- On screen a label is a phrase, a key line one or two short lines, a figure a number and its name.
|
|
9
|
+
|
|
10
|
+
## Motion
|
|
11
|
+
|
|
12
|
+
- **The stage is in use as soon as a scene has entered.** By half a second in every layer draws its base state (low bars, a faint curve, the outline); empty axes or a frame waiting for a word are not a picture, and a frame with only a title is unfinished.
|
|
13
|
+
- **One main change a line**, when that line names its subject. Without word times, place it in the line's share of the scene (its `at`, or its slot when the scene's lines share it evenly). A fact is never on screen before its line starts.
|
|
14
|
+
- **Motion means something.** An arrival says "here is a new thing", a growth "this quantity", a slide or morph "this became that", a draw "this leads there". A quantity changes by counting up or growing a bar: `Math.round(interpolate(t, [a, b], [0, 76], {easing: Easing.outQuart, clamp: true}))`. Motion that pulls the eye from what the line is about is decoration; leave it out.
|
|
15
|
+
- **Ease everything**, and clamp: pass `easing` and `clamp: true` to every `interpolate`. Only time itself moves at a constant speed (`Easing.linear`).
|
|
16
|
+
- **Scenes enter**: fade or rise each scene's layers over about half a second (`interpolate(t, [0, 0.5], …)`), from the same ground: keep a film-level ground layer the scenes' colour, so a cut never flashes another one. The cover is the exception (Pacing).
|
|
17
|
+
- **One focus at a time.** The rest stays quiet, or dims the same way each time. What a line replaces leaves before the new thing arrives; before and after share a frame only when the line compares them; things that merge go into each other without overprinting.
|
|
18
|
+
- **Every object has a reason** the lines give, and goes once that reason is past. A layer lives for its whole scene, so "goes" is a fade inside it.
|
|
19
|
+
- **A picture continues; it is not redrawn.** One that runs over several lines is one layer whose numbers move with time. One that carries into the next scene is the same component there, starting where the last scene left it, or a layer in `<Film>`.
|
|
20
|
+
- **Show the thing, not a label for it**: a command with what it prints, a file by its contents, a formula with each term lit as it is named, a feeling by a metaphor, a familiar product or kind of thing beside its name.
|
|
21
|
+
|
|
22
|
+
## Pacing
|
|
23
|
+
|
|
24
|
+
- **At least two seconds on screen** from when a thing appears to when it goes; a flash only when the flash is the point.
|
|
25
|
+
- **Hold the end**: a scene's motion ends a second or more before its `duration`, so its last picture holds.
|
|
26
|
+
- **The cover**: frame 0 is the thumbnail. The first scene shows its title picture at t = 0 with no fade (one illustration, one big figure, one short line, nothing else), and the film moves on a few seconds in.
|
|
27
|
+
- **A photo holds eight seconds at most**: move it slowly (an interpolated `scale` or `x`) or cut.
|
|
28
|
+
|
|
29
|
+
## Sound
|
|
30
|
+
|
|
31
|
+
A film's sound is a narration when the person asks for one (`oms voice`, below), music the person gives, and effects from `oms sound`: its motion's sound when it draws in one, oms's own when it does not.
|
|
32
|
+
|
|
33
|
+
- **Effects follow the picture**, one cue for each thing a viewer should feel happen, not one for every element: `land` when something arrives and settles, `move` for a slide, morph or camera move (with its length, `at:move:dur`), `draw` for a stroke drawn on (with its length), `count` as a figure counts up, `cut` at a scene's change, `out` as something leaves. Take the times from your board: the moment, not the start of a long ease. An effect that tells the viewer nothing the picture does not is noise; leave it out.
|
|
34
|
+
- **The roles are the sound's**: oms's own has all six; a motion's sound gives some of them, not always all; `oms sound` names the ones it has and refuses a cue for any other. Pick the nearest it has (a `move` for something leaving when it has no `out`).
|
|
35
|
+
- **One track**: `oms sound` renders every cue into one WAV as long as the film, in the motion's own sound (its `react/sound.json`), or in oms's own, plain and with no bed, when the project has no motion. A sound with a `bed` plays it, a soft tone under the whole film, beneath its hits: that is the motion's, not a fault. The track comes mixed, so play it as it is, `<Sound src="media/effects.wav" />` directly in `<Film>` (the -6 to -10 dB of film-format.md is for a single effect file of your own); under music, take it down 3 to 6 dB (`volume={-4}`). `oms sound` prints the track's peak and each cue's own (without the bed, before the next cue): a cue it marks not heard made no sound, so change its role. Change a cue, render a new track under a new name, and point the `<Sound>` at it.
|
|
36
|
+
- **Music**: a bed under everything, `<Sound src="media/music.mp3" loop volume={-16} fadeIn={1} fadeOut={3} />`, between -18 and -14 dB, in from the start or once the title has landed, out a few seconds after the last line. With a narration give it `duck={10}`, which sinks it while a line is said; without one, keep it low enough for the effects to read over it.
|
|
37
|
+
- **Narration**: the lines are what it says, so write them to be heard: short sentences, numbers as they are said in the words it speaks and as they are written in its `text`, which the caption shows (`<Line id="rise" text="升高了 1.5 °C">升高了一点五摄氏度</Line>`), about 4.5 Chinese characters or 2.5 English words a second. `oms voice` speaks each line whose words changed into `voice/` and keeps the rest; each clip is levelled to -16 LUFS (the whole film, with effects and music over it, measures louder, near -14), so play effects under it 3 to 6 dB lower than without. A voiced line lasts as long as its speech, after a lead of 0.4 s (the scene's first line) or a hold of 0.4 s (the others): give it no `dur`, let `oms check` say which speech is cut short, and lengthen that scene rather than cut the words (speech cut short loses the words past the cut, and their times). A voiced line may take an `at` to start sooner or later than that, in order and without overlapping. Time what the picture does to what is said with `useLine(id)` (its `{start, end, words}` in the scene's time; in Chinese each word is one character, so find a phrase by its characters).
|
|
38
|
+
- **A narration the person records**: finish the lines first, then ask for one take of them in order, as written (the `text` where a line has one, read as it is said), in any file ffmpeg reads (m4a, mp3, wav). Pauses between lines, silence before the first and a filler between lines ("嗯", "um") do no harm; a line left out or read too differently does. Keep the take outside the project folder, or out of git. Give `<Film>` `voice="recording:take"` (`take` is a name for the take, any name, not its file's; changing it means importing again) and run `oms voice "<folder>" --recording "<file>"`. It transcribes the take with the first key the environment holds of MiniMax, OpenAI and ElevenLabs (`--transcribe <provider>` picks one; it costs what the provider charges for the take's length, once: the transcript is kept by the file's hash, and the output says when it was used), matches it to the lines character by character and cuts one clip a line into `voice/`. Read what it prints:
|
|
39
|
+
- A line read less than 75 percent as written stops it, writing nothing, with what was heard: they record it again, or you write the line as they said it.
|
|
40
|
+
- Every other line read otherwise is still cut, and listed with each difference (`"一瞬间" heard as "一眨眼"`, `added "嗯"`). Its caption shows the written words, timed by what was said, so a changed word is on screen but not in the sound. A transcriber spells homophones and numbers its own way (`地` as `的`, `3` as `三`): those are not differences to fix. For a real one, write the line as it was said and run the import again; the transcript is kept, so nothing is paid.
|
|
41
|
+
- Words said between the lines are left out of every clip and listed with their times. A filler that shares letters with the next line (English more than Chinese) can instead be taken into that line and shows as one of its differences.
|
|
42
|
+
- You cannot hear the film: keep levels where these numbers put them, read what `oms sound` and `oms voice` print, and say in your report that the sound is unheard.
|
|
43
|
+
|
|
44
|
+
## Honest pictures
|
|
45
|
+
|
|
46
|
+
- A figure on screen carries its scope (who, how many, which task) on the same screen, and is attributed to its source.
|
|
47
|
+
- Results from different experiments are not drawn on one axis without saying so.
|
|
48
|
+
- A calculation is labelled as one; an illustration says it is one.
|
|
49
|
+
- A range that crosses its reference value is drawn hollow, not as a result.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Drawing: layout, data, recipes, determinism
|
|
2
|
+
|
|
3
|
+
## Layout and data
|
|
4
|
+
|
|
5
|
+
- Lay out inside a layer with CSS flex and grid, not hand-placed coordinates.
|
|
6
|
+
- Data drives the picture: bars, ticks and dots are a `.map` over a table, positioned by a scale function; a key comes from the same table.
|
|
7
|
+
- Draw with SVG; HTML for text; a canvas only for thousands of particles. three.js (provided) for real 3D: create the renderer once with `preserveDrawingBuffer: true`, render once a frame in a `useLayoutEffect` keyed on `useTime()`, and keep every word in HTML over the canvas.
|
|
8
|
+
|
|
9
|
+
## Recipes (inside a layer, `const t = useTime()`)
|
|
10
|
+
|
|
11
|
+
- **Count up**: `const n = Math.round(interpolate(t, [0.5, 2], [0, 76], {easing: Easing.outQuart, clamp: true}))`.
|
|
12
|
+
- **Stagger a series**: offset each item's window by its index, `interpolate(t, [0.4 + i * 0.12, 0.9 + i * 0.12], [0, 1], {easing: Easing.outCubic, clamp: true})`, or wrap each in `<Sequence from={0.4 + i * 0.12}>`.
|
|
13
|
+
- **A stroke that draws itself**: `const draw = interpolate(t, [1, 2.5], [0, 1], {easing: Easing.inOutCubic, clamp: true})`, then `<path strokeDasharray={len} strokeDashoffset={len * (1 - draw)} />`.
|
|
14
|
+
- **Typing**: `text.slice(0, Math.round(interpolate(t, [0, 2], [0, text.length], {clamp: true})))`.
|
|
15
|
+
- **A slow move on a photo**: `transform: scale(${interpolate(t, [0, 8], [1, 1.08], {easing: Easing.inOutSine})})`.
|
|
16
|
+
- **A long film's chapter rail**: a layer in `<Film>`, filled by `useCompositionTime()` against the scenes' spans.
|
|
17
|
+
|
|
18
|
+
## Formulas
|
|
19
|
+
|
|
20
|
+
Variables in italic; `<sup>` and `<sub>` for powers and indices; a fraction is a column over a rule. Each term is its own element, lit on the line that names it. The lines say what a term means; they do not read the formula out.
|
|
21
|
+
|
|
22
|
+
## Determinism
|
|
23
|
+
|
|
24
|
+
Beyond film-format.md (time from `useTime()` only, `seededRandom`, no clocks or CSS animations):
|
|
25
|
+
- Round computed positions to whole pixels (`Math.round`) for crisp edges.
|
|
26
|
+
- Draw an arrow as one filled shape, not a line and a head.
|
|
27
|
+
- Use only the font weights the face has.
|
|
28
|
+
- Drive three.js from `useTime()`, never from its own clock or loop.
|
|
29
|
+
- Keep a growing shape's scale off exactly 0 when it must be seen.
|