A motion design toolkit for coding agents.
JavaScript
Run Python as `python` on Windows and print UTF-8 from sfx
Dan Wellsf3ef96ee8255
diff --git a/AGENTS.md b/AGENTS.mdindex c806dd5..705b1bd 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -46,7 +46,7 @@ ffmpeg -y -i out/<name>-silent.mp4 -i public/<name>.wav -map 0:v -map 1:a -c:v cThe example has shortcuts: `npm run draft`, `npm run sfx`, `npm run build` (sound + render + mux → `out/effort.mp4`), `npm run cover`, `npm run gif`.-Requirements: Node 20+, Python 3, ffmpeg. If `/usr/bin/chromium` (or `$REMOTION_BROWSER`) exists it's used; otherwise Remotion downloads its own browser on first render.+Requirements: Node 20+, Python 3, ffmpeg. On Windows, run `python` wherever these docs say `python3`. If `/usr/bin/chromium` (or `$REMOTION_BROWSER`) exists it's used; otherwise Remotion downloads its own browser on first render.## Layoutdiff --git a/package.json b/package.jsonindex eda8879..3c523a7 100644--- a/package.json+++ b/package.json@@ -8,7 +8,7 @@"still": "remotion still EffortVideo","draft": "remotion render EffortVideo out/draft.mp4 --scale=0.5 --crf=28","render": "remotion render EffortVideo out/effort-silent.mp4",- "sfx": "python3 -m sfx sfx/cues/effort.py",+ "sfx": "node scripts/py.mjs -m sfx sfx/cues/effort.py","mux": "ffmpeg -loglevel error -y -i out/effort-silent.mp4 -i public/sfx.wav -map 0:v -map 1:a -c:v copy -c:a aac -b:a 256k -movflags +faststart -shortest out/effort.mp4","build": "npm run sfx && npm run render && npm run mux","sheet": "node scripts/sheet.mjs",diff --git a/scripts/py.mjs b/scripts/py.mjsnew file mode 100644index 0000000..3099f98--- /dev/null+++ b/scripts/py.mjs@@ -0,0 +1,7 @@+// Runs Python 3 with the given arguments on any OS: `python3` on macOS and+// Linux, `python` on Windows, where `python3` is usually a Microsoft Store stub.+import {spawnSync} from 'node:child_process';++const python = process.platform === 'win32' ? 'python' : 'python3';+const result = spawnSync(python, process.argv.slice(2), {stdio: 'inherit'});+process.exit(result.status ?? 1);diff --git a/sfx/__init__.py b/sfx/__init__.pyindex fd8be6e..50f901e 100644--- a/sfx/__init__.py+++ b/sfx/__init__.py@@ -4,6 +4,14 @@python3 -m sfx --list list the sound generators"""+import sys++# Windows consoles and pipes default to cp1252, which cannot print the arrows and+# minus signs these scripts use. Any script that imports sfx gets UTF-8 output.+for _stream in (sys.stdout, sys.stderr):+ if hasattr(_stream, "reconfigure") and (_stream.encoding or "").lower() != "utf-8":+ _stream.reconfigure(encoding="utf-8")+from .mix import Mixfrom .synth import SRdiff --git a/sims/capture.mjs b/sims/capture.mjsindex e7be4a8..60cf992 100644--- a/sims/capture.mjs+++ b/sims/capture.mjs@@ -46,7 +46,7 @@ if (music) {fs.mkdirSync(path.dirname(cache), {recursive: true});const {execFileSync} = await import('node:child_process');if (!fs.existsSync(cache) || fs.statSync(cache).mtimeMs < fs.statSync(music).mtimeMs) {- execFileSync('python3', [path.join(HERE, 'beats.py'), music, '--duration', String(dur), '--start', ms, '-o', cache], {stdio: 'inherit'});+ execFileSync(process.platform === 'win32' ? 'python' : 'python3', [path.join(HERE, 'beats.py'), music, '--duration', String(dur), '--start', ms, '-o', cache], {stdio: 'inherit'});}beats = JSON.parse(fs.readFileSync(cache, 'utf8'));if (!opt('no-sync')) config.beats = beats;