remotion-ffmpeg-skill 0.17.0 → 0.18.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/SKILL.md +1 -0
- package/package.json +1 -1
- package/references/scripts.md +6 -3
- package/references/timeline.md +3 -0
- package/scripts/_common.py +23 -2
- package/scripts/_contract.py +2 -0
- package/scripts/doctor.py +18 -1
- package/scripts/render.py +5 -1
- package/scripts/still.py +3 -1
- package/templates/remotion-project/package.json +5 -1
- package/templates/remotion-project/src/Root.tsx +2 -0
- package/templates/remotion-project/src/compositions/ThreeScene.tsx +83 -0
- package/templates/remotion-project/src/timeline.ts +6 -0
package/SKILL.md
CHANGED
|
@@ -69,6 +69,7 @@ Moving text has three owners: word-timed caption effects are this skill's, anima
|
|
|
69
69
|
| several clips ("intro + talk + outro") | `analyze.py A.mp4 B.mov C.mp4` (or `pipeline.py` with several inputs): ffmpeg-skill join.py normalises and joins them, then everything is measured on the joined file |
|
|
70
70
|
| "kinetic type / lyric video / words that hit on the beat" | `analyze.py [SOURCE \| --blank S --music song.wav] --captions lyrics.srt --beats --kinetic beats` (each word, or Japanese / Chinese character, on the next measured beat; `--kinetic-step N` beats apart) or `--words WORDS.json --kinetic words` (each word at its spoken time) → `render.py --comp KineticType` (`kineticStyle`, `kineticReveal`, `kineticStagger`, `kineticSize`). Only measured timings: kinetic type from a JSON request with no measurement is hyperframes-skill's |
|
|
71
71
|
| "audio visualizer / spectrum / waveform / podcast or music video from the audio" / a loop for an edit | `analyze.py SOURCE` (or `--blank S --music song.wav`) `[--beats] [--words W.json]` → `render.py --comp Visualizer` (`visualizer`: bars, spectrum, radial, waveform; lyrics as Karaoke draws them). A loop: `--beats` and `{"loopBars": 0}` (or N) in `--options`: whole measured bars, seam halfway between beats; check it with qc-skill's `video.loop_seam` |
|
|
72
|
+
| "3D / Three.js / particles that hit on the beat" | `analyze.py [--beats]` (or `--blank S --music song.wav --beats`) → `render.py --comp ThreeScene` (`seed`, `threeParticles`). WebGL renders with `--gl swangle` (software, no GPU needed); `--gl angle` on a machine with a GPU. `doctor.py --project` names the backend in use; another backend changes the pixels |
|
|
72
73
|
| "a video from just this music" / text or a visualizer with no footage | `analyze.py --blank SECONDS --size WxH [--fps N] [--music bgm.wav] [--beats]` (or `pipeline.py --blank ...`; through MCP, `input` is `["-"]`): a timeline with no footage, the music measured for peaks and beats as a source's audio is; any composition draws on the `background` option (default black). Length, size and rate are the caller's, so ask for them |
|
|
73
74
|
| "preview" / "show me a frame" | `still.py` |
|
|
74
75
|
| a new kind of graphic | add a composition to `src/` of the project that reads `Props` from `src/timeline.ts`; render with `--comp YourId` (render.py then reports measured numbers without a built-in expectation) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remotion-ffmpeg-skill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Agent Skill: ffmpeg-skill measures the footage, Remotion draws the motion graphics from those measurements, ffmpeg-skill checks and delivers the result. Timeline-driven captions, silence jump cuts and audio-peak motion with probe-first / verify-last rendering. Local, no API keys.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"remotion",
|
package/references/scripts.md
CHANGED
|
@@ -89,7 +89,7 @@ Render single frames as PNG to check the look before a full render.
|
|
|
89
89
|
| Argument | Type | Default | Meaning |
|
|
90
90
|
|---|---|---|---|
|
|
91
91
|
| `--project (required)` | string | | Remotion project folder made by init.py |
|
|
92
|
-
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, or yours) |
|
|
92
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, ThreeScene, or yours) |
|
|
93
93
|
| `--timeline (required)` | string | | timeline.json written by analyze.py |
|
|
94
94
|
| `--options` | string | | JSON object of look-and-feel options |
|
|
95
95
|
| `--at` | number, repeatable | | time in seconds (repeatable) |
|
|
@@ -100,6 +100,7 @@ Render single frames as PNG to check the look before a full render.
|
|
|
100
100
|
| `--fit` | string: blur / contain / cover | | how the source fills another shape: blur (default when the shape changes), contain (bars) or cover (crop) |
|
|
101
101
|
| `--font-file` | string | | caption font file (.ttf/.otf/.ttc/.woff2), staged into the project |
|
|
102
102
|
| `--brand` | string | | ffmpeg-skill brand.json: its colours, caption colour, font and font file set the look (an --options file still wins key by key) |
|
|
103
|
+
| `--gl` | string: angle / egl / swiftshader / swangle / vulkan / angle-egl | | Chromium's OpenGL backend for Remotion (default: swangle -- software WebGL, works without a GPU -- for ThreeScene, none for the other compositions: Chrome's choice; angle uses a GPU). Another backend changes the pixels; doctor.py names the one in use |
|
|
103
104
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
104
105
|
|
|
105
106
|
--json result (besides `status`, `dry_run`, `output`): `outputs` (list[str] (PNG paths)), `frames` (list[int]), `commands` (list[str]), `verified` (bool), `frame` (object|null {width, height, fit}), `font` (str|null)
|
|
@@ -120,7 +121,7 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
120
121
|
| Argument | Type | Default | Meaning |
|
|
121
122
|
|---|---|---|---|
|
|
122
123
|
| `--project (required)` | string | | Remotion project folder made by init.py |
|
|
123
|
-
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, or one you added) |
|
|
124
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, ThreeScene, or one you added) |
|
|
124
125
|
| `--timeline (required)` | string | | timeline.json written by analyze.py |
|
|
125
126
|
| `--options` | string | | JSON object of look-and-feel options (see references/timeline.md) |
|
|
126
127
|
| `--output` | string | | output file (default: <source>_<comp>.mp4, .mov for prores) |
|
|
@@ -139,6 +140,7 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
139
140
|
| `--fit` | string: blur / contain / cover | | how the source fills another shape: blur (default when the shape changes), contain (bars) or cover (crop) |
|
|
140
141
|
| `--font-file` | string | | caption font file (.ttf/.otf/.ttc/.woff2), staged into the project |
|
|
141
142
|
| `--brand` | string | | ffmpeg-skill brand.json: its colours, caption colour, font and font file set the look (an --options file still wins key by key) |
|
|
143
|
+
| `--gl` | string: angle / egl / swiftshader / swangle / vulkan / angle-egl | | Chromium's OpenGL backend for Remotion (default: swangle -- software WebGL, works without a GPU -- for ThreeScene, none for the other compositions: Chrome's choice; angle uses a GPU). Another backend changes the pixels; doctor.py names the one in use |
|
|
142
144
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
143
145
|
|
|
144
146
|
--json result (besides `status`, `dry_run`, `output`): `verified` (bool), `verification` (list[{check, status, value, expected}]), `commands` (list[str]), `look` (str|null (contact sheet PNG)), `look_error` (str|null), `summary` (str), `frame` (object|null), `font` (str|null), `mode` (full|overlay), `graphics` (str|null (kept ProRes 4444 layer)), `sparse` (null|{used, reason, stretches, drawn_frames, source_frames} (--sparse)), `kind` (null|failed), `error` (null|str (which verification rows failed))
|
|
@@ -185,7 +187,7 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
|
185
187
|
|---|---|---|---|
|
|
186
188
|
| `input` | string, repeatable | | source video; several are joined in order (ffmpeg-skill join.py) first (with --blank: none, or `-`) |
|
|
187
189
|
| `--project (required)` | string | | Remotion project folder made by init.py |
|
|
188
|
-
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, or yours) |
|
|
190
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, ThreeScene, or yours) |
|
|
189
191
|
| `--captions` | string | | SRT / WebVTT / JSON cues for the timeline |
|
|
190
192
|
| `--chapters` | string | | chapters (`TIME TITLE` per line, or `source`): cards in Titled and, with --platform, chapter markers in the deliverable |
|
|
191
193
|
| `--options` | string | | JSON options file passed to the composition |
|
|
@@ -237,6 +239,7 @@ Holds:
|
|
|
237
239
|
- analyze.py run twice on the same file writes a byte-identical timeline.json; on a copy at another path only source.path differs
|
|
238
240
|
- pipeline.py writes byte-identical render and deliverable files; it is content_equivalent, not bit_exact, because its timeline.json records the input's absolute path
|
|
239
241
|
- init.py (without --install) writes an identical project folder
|
|
242
|
+
- ThreeScene (WebGL through @remotion/three, render.py --gl swangle by default) renders twice to byte-identical files, --concurrency 1 included; the scene is a function of the frame and options.seed alone
|
|
240
243
|
|
|
241
244
|
Does not hold:
|
|
242
245
|
|
package/references/timeline.md
CHANGED
|
@@ -53,6 +53,7 @@ composition exactly.
|
|
|
53
53
|
| `Pip` | source duration | the source with `pip` (a camera) in a corner while the camera has pictures, synced by `pip.offset`; captions on top as in Captioned |
|
|
54
54
|
| `KineticType` | source duration | the `kinetic` schedule: each line centred, its units (words, or CJK characters) entering at their measured starts -- invisible before that frame, visible on it, never reflowing the line; `kineticStyle` pop, wipe, tracking or rise; `kineticReveal: "char"` lets a unit's characters follow each other `kineticStagger` s apart. The current unit takes the accent colour. Needs `analyze.py --kinetic` |
|
|
55
55
|
| `Visualizer` | source duration, or with `loopBars` a whole number of measured bars | the source's audio drawn each frame (`visualizer`: `bars`, `spectrum`, `radial` or `waveform`; @remotion/media-utils, a 1024-sample FFT centred on the frame's time, no smoothing across frames), a ring that hits on every measured beat, and the caption cues as Karaoke draws them (lyrics with `--words`). Over the source's picture, or over `background` on a `--blank` run. `loopBars`: a loop of that many bars of `beatsPerBar` measured beats (0 = as many as the beats hold) whose seam falls halfway between two beats -- from halfway between beats 0 and 1 to halfway between beats k and k+1 -- so its last frame runs into its first; refused when the beats cannot hold it |
|
|
56
|
+
| `ThreeScene` | source duration | a Three.js scene (@remotion/three) over the source (or `background`): seeded particles (`seed`, `threeParticles`) drifting round a centre shape that hits on every measured beat (measured peaks without a grid), the scene turning under a fixed camera. A function of the frame and `seed` only; rendered with `--gl swangle` unless `--gl` says otherwise |
|
|
56
57
|
| `BeatMontage` | source duration | audio unbroken; the picture cuts every `beatsPerCut` measured beats, cycling through highlights (or scenes); no usable grid → cuts on scene changes |
|
|
57
58
|
|
|
58
59
|
## Options (`--options look.json`)
|
|
@@ -90,6 +91,8 @@ Every key is optional.
|
|
|
90
91
|
| `visualizerBars` | `48` | Visualizer: bars (or points) drawn, 8–256 |
|
|
91
92
|
| `loopBars` | `null` | Visualizer: `null` = the whole source; `0` = a loop of as many whole measured bars as fit; `N` = N bars (needs `analyze.py --beats`) |
|
|
92
93
|
| `beatsPerBar` | `4` | Visualizer: measured beats per bar for `loopBars`, 1–16 |
|
|
94
|
+
| `seed` | `1` | ThreeScene: places the particles; same seed, same scene (0–4294967295) |
|
|
95
|
+
| `threeParticles` | `300` | ThreeScene: number of particles, 1–5000 |
|
|
93
96
|
| `chapterSeconds` | `4` | Titled: how long a chapter card stays up (cut short by the next chapter; 0 = none) |
|
|
94
97
|
|
|
95
98
|
Unknown keys and wrong types are refused by render.py / still.py before anything renders.
|
package/scripts/_common.py
CHANGED
|
@@ -369,7 +369,7 @@ def expected_frames(comp: str, t: Dict[str, Any], options: Optional[Dict[str, An
|
|
|
369
369
|
if loop:
|
|
370
370
|
return loop[1]
|
|
371
371
|
if comp in ("Captioned", "PeakPulse", "Titled", "BeatMontage", "Karaoke", "Pip", "Emphasis", "KineticType",
|
|
372
|
-
"Visualizer"):
|
|
372
|
+
"Visualizer", "ThreeScene"):
|
|
373
373
|
return max(1, sec_to_frames(float(t["source"]["duration"]), fps))
|
|
374
374
|
if comp in ("Jumpcut", "Highlights"):
|
|
375
375
|
if comp == "Jumpcut":
|
|
@@ -384,7 +384,7 @@ def expected_frames(comp: str, t: Dict[str, Any], options: Optional[Dict[str, An
|
|
|
384
384
|
# ---------------------------------------------------------------- Remotion project
|
|
385
385
|
|
|
386
386
|
BUILTIN_COMPOSITIONS = ("Captioned", "Jumpcut", "PeakPulse", "Titled", "Highlights", "BeatMontage", "Karaoke", "Pip",
|
|
387
|
-
"Emphasis", "KineticType", "Visualizer")
|
|
387
|
+
"Emphasis", "KineticType", "Visualizer", "ThreeScene")
|
|
388
388
|
|
|
389
389
|
|
|
390
390
|
def remotion_bin(project: Path) -> Path:
|
|
@@ -587,6 +587,17 @@ def write_props(project: Path, comp: str, timeline: Dict[str, Any], options: Dic
|
|
|
587
587
|
return path, props
|
|
588
588
|
|
|
589
589
|
|
|
590
|
+
# Chromium's OpenGL backends Remotion accepts (--gl). None = Remotion's own default (4.x: none passed, Chrome
|
|
591
|
+
# chooses), as render.py has always rendered the 2D compositions; WebGL compositions get GL_DEFAULTS.
|
|
592
|
+
GL_BACKENDS = ("angle", "egl", "swiftshader", "swangle", "vulkan", "angle-egl")
|
|
593
|
+
GL_DEFAULTS = {"ThreeScene": "swangle"}
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def gl_backend(comp: str, given: Optional[str]) -> Optional[str]:
|
|
597
|
+
"""The --gl a render or still of this composition passes to Remotion (None: none)."""
|
|
598
|
+
return given or GL_DEFAULTS.get(comp)
|
|
599
|
+
|
|
600
|
+
|
|
590
601
|
def add_frame_args(p: argparse.ArgumentParser) -> None:
|
|
591
602
|
g = p.add_argument_group("output frame and font")
|
|
592
603
|
g.add_argument("--aspect", choices=["source", *ASPECTS], default=None,
|
|
@@ -597,6 +608,10 @@ def add_frame_args(p: argparse.ArgumentParser) -> None:
|
|
|
597
608
|
g.add_argument("--font-file", help="caption font file (.ttf/.otf/.ttc/.woff2), staged into the project")
|
|
598
609
|
g.add_argument("--brand", help="ffmpeg-skill brand.json: its colours, caption colour, font and font file set "
|
|
599
610
|
"the look (an --options file still wins key by key)")
|
|
611
|
+
g.add_argument("--gl", choices=GL_BACKENDS,
|
|
612
|
+
help="Chromium's OpenGL backend for Remotion (default: swangle -- software WebGL, works without a "
|
|
613
|
+
"GPU -- for ThreeScene, none for the other compositions: Chrome's choice; angle uses a GPU). "
|
|
614
|
+
"Another backend changes the pixels; doctor.py names the one in use")
|
|
600
615
|
g.add_argument("--no-auto-font", action="store_true",
|
|
601
616
|
help="don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions")
|
|
602
617
|
|
|
@@ -712,6 +727,7 @@ _OPTION_TYPES: Dict[str, Any] = {
|
|
|
712
727
|
"emphasisStyle": str, "bubbles": list, "comments": list, "background": str,
|
|
713
728
|
"kineticStyle": str, "kineticReveal": str, "kineticStagger": (int, float), "kineticSize": (int, float),
|
|
714
729
|
"visualizer": str, "visualizerBars": int, "loopBars": (int, type(None)), "beatsPerBar": int,
|
|
730
|
+
"seed": int, "threeParticles": int,
|
|
715
731
|
}
|
|
716
732
|
|
|
717
733
|
|
|
@@ -763,6 +779,11 @@ def validate_options(o: Dict[str, Any]) -> List[str]:
|
|
|
763
779
|
p.append("loopBars must be 0 (as many whole bars as measured), a number of bars, or null")
|
|
764
780
|
if isinstance(o.get("beatsPerBar"), int) and not isinstance(o["beatsPerBar"], bool) and not 1 <= o["beatsPerBar"] <= 16:
|
|
765
781
|
p.append("beatsPerBar must be between 1 and 16")
|
|
782
|
+
if isinstance(o.get("seed"), int) and not isinstance(o["seed"], bool) and not 0 <= o["seed"] <= 2 ** 32 - 1:
|
|
783
|
+
p.append("seed must be a whole number from 0 to 4294967295")
|
|
784
|
+
if isinstance(o.get("threeParticles"), int) and not isinstance(o["threeParticles"], bool) \
|
|
785
|
+
and not 1 <= o["threeParticles"] <= 5000:
|
|
786
|
+
p.append("threeParticles must be between 1 and 5000")
|
|
766
787
|
if "emphasisStyle" in o and o["emphasisStyle"] not in ("pop", "color", "box"):
|
|
767
788
|
p.append("emphasisStyle must be pop, color or box")
|
|
768
789
|
for key, extra in (("bubbles", "side"), ("comments", "author")):
|
package/scripts/_contract.py
CHANGED
|
@@ -178,6 +178,8 @@ DETERMINISM = {
|
|
|
178
178
|
"pipeline.py writes byte-identical render and deliverable files; it is content_equivalent, not bit_exact, "
|
|
179
179
|
"because its timeline.json records the input's absolute path",
|
|
180
180
|
"init.py (without --install) writes an identical project folder",
|
|
181
|
+
"ThreeScene (WebGL through @remotion/three, render.py --gl swangle by default) renders twice to byte-identical "
|
|
182
|
+
"files, --concurrency 1 included; the scene is a function of the frame and options.seed alone",
|
|
181
183
|
],
|
|
182
184
|
"does_not_hold": [
|
|
183
185
|
"another Chromium build: chrome-headless-shell 153 and 156 differed on every frame (PSNR 43 dB average, "
|
package/scripts/doctor.py
CHANGED
|
@@ -16,7 +16,23 @@ import sys
|
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
|
|
18
18
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
19
|
-
|
|
19
|
+
import re
|
|
20
|
+
|
|
21
|
+
from _common import (GL_DEFAULTS, add_common, apply_common, emit, ffmpeg_skill_version, find_ffmpeg_skill, remotion_bin,
|
|
22
|
+
version)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def project_gl(proj: Path) -> str:
|
|
26
|
+
"""The GL backend renders in this project use, as doctor reports it: the remotion.config.ts override when
|
|
27
|
+
there is one (Config.setChromiumOpenGlRenderer), else render.py's --gl defaults."""
|
|
28
|
+
cfg = proj / "remotion.config.ts"
|
|
29
|
+
text = cfg.read_text(encoding="utf-8") if cfg.is_file() else ""
|
|
30
|
+
text = re.sub(r"//[^\n]*", "", text)
|
|
31
|
+
m = re.search(r"setChromiumOpenGlRenderer\(\s*['\"]([\w-]+)['\"]", text)
|
|
32
|
+
if m:
|
|
33
|
+
return f"{m.group(1)} (remotion.config.ts, every composition unless --gl is given)"
|
|
34
|
+
three = ", ".join(f"{c}: {b}" for c, b in GL_DEFAULTS.items())
|
|
35
|
+
return f"{three}; other compositions: none set (Chrome's choice); --gl overrides"
|
|
20
36
|
|
|
21
37
|
|
|
22
38
|
def _version(cmd):
|
|
@@ -71,6 +87,7 @@ def main() -> None:
|
|
|
71
87
|
rv = json.loads(pkg.read_text(encoding="utf-8")).get("version")
|
|
72
88
|
row("remotion project", rb.exists(), f"{proj} (remotion {rv})" if rv else str(proj),
|
|
73
89
|
f"cd {proj} && npm install")
|
|
90
|
+
row("gl backend", True, project_gl(proj))
|
|
74
91
|
|
|
75
92
|
ok = all(r["ok"] for r in rows)
|
|
76
93
|
lines = [f"{'ok ' if r['ok'] else 'NO '} {r['check']}: {r['value']}" + (f" -> {r['fix']}" if r["fix"] else "")
|
package/scripts/render.py
CHANGED
|
@@ -16,7 +16,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
|
|
16
16
|
|
|
17
17
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
18
18
|
import _sparse
|
|
19
|
-
from _common import (loop_range, BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit, expected_frames,
|
|
19
|
+
from _common import (gl_backend, loop_range, BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit, expected_frames,
|
|
20
20
|
ffskill, ffskill_cmd, frame_size, info, load_look, load_timeline, prepare_props, refuse_existing,
|
|
21
21
|
remotion_bin, require_ffmpeg_skill, require_project, remotion_error, run, shell_join)
|
|
22
22
|
|
|
@@ -79,6 +79,8 @@ def remotion_render_cmd(project: Path, comp: str, output: Path, props: Path, a:
|
|
|
79
79
|
cmd.append(f"--frames={a.frames}")
|
|
80
80
|
if a.concurrency:
|
|
81
81
|
cmd.append(f"--concurrency={a.concurrency}")
|
|
82
|
+
if gl_backend(comp, getattr(a, "gl", None)):
|
|
83
|
+
cmd.append(f"--gl={gl_backend(comp, a.gl)}")
|
|
82
84
|
return cmd
|
|
83
85
|
cmd = [str(remotion_bin(project)), "render", "src/index.ts", comp, str(output), f"--props={props}",
|
|
84
86
|
f"--codec={a.codec}", "--log=warn"]
|
|
@@ -94,6 +96,8 @@ def remotion_render_cmd(project: Path, comp: str, output: Path, props: Path, a:
|
|
|
94
96
|
cmd.append("--crf=28")
|
|
95
97
|
if a.concurrency:
|
|
96
98
|
cmd.append(f"--concurrency={a.concurrency}")
|
|
99
|
+
if gl_backend(comp, getattr(a, "gl", None)):
|
|
100
|
+
cmd.append(f"--gl={gl_backend(comp, a.gl)}")
|
|
97
101
|
return cmd
|
|
98
102
|
|
|
99
103
|
|
package/scripts/still.py
CHANGED
|
@@ -13,7 +13,7 @@ from pathlib import Path
|
|
|
13
13
|
from typing import List
|
|
14
14
|
|
|
15
15
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
16
|
-
from _common import (BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit,
|
|
16
|
+
from _common import (gl_backend, BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit,
|
|
17
17
|
expected_frames, info, load_look, load_timeline, prepare_props, refuse_existing, remotion_bin,
|
|
18
18
|
require_project, remotion_error, run, sec_to_frames, shell_join)
|
|
19
19
|
|
|
@@ -64,6 +64,8 @@ def main() -> None:
|
|
|
64
64
|
refuse_existing(out)
|
|
65
65
|
cmd = [str(remotion_bin(project)), "still", "src/index.ts", a.comp, str(out),
|
|
66
66
|
f"--props={props_path}", f"--frame={f}", "--log=warn"]
|
|
67
|
+
if gl_backend(a.comp, a.gl):
|
|
68
|
+
cmd.append(f"--gl={gl_backend(a.comp, a.gl)}")
|
|
67
69
|
commands.append(shell_join(cmd))
|
|
68
70
|
if STATE.dry_run:
|
|
69
71
|
outputs.append(str(out))
|
|
@@ -10,12 +10,16 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@remotion/cli": "4.0.540",
|
|
12
12
|
"@remotion/media-utils": "4.0.540",
|
|
13
|
+
"@remotion/three": "4.0.540",
|
|
14
|
+
"@react-three/fiber": "9.8.2",
|
|
13
15
|
"remotion": "4.0.540",
|
|
14
16
|
"react": "19.3.1",
|
|
15
|
-
"react-dom": "19.3.1"
|
|
17
|
+
"react-dom": "19.3.1",
|
|
18
|
+
"three": "0.186.1"
|
|
16
19
|
},
|
|
17
20
|
"devDependencies": {
|
|
18
21
|
"@types/react": "^19.0.0",
|
|
22
|
+
"@types/three": "0.186.0",
|
|
19
23
|
"typescript": "^7.0.2"
|
|
20
24
|
}
|
|
21
25
|
}
|
|
@@ -11,6 +11,7 @@ import { Pip } from "./compositions/Pip";
|
|
|
11
11
|
import { Emphasis } from "./compositions/Emphasis";
|
|
12
12
|
import { KineticType } from "./compositions/KineticType";
|
|
13
13
|
import { Visualizer } from "./compositions/Visualizer";
|
|
14
|
+
import { ThreeScene } from "./compositions/ThreeScene";
|
|
14
15
|
import {
|
|
15
16
|
SAMPLE_TIMELINE,
|
|
16
17
|
fullLengthFrames,
|
|
@@ -55,5 +56,6 @@ export const RemotionRoot: React.FC = () => (
|
|
|
55
56
|
<Composition id="Emphasis" component={Emphasis} {...base} calculateMetadata={metadataFrom(fullLengthFrames)} />
|
|
56
57
|
<Composition id="KineticType" component={KineticType} {...base} calculateMetadata={metadataFrom(fullLengthFrames)} />
|
|
57
58
|
<Composition id="Visualizer" component={Visualizer} {...base} calculateMetadata={visualizerMetadata} />
|
|
59
|
+
<Composition id="ThreeScene" component={ThreeScene} {...base} calculateMetadata={metadataFrom(fullLengthFrames)} />
|
|
58
60
|
</>
|
|
59
61
|
);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";
|
|
3
|
+
import { ThreeCanvas } from "@remotion/three";
|
|
4
|
+
import { SourceVideo } from "../lib/SourceVideo";
|
|
5
|
+
import { Props, beatTimes, outputFrame, resolveOptions, secToFrames } from "../timeline";
|
|
6
|
+
|
|
7
|
+
/** mulberry32: a small seeded generator, so the same seed always places the same particles. */
|
|
8
|
+
const seeded = (seed: number) => {
|
|
9
|
+
let a = seed >>> 0;
|
|
10
|
+
return () => {
|
|
11
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
12
|
+
let t = a;
|
|
13
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
14
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
15
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ThreeScene: a Three.js scene (@remotion/three) over the source, a function of the frame number and
|
|
21
|
+
* options.seed alone -- no clock, no requestAnimationFrame, no Math.random -- so the same frame gives the same
|
|
22
|
+
* pixels on one machine and GL backend (render.py --gl; doctor.py names it). A field of seeded particles drifts
|
|
23
|
+
* round a centre shape while the camera orbits; the shape hits on every measured beat (or measured audio peak
|
|
24
|
+
* when no beat grid was measured), with the same decay PeakPulse uses.
|
|
25
|
+
*/
|
|
26
|
+
export const ThreeScene: React.FC<Props> = (props) => {
|
|
27
|
+
const { timeline, options, overlay } = props;
|
|
28
|
+
const o = resolveOptions(options);
|
|
29
|
+
const frame = useCurrentFrame();
|
|
30
|
+
const { fps, width, height } = useVideoConfig();
|
|
31
|
+
const beats = beatTimes(timeline);
|
|
32
|
+
const maxRms = Math.max(1e-6, ...timeline.peaks.map((p) => p.rms));
|
|
33
|
+
const events = beats.length > 0 ? beats.map((t) => ({ t, s: 1 })) : timeline.peaks.map((p) => ({ t: p.time, s: p.rms / maxRms }));
|
|
34
|
+
let hit = 0;
|
|
35
|
+
for (const ev of events) {
|
|
36
|
+
const f = secToFrames(ev.t, fps);
|
|
37
|
+
if (f > frame) continue;
|
|
38
|
+
hit = Math.max(hit, ev.s * Math.exp(-(frame - f) / (fps * 0.15)));
|
|
39
|
+
}
|
|
40
|
+
const count = Math.max(1, Math.min(5000, Math.round(o.threeParticles)));
|
|
41
|
+
const particles = useMemo(() => {
|
|
42
|
+
const rnd = seeded(o.seed);
|
|
43
|
+
return Array.from({ length: count }, () => {
|
|
44
|
+
const r = 2.2 + rnd() * 4;
|
|
45
|
+
const theta = rnd() * Math.PI * 2;
|
|
46
|
+
const y = (rnd() - 0.5) * 4;
|
|
47
|
+
return { r, theta, y, speed: 0.2 + rnd() * 0.6, size: 0.02 + rnd() * 0.05 };
|
|
48
|
+
});
|
|
49
|
+
}, [o.seed, count]);
|
|
50
|
+
const t = frame / fps;
|
|
51
|
+
const cam = 0.25 * t;
|
|
52
|
+
return (
|
|
53
|
+
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
54
|
+
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
55
|
+
<ThreeCanvas
|
|
56
|
+
width={width}
|
|
57
|
+
height={height}
|
|
58
|
+
gl={{ antialias: true, alpha: true, preserveDrawingBuffer: true }}
|
|
59
|
+
camera={{ fov: 50, near: 0.1, far: 100, position: [0, 0, 9] }}
|
|
60
|
+
style={{ position: "absolute", inset: 0 }}
|
|
61
|
+
>
|
|
62
|
+
<ambientLight intensity={0.5} />
|
|
63
|
+
<directionalLight position={[4, 6, 5]} intensity={1.6} />
|
|
64
|
+
{/* the "orbit": the scene turns under a fixed camera, a function of the frame */}
|
|
65
|
+
<group rotation={[0.25, -cam, 0]}>
|
|
66
|
+
<mesh rotation={[t * 0.6, t * 0.9, 0]} scale={1 + 0.35 * hit}>
|
|
67
|
+
<icosahedronGeometry args={[1.3, 1]} />
|
|
68
|
+
<meshStandardMaterial color={o.accent} emissive={o.accent} emissiveIntensity={0.15 + 0.85 * hit} flatShading />
|
|
69
|
+
</mesh>
|
|
70
|
+
{particles.map((p, i) => {
|
|
71
|
+
const a = p.theta + t * p.speed * 0.5;
|
|
72
|
+
return (
|
|
73
|
+
<mesh key={i} position={[Math.cos(a) * p.r, p.y + Math.sin(t * p.speed + i) * 0.15, Math.sin(a) * p.r]}>
|
|
74
|
+
<sphereGeometry args={[p.size * (1 + hit), 8, 8]} />
|
|
75
|
+
<meshBasicMaterial color={o.textColor} />
|
|
76
|
+
</mesh>
|
|
77
|
+
);
|
|
78
|
+
})}
|
|
79
|
+
</group>
|
|
80
|
+
</ThreeCanvas>
|
|
81
|
+
</AbsoluteFill>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
@@ -173,6 +173,10 @@ export type Options = {
|
|
|
173
173
|
loopBars: number | null;
|
|
174
174
|
/** Visualizer: measured beats per bar (4 for 4/4). */
|
|
175
175
|
beatsPerBar: number;
|
|
176
|
+
/** ThreeScene: the seed that places the particles (same seed, same scene). */
|
|
177
|
+
seed: number;
|
|
178
|
+
/** ThreeScene: number of particles, 1..5000. */
|
|
179
|
+
threeParticles: number;
|
|
176
180
|
};
|
|
177
181
|
|
|
178
182
|
export const DEFAULT_OPTIONS: Options = {
|
|
@@ -206,6 +210,8 @@ export const DEFAULT_OPTIONS: Options = {
|
|
|
206
210
|
visualizerBars: 48,
|
|
207
211
|
loopBars: null,
|
|
208
212
|
beatsPerBar: 4,
|
|
213
|
+
seed: 1,
|
|
214
|
+
threeParticles: 300,
|
|
209
215
|
};
|
|
210
216
|
|
|
211
217
|
/** Where the camera plays on the source timeline: [from, durationInFrames, trimBefore] in frames. */
|