huashu-motion 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/lib/render-om.js +2 -1
- package/cli/lib/render.js +11 -1
- package/package.json +1 -1
- package/skills/huashu-motion/SKILL.md +1 -1
package/cli/lib/render-om.js
CHANGED
|
@@ -162,7 +162,8 @@ export async function renderOm(project, { fps, out, format = 'mp4', transparent
|
|
|
162
162
|
const write = async (buf) => {
|
|
163
163
|
if (enc.exitCode != null) throw new OmError(`ffmpeg stopped early: ${encErr.trim().split('\n').pop()}`);
|
|
164
164
|
// an encoder that dies while the pipe is full never drains: wake on its exit too, then report it
|
|
165
|
-
|
|
165
|
+
// both listeners go once either fires: a long render waits here every frame and must not pile them up
|
|
166
|
+
if (!enc.stdin.write(buf)) await new Promise((ok) => { const done = () => { enc.stdin.off('drain', done); enc.off('close', done); ok(); }; enc.stdin.once('drain', done); enc.once('close', done); });
|
|
166
167
|
if (enc.exitCode != null) throw new OmError(`ffmpeg stopped early: ${encErr.trim().split('\n').pop()}`);
|
|
167
168
|
};
|
|
168
169
|
// Work goes out in small runs of consecutive frames (chunk), dealt round-robin: a heavy scene is spread over all
|
package/cli/lib/render.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// om render: the film as a video file, through the huashu-motion renderer (render-om.js). Output always
|
|
2
2
|
// lands in <project>/out/ with a new name — a render never overwrites a file the user may already have shared.
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { existsSync, mkdirSync, readdirSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { existsSync, mkdirSync, readdirSync, statSync, unlinkSync, writeFileSync, writeSync } from 'node:fs';
|
|
5
5
|
import { join, sep } from 'node:path';
|
|
6
6
|
import { OmError, readSource, readVariables } from './project.js';
|
|
7
7
|
import { FORMATS, renderOm } from './render-om.js';
|
|
@@ -45,6 +45,14 @@ export async function render(project, { format, fps, out, transparent = false, b
|
|
|
45
45
|
const switchVar = transparent && readVariables(html).some((v) => v.id === 'transparent' && v.type === 'boolean');
|
|
46
46
|
const claimed = !out;
|
|
47
47
|
const target = out || nextOutput(project, format);
|
|
48
|
+
// If the process ends while the render is still running (it is exited, or it runs out of work because something it
|
|
49
|
+
// waits for vanished without a word), the catch below never runs: drop the empty placeholder and never exit 0.
|
|
50
|
+
const unfinished = () => {
|
|
51
|
+
try { if (claimed && statSync(target).size === 0) unlinkSync(target); } catch { /* already gone */ }
|
|
52
|
+
if (!process.exitCode) process.exitCode = 1;
|
|
53
|
+
try { writeSync(2, `om: the render stopped before it finished — no file was written (${target})\n`); } catch { /* no stderr */ }
|
|
54
|
+
};
|
|
55
|
+
process.once('exit', unfinished);
|
|
48
56
|
let r;
|
|
49
57
|
try {
|
|
50
58
|
r = await renderOm(project, { fps, out: target, format, transparent, blur, video, variables: switchVar ? { transparent: true } : null, ...(workers ? { workers } : {}), ...(frameFormat ? { frameFormat } : {}), ...tune, allowPageErrors, prepare, verify: transparent ? (file) => checkOverlay(file, switchVar, onWarn) : null, onLog, onNote, onWarn });
|
|
@@ -52,6 +60,8 @@ export async function render(project, { format, fps, out, transparent = false, b
|
|
|
52
60
|
// the version we claimed stays free for the next try (only the empty placeholder is removed, never a film)
|
|
53
61
|
if (claimed && existsSync(target) && statSync(target).size === 0) unlinkSync(target);
|
|
54
62
|
throw e;
|
|
63
|
+
} finally {
|
|
64
|
+
process.off('exit', unfinished);
|
|
55
65
|
}
|
|
56
66
|
const { token } = readSource(project); // what was rendered: the source after the sound refresh
|
|
57
67
|
onLog(`done ${r.frames} frames in ${r.stats.renderSeconds.toFixed(1)}s (${(r.frames / r.stats.renderSeconds).toFixed(1)} fps), total ${r.stats.totalSeconds.toFixed(1)}s, workers ${r.stats.workers}, sound ${r.stats.audio}${r.stats.loudness?.lufs != null ? `, ${r.stats.loudness.lufs} LUFS` : ''}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huashu-motion",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Make motion graphics with your own coding agent — point at the frame to change it. Open, local, with sound.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "om": "cli/om.js", "huashu-motion": "cli/om.js" },
|