@motionhub/oms 0.1.0 → 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 +8 -1
- package/dist/resources/preview/core.js +7 -7
- package/dist/worker.cjs +240 -76
- package/oms.mjs +21 -11
- package/package.json +1 -1
- package/skills/oms/SKILL.md +4 -2
- package/{dist → skills/oms}/film-format.md +3 -2
- package/skills/oms/references/look.md +1 -1
- /package/{dist → skills/oms}/example/film.tsx +0 -0
package/oms.mjs
CHANGED
|
@@ -54,8 +54,9 @@ async function sound(args) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* `oms font <folder> --family <name> [--weights 400,700]`: a face from Google Fonts cut to the characters the
|
|
58
|
-
* writes, into its media/fonts/ with its licence; run again
|
|
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.
|
|
59
60
|
*/
|
|
60
61
|
async function font(args) {
|
|
61
62
|
const { values, positionals } = parseArgs({ args, options: { family: { type: 'string', multiple: true }, weights: { type: 'string' } }, allowPositionals: true });
|
|
@@ -73,10 +74,16 @@ async function font(args) {
|
|
|
73
74
|
const ofl = await readFile(worker.OFL, 'utf8');
|
|
74
75
|
const name = (file) => file.replace(/^.*\//, '').replace(/\.ttf$/, '').replace(/-/g, '_').replace(/^(\d)/, '_$1');
|
|
75
76
|
const declared = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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 });
|
|
80
87
|
}
|
|
81
88
|
console.log('Run this again when the words change. Declare them where the film draws:');
|
|
82
89
|
for (const { file } of declared) console.log(` import ${name(file)} from './${file}';`);
|
|
@@ -109,6 +116,7 @@ async function voice(args) {
|
|
|
109
116
|
const done = await worker.voice(dir, scratch, (n, of) => process.stderr.isTTY && process.stderr.write(`\rSpeaking ${n}/${of}`));
|
|
110
117
|
if (process.stderr.isTTY) process.stderr.write('\n');
|
|
111
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.`);
|
|
112
120
|
} finally {
|
|
113
121
|
await rm(scratch, { recursive: true, force: true, maxRetries: 4 });
|
|
114
122
|
}
|
|
@@ -140,9 +148,8 @@ async function run() {
|
|
|
140
148
|
throw error;
|
|
141
149
|
});
|
|
142
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.
|
|
143
152
|
await cp(join(root, 'skills/oms'), dest, { recursive: true });
|
|
144
|
-
await copyFile(join(root, 'dist/film-format.md'), join(dest, 'film-format.md'));
|
|
145
|
-
await cp(join(root, 'dist/example'), join(dest, 'example'), { recursive: true });
|
|
146
153
|
} catch (error) {
|
|
147
154
|
await rm(dest, { recursive: true, force: true });
|
|
148
155
|
throw error;
|
|
@@ -163,9 +170,11 @@ async function run() {
|
|
|
163
170
|
// The film as one file for the Studio's Import (ADR 0019): beside the folder unless --out names another place.
|
|
164
171
|
const out = resolve(values.out ?? `${dir}.oms`);
|
|
165
172
|
const worker = createRequire(import.meta.url)(join(root, 'dist/worker.cjs'));
|
|
166
|
-
const { files, bytes } = await worker.pack(dir, out);
|
|
173
|
+
const { files, bytes, leftOut } = await worker.pack(dir, out);
|
|
167
174
|
console.log(out);
|
|
168
|
-
|
|
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.`);
|
|
169
178
|
}
|
|
170
179
|
if (!['still', 'check', 'render', 'player', 'preview'].includes(command)) throw new Error(usage);
|
|
171
180
|
if (command === 'player' && !values.out) throw new Error(usage);
|
|
@@ -187,11 +196,12 @@ async function run() {
|
|
|
187
196
|
// Ctrl-C stops the render cleanly: its Chromes closed, its finished segments kept for the next run.
|
|
188
197
|
const stop = new AbortController();
|
|
189
198
|
process.once('SIGINT', () => stop.abort());
|
|
190
|
-
await worker.render(dir, scratch, resolve(values.out), (done) => {
|
|
199
|
+
const { drawnOn } = await worker.render(dir, scratch, resolve(values.out), (done) => {
|
|
191
200
|
const percent = Math.floor(done * 100);
|
|
192
201
|
if (percent !== shown && process.stderr.isTTY) process.stderr.write(`\rRendering ${(shown = percent)}%`);
|
|
193
202
|
}, stop.signal);
|
|
194
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.`);
|
|
195
205
|
return console.log(resolve(values.out));
|
|
196
206
|
}
|
|
197
207
|
if (command === 'player') {
|
package/package.json
CHANGED
package/skills/oms/SKILL.md
CHANGED
|
@@ -5,6 +5,8 @@ description: Make, inspect, revise or render OpenMotionStudio (OMS) motion video
|
|
|
5
5
|
|
|
6
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
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
|
+
|
|
8
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.
|
|
9
11
|
|
|
10
12
|
## Order of work
|
|
@@ -16,10 +18,10 @@ Read the bundled [film format](film-format.md) first, then the [example film](ex
|
|
|
16
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.
|
|
17
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".
|
|
18
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.
|
|
19
|
-
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 or the Studio's state), which the Studio's Import project opens as a new project.
|
|
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.
|
|
20
22
|
|
|
21
23
|
Assets the person gives or you fetch follow [assets](references/assets.md).
|
|
22
24
|
|
|
23
25
|
## In this host
|
|
24
26
|
|
|
25
|
-
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`, `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.
|
|
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.
|
|
@@ -26,11 +26,12 @@ export default function Main() {
|
|
|
26
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
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
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.
|
|
29
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.
|
|
30
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.
|
|
31
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.
|
|
32
|
-
- `@motionhub/runtime` also gives `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>`.
|
|
33
|
-
- React, `@motionhub/runtime` and three.js (`three` 0.187.0 and its subpaths, such as `three/addons/…`, for real 3D) are provided. 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.
|
|
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.
|
|
34
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).
|
|
35
36
|
|
|
36
37
|
# Motions
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
## Type
|
|
11
11
|
|
|
12
12
|
- A motion's type scale comes first: its sizes, as its `MOTION.md` and tokens give them, even below the defaults here. Without one: four or five sizes in all, weight and colour doing the rest; headlines 84 px or more, other text 40 px or more (film-format.md), key text 80 px from the frame's sides.
|
|
13
|
-
- Name only faces the film loads (its motion's, or one declared from the project's files). For a face of your own, or a motion's that its download does not carry, `oms font "<folder>" --family "Noto Sans SC" --weights 400,700` takes it from Google Fonts cut to the characters the
|
|
13
|
+
- Name only faces the film loads (its motion's, or one declared from the project's files). For a face of your own, or a motion's that its download does not carry, `oms font "<folder>" --family "Noto Sans SC" --weights 400,700` takes it from Google Fonts cut to the characters the film writes, words it imports from outside the project included (`--family` again for each other face, as `--family "Big Shoulders Display:700"`), into `media/fonts/` with its licence, and prints the `@font-face` to declare; run it again whenever the words change, and `check` names any character it lacks. A family that is not loaded draws in the machine's fallback, so frames differ between machines, and so does every character the loaded faces lack (Chinese after a Latin face): load a face for each script the film writes. `check` names both. Never look for fonts on the system.
|
|
14
14
|
- Large lowercase letters in a sans face can read as capitals; set such a name in the mono face.
|
|
15
15
|
|
|
16
16
|
## The frame
|
|
File without changes
|