remotion-ffmpeg-skill 0.17.0 → 0.19.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 +3 -0
- package/package.json +1 -1
- package/references/scripts.md +12 -5
- package/references/timeline.md +30 -0
- package/scripts/_common.py +41 -6
- package/scripts/_contract.py +5 -1
- package/scripts/_looks.py +93 -0
- package/scripts/doctor.py +18 -1
- package/scripts/pipeline.py +5 -2
- package/scripts/render.py +93 -4
- 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/Captioned.tsx +3 -3
- package/templates/remotion-project/src/compositions/Emphasis.tsx +5 -4
- package/templates/remotion-project/src/compositions/Karaoke.tsx +3 -3
- package/templates/remotion-project/src/compositions/KineticType.tsx +2 -2
- package/templates/remotion-project/src/compositions/ThreeScene.tsx +83 -0
- package/templates/remotion-project/src/compositions/Titled.tsx +4 -4
- package/templates/remotion-project/src/timeline.ts +17 -0
package/SKILL.md
CHANGED
|
@@ -69,6 +69,9 @@ 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 |
|
|
73
|
+
| "make it look swiss / minimal / neon / glitch / corporate" (or `wafu`, a Japanese look) | `--style NAME` on render / still / pipeline: an options bundle; `--brand` wins over it key by key, `--options` over both |
|
|
74
|
+
| "give me each graphic as its own layer" / "for After Effects" | `render.py --layers` (Captioned, Karaoke, Titled, Emphasis, KineticType): the composite plus one transparent ProRes 4444 per group (captions, lower thirds, bubbles, ...) and `<output>.layers.json` (times, position, stacking order). Stacked over the source in that order they give the composite back |
|
|
72
75
|
| "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
76
|
| "preview" / "show me a frame" | `still.py` |
|
|
74
77
|
| 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.19.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) |
|
|
@@ -99,7 +99,9 @@ Render single frames as PNG to check the look before a full render.
|
|
|
99
99
|
| `--width` | integer | | output width in px (default: keep the source's short side) |
|
|
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
|
+
| `--style` | string: swiss / minimal / neon / glitch / wafu / corporate | | a look in one word: an options bundle (colours, font, background, sizes, the kinetic and visualizer styles). --brand wins over it key by key, and --options over both |
|
|
102
103
|
| `--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) |
|
|
104
|
+
| `--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
105
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
104
106
|
|
|
105
107
|
--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 +122,7 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
120
122
|
| Argument | Type | Default | Meaning |
|
|
121
123
|
|---|---|---|---|
|
|
122
124
|
| `--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) |
|
|
125
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, ThreeScene, or one you added) |
|
|
124
126
|
| `--timeline (required)` | string | | timeline.json written by analyze.py |
|
|
125
127
|
| `--options` | string | | JSON object of look-and-feel options (see references/timeline.md) |
|
|
126
128
|
| `--output` | string | | output file (default: <source>_<comp>.mp4, .mov for prores) |
|
|
@@ -132,18 +134,21 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
132
134
|
| `--no-look` | boolean | | skip the contact sheet |
|
|
133
135
|
| `--overlay` | boolean | | draw the graphics only as a transparent ProRes 4444 layer and composite it over the untouched source with ffmpeg-skill overlay.py (Captioned / PeakPulse, source frame only); with --keep-graphics the layer is kept for an editing app (Premiere, Resolve, Final Cut) |
|
|
134
136
|
| `--keep-graphics` | boolean | | with --overlay: keep the transparent graphics .mov |
|
|
137
|
+
| `--layers` | boolean | | also write each graphic group (captions, lower thirds, bubbles, ...) as its own transparent ProRes 4444 .mov, full frame, in <output>.layers/, with a manifest <output>.layers.json (the times each shows, its position and stacking order) beside the composite, for After Effects or an NLE (Captioned, Karaoke, Titled, Emphasis, KineticType) |
|
|
135
138
|
| `--sparse` | boolean | | overlay mode that draws only the frames where something shows (Captioned / Karaoke / Titled) and places each stretch at its time with ffmpeg-skill overlay.py --place: much faster on long footage with gaps between captions. Falls back to the full-length layer (and says why) when this ffmpeg-skill has no --place or the source does not start at 0 |
|
|
136
139
|
| `--merge-gap` | number | `2.0` | with --sparse: graphics closer than this many seconds are drawn as one stretch (default 2) |
|
|
137
140
|
| `--aspect` | string: source / 16:9 / 9:16 / 1:1 / 4:5 / 4:3 | | output shape (default: the source's own). 9:16 for Reels/TikTok/Shorts, 1:1, 4:5, 16:9 |
|
|
138
141
|
| `--width` | integer | | output width in px (default: keep the source's short side) |
|
|
139
142
|
| `--fit` | string: blur / contain / cover | | how the source fills another shape: blur (default when the shape changes), contain (bars) or cover (crop) |
|
|
140
143
|
| `--font-file` | string | | caption font file (.ttf/.otf/.ttc/.woff2), staged into the project |
|
|
144
|
+
| `--style` | string: swiss / minimal / neon / glitch / wafu / corporate | | a look in one word: an options bundle (colours, font, background, sizes, the kinetic and visualizer styles). --brand wins over it key by key, and --options over both |
|
|
141
145
|
| `--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) |
|
|
146
|
+
| `--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
147
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
143
148
|
|
|
144
|
-
--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))
|
|
149
|
+
--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)), `layers` (null|{manifest, files} (--layers: the layers@1 manifest and the ProRes 4444 files)), `kind` (null|failed), `error` (null|str (which verification rows failed))
|
|
145
150
|
|
|
146
|
-
--dry-run --json result (besides `status`, `dry_run`, `output`): `commands` (list[str]), `props` (str), `expected_frames` (int|null), `frame` (object|null), `font` (str|null), `sparse` (null|object (--sparse))
|
|
151
|
+
--dry-run --json result (besides `status`, `dry_run`, `output`): `commands` (list[str]), `props` (str), `expected_frames` (int|null), `frame` (object|null), `font` (str|null), `sparse` (null|object (--sparse)), `layers` (null|list[str] (--layers: the groups that would be written))
|
|
147
152
|
|
|
148
153
|
## deliver.py
|
|
149
154
|
|
|
@@ -185,11 +190,12 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
|
185
190
|
|---|---|---|---|
|
|
186
191
|
| `input` | string, repeatable | | source video; several are joined in order (ffmpeg-skill join.py) first (with --blank: none, or `-`) |
|
|
187
192
|
| `--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) |
|
|
193
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, Visualizer, ThreeScene, or yours) |
|
|
189
194
|
| `--captions` | string | | SRT / WebVTT / JSON cues for the timeline |
|
|
190
195
|
| `--chapters` | string | | chapters (`TIME TITLE` per line, or `source`): cards in Titled and, with --platform, chapter markers in the deliverable |
|
|
191
196
|
| `--options` | string | | JSON options file passed to the composition |
|
|
192
197
|
| `--brand` | string | | ffmpeg-skill brand.json: the look of the graphics and, on delivery, the logo |
|
|
198
|
+
| `--style` | string: swiss / minimal / neon / glitch / wafu / corporate | | a look in one word (render.py --style): --brand and --options win over it key by key |
|
|
193
199
|
| `--platform` | string: youtube / youtube-shorts / shorts / reels / tiktok / x / facebook / linkedin / podcast / audiogram | | deliver with this ffmpeg-skill template and check it |
|
|
194
200
|
| `--out-dir` | string | | where the timeline, render and deliverable go (default: next to the input) |
|
|
195
201
|
| `--beats` | boolean | | measure the beat grid too |
|
|
@@ -237,6 +243,7 @@ Holds:
|
|
|
237
243
|
- 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
244
|
- 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
245
|
- init.py (without --install) writes an identical project folder
|
|
246
|
+
- 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
247
|
|
|
241
248
|
Does not hold:
|
|
242
249
|
|
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,9 @@ 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 |
|
|
96
|
+
| `captionBox` | `null` | Captioned / Karaoke / Emphasis: the caption box colour (any CSS colour); `null` = their dark box |
|
|
93
97
|
| `chapterSeconds` | `4` | Titled: how long a chapter card stays up (cut short by the next chapter; 0 = none) |
|
|
94
98
|
|
|
95
99
|
Unknown keys and wrong types are refused by render.py / still.py before anything renders.
|
|
@@ -125,3 +129,29 @@ Example:
|
|
|
125
129
|
2. Register it in `src/Root.tsx` with a `calculateMetadata` that derives length from the timeline.
|
|
126
130
|
3. `render.py --comp YourId ...` — the output is still probed and contact-sheeted; the frame
|
|
127
131
|
count check is replaced by an INFO row because the skill cannot know your length rule.
|
|
132
|
+
|
|
133
|
+
## Style presets (`--style`)
|
|
134
|
+
|
|
135
|
+
`render.py`, `still.py` and `pipeline.py --style NAME` start from a bundle of the options above (`scripts/_looks.py`). A `--brand` file wins over it key by key, and an `--options` file wins over both.
|
|
136
|
+
|
|
137
|
+
| Style | Look |
|
|
138
|
+
|---|---|
|
|
139
|
+
| `swiss` | red accent, near-black text on off-white, a grotesk, light caption box; kinetic `wipe` per unit; bars |
|
|
140
|
+
| `minimal` | white on near-black, small captions, a gentle pulse, no progress bar; kinetic `rise` per unit; waveform |
|
|
141
|
+
| `neon` | pink accent, cyan text on a deep blue radial gradient, a strong pulse; kinetic `pop`; radial |
|
|
142
|
+
| `glitch` | acid green accent on black, monospaced, a harder punch-in; kinetic `tracking`, fast stagger; spectrum |
|
|
143
|
+
| `wafu` | vermilion accent, ink text on washi, a mincho face, light caption box; kinetic `rise` per character (Japanese look; opt-in) |
|
|
144
|
+
| `corporate` | blue accent, white on navy, a plain sans, a calm pulse; kinetic `rise` per unit; bars |
|
|
145
|
+
|
|
146
|
+
## Layers (`render.py --layers`, schema `remotion-ffmpeg-skill/layers@1`)
|
|
147
|
+
|
|
148
|
+
Besides the composite, each graphic group is drawn alone on a transparent, full frame. Each group goes to its own ProRes 4444 file (`<output>.layers/NN_<group>.mov`). The groups are Captioned and Karaoke `captions`; Titled `sceneTitles`, `chapters`, `lowerThirds`; Emphasis `captions`, `bubbles`, `comments`; KineticType `text`. A manifest `<output>.layers.json` sits beside the composite:
|
|
149
|
+
|
|
150
|
+
| Key | Meaning |
|
|
151
|
+
|---|---|
|
|
152
|
+
| `composition`, `composite`, `fps`, `width`, `height`, `frames`, `duration` | the composite the layers belong to |
|
|
153
|
+
| `base` | what the layers go over: `source` (the video, or null), `background` (a blank's or audio-only source's background colour), `fit` |
|
|
154
|
+
| `layers[]` | bottom first: `group`, `order`, `file` (null when nothing of the group shows; then `skipped` says so), `position` (`{x, y, width, height}`: full frame at 0,0), `times` (`[{start, end, from_frame, end_frame}]`, where the group draws), `codec`, `pix_fmt`, `frames` |
|
|
155
|
+
|
|
156
|
+
Every layer is checked against the composite (ffmpeg-skill probe: frame count, size, a pixel format with alpha). Stacked over the base in order, the layers give back the composite. The fixture measures at least 40 dB PSNR on every frame (`test_integration.StylesAndLayers`).
|
|
157
|
+
|
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:
|
|
@@ -569,7 +569,7 @@ def resolve_font(project: Path, timeline: Dict[str, Any], font_file: Optional[st
|
|
|
569
569
|
|
|
570
570
|
def write_props(project: Path, comp: str, timeline: Dict[str, Any], options: Dict[str, Any],
|
|
571
571
|
frame: Optional[Dict[str, Any]] = None, font: Optional[Dict[str, str]] = None,
|
|
572
|
-
overlay: bool = False) -> Tuple[Path, Dict[str, Any]]:
|
|
572
|
+
overlay: bool = False, layer: Optional[str] = None) -> Tuple[Path, Dict[str, Any]]:
|
|
573
573
|
t = json.loads(json.dumps(timeline))
|
|
574
574
|
src = t["source"].get("path")
|
|
575
575
|
has_media = t["source"].get("has_video", True) or t["source"].get("has_audio", False)
|
|
@@ -577,6 +577,8 @@ def write_props(project: Path, comp: str, timeline: Dict[str, Any], options: Dic
|
|
|
577
577
|
if t.get("pip") and comp == "Pip":
|
|
578
578
|
t["pip"]["src"] = stage_source(project, t["pip"]["path"])
|
|
579
579
|
props = {"timeline": t, "options": options, "frame": frame, "font": font, "overlay": overlay}
|
|
580
|
+
if layer is not None:
|
|
581
|
+
props["layer"] = layer # render.py --layers: this graphic group only
|
|
580
582
|
# Named by content: two renders running at once (different sources, shapes or options) never
|
|
581
583
|
# overwrite each other's props, and identical props share one file harmlessly.
|
|
582
584
|
digest = hashlib.sha1(json.dumps(props, sort_keys=True, ensure_ascii=False).encode("utf-8")).hexdigest()[:10]
|
|
@@ -587,6 +589,21 @@ def write_props(project: Path, comp: str, timeline: Dict[str, Any], options: Dic
|
|
|
587
589
|
return path, props
|
|
588
590
|
|
|
589
591
|
|
|
592
|
+
# The --style presets (scripts/_looks.py STYLES holds their options).
|
|
593
|
+
STYLE_NAMES = ("swiss", "minimal", "neon", "glitch", "wafu", "corporate")
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
# Chromium's OpenGL backends Remotion accepts (--gl). None = Remotion's own default (4.x: none passed, Chrome
|
|
597
|
+
# chooses), as render.py has always rendered the 2D compositions; WebGL compositions get GL_DEFAULTS.
|
|
598
|
+
GL_BACKENDS = ("angle", "egl", "swiftshader", "swangle", "vulkan", "angle-egl")
|
|
599
|
+
GL_DEFAULTS = {"ThreeScene": "swangle"}
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def gl_backend(comp: str, given: Optional[str]) -> Optional[str]:
|
|
603
|
+
"""The --gl a render or still of this composition passes to Remotion (None: none)."""
|
|
604
|
+
return given or GL_DEFAULTS.get(comp)
|
|
605
|
+
|
|
606
|
+
|
|
590
607
|
def add_frame_args(p: argparse.ArgumentParser) -> None:
|
|
591
608
|
g = p.add_argument_group("output frame and font")
|
|
592
609
|
g.add_argument("--aspect", choices=["source", *ASPECTS], default=None,
|
|
@@ -595,8 +612,15 @@ def add_frame_args(p: argparse.ArgumentParser) -> None:
|
|
|
595
612
|
g.add_argument("--fit", choices=FITS, help="how the source fills another shape: blur (default when the shape "
|
|
596
613
|
"changes), contain (bars) or cover (crop)")
|
|
597
614
|
g.add_argument("--font-file", help="caption font file (.ttf/.otf/.ttc/.woff2), staged into the project")
|
|
615
|
+
g.add_argument("--style", choices=STYLE_NAMES,
|
|
616
|
+
help="a look in one word: an options bundle (colours, font, background, sizes, the kinetic and "
|
|
617
|
+
"visualizer styles). --brand wins over it key by key, and --options over both")
|
|
598
618
|
g.add_argument("--brand", help="ffmpeg-skill brand.json: its colours, caption colour, font and font file set "
|
|
599
619
|
"the look (an --options file still wins key by key)")
|
|
620
|
+
g.add_argument("--gl", choices=GL_BACKENDS,
|
|
621
|
+
help="Chromium's OpenGL backend for Remotion (default: swangle -- software WebGL, works without a "
|
|
622
|
+
"GPU -- for ThreeScene, none for the other compositions: Chrome's choice; angle uses a GPU). "
|
|
623
|
+
"Another backend changes the pixels; doctor.py names the one in use")
|
|
600
624
|
g.add_argument("--no-auto-font", action="store_true",
|
|
601
625
|
help="don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions")
|
|
602
626
|
|
|
@@ -672,16 +696,21 @@ def brand_look(path: str) -> Tuple[Dict[str, Any], Optional[str], List[str]]:
|
|
|
672
696
|
|
|
673
697
|
|
|
674
698
|
def load_look(a: argparse.Namespace) -> Dict[str, Any]:
|
|
675
|
-
"""Options for render.py / still.py: the brand file's look, then --options over
|
|
699
|
+
"""Options for render.py / still.py: the --style preset, the brand file's look over it, then --options over
|
|
700
|
+
both, key by key."""
|
|
676
701
|
options = load_options(a.options)
|
|
702
|
+
style: Dict[str, Any] = {}
|
|
703
|
+
if getattr(a, "style", None):
|
|
704
|
+
from _looks import STYLES
|
|
705
|
+
style = dict(STYLES[a.style])
|
|
677
706
|
if not getattr(a, "brand", None):
|
|
678
|
-
return options
|
|
707
|
+
return {**style, **options}
|
|
679
708
|
b, font_file, notes = brand_look(a.brand)
|
|
680
709
|
for n in notes:
|
|
681
710
|
info(n)
|
|
682
711
|
if font_file and not a.font_file:
|
|
683
712
|
a.font_file = font_file
|
|
684
|
-
return {**b, **options}
|
|
713
|
+
return {**style, **b, **options}
|
|
685
714
|
|
|
686
715
|
|
|
687
716
|
def load_options(path: Optional[str]) -> Dict[str, Any]:
|
|
@@ -712,6 +741,7 @@ _OPTION_TYPES: Dict[str, Any] = {
|
|
|
712
741
|
"emphasisStyle": str, "bubbles": list, "comments": list, "background": str,
|
|
713
742
|
"kineticStyle": str, "kineticReveal": str, "kineticStagger": (int, float), "kineticSize": (int, float),
|
|
714
743
|
"visualizer": str, "visualizerBars": int, "loopBars": (int, type(None)), "beatsPerBar": int,
|
|
744
|
+
"seed": int, "threeParticles": int, "captionBox": (str, type(None)),
|
|
715
745
|
}
|
|
716
746
|
|
|
717
747
|
|
|
@@ -763,6 +793,11 @@ def validate_options(o: Dict[str, Any]) -> List[str]:
|
|
|
763
793
|
p.append("loopBars must be 0 (as many whole bars as measured), a number of bars, or null")
|
|
764
794
|
if isinstance(o.get("beatsPerBar"), int) and not isinstance(o["beatsPerBar"], bool) and not 1 <= o["beatsPerBar"] <= 16:
|
|
765
795
|
p.append("beatsPerBar must be between 1 and 16")
|
|
796
|
+
if isinstance(o.get("seed"), int) and not isinstance(o["seed"], bool) and not 0 <= o["seed"] <= 2 ** 32 - 1:
|
|
797
|
+
p.append("seed must be a whole number from 0 to 4294967295")
|
|
798
|
+
if isinstance(o.get("threeParticles"), int) and not isinstance(o["threeParticles"], bool) \
|
|
799
|
+
and not 1 <= o["threeParticles"] <= 5000:
|
|
800
|
+
p.append("threeParticles must be between 1 and 5000")
|
|
766
801
|
if "emphasisStyle" in o and o["emphasisStyle"] not in ("pop", "color", "box"):
|
|
767
802
|
p.append("emphasisStyle must be pop, color or box")
|
|
768
803
|
for key, extra in (("bubbles", "side"), ("comments", "author")):
|
package/scripts/_contract.py
CHANGED
|
@@ -135,10 +135,12 @@ OUTPUTS: Dict[str, Dict[str, Dict[str, str]]] = {
|
|
|
135
135
|
"summary": "str", "frame": "object|null", "font": "str|null", "mode": "full|overlay",
|
|
136
136
|
"graphics": "str|null (kept ProRes 4444 layer)",
|
|
137
137
|
"sparse": "null|{used, reason, stretches, drawn_frames, source_frames} (--sparse)",
|
|
138
|
+
"layers": "null|{manifest, files} (--layers: the layers@1 manifest and the ProRes 4444 files)",
|
|
138
139
|
"kind": "null|failed",
|
|
139
140
|
"error": "null|str (which verification rows failed)"},
|
|
140
141
|
"dry_run": {"commands": "list[str]", "props": "str", "expected_frames": "int|null", "frame": "object|null",
|
|
141
|
-
"font": "str|null", "sparse": "null|object (--sparse)"
|
|
142
|
+
"font": "str|null", "sparse": "null|object (--sparse)",
|
|
143
|
+
"layers": "null|list[str] (--layers: the groups that would be written)"},
|
|
142
144
|
},
|
|
143
145
|
"deliver": {
|
|
144
146
|
"result": {"checked": "str", "platform": "str|null", "verified": "bool",
|
|
@@ -178,6 +180,8 @@ DETERMINISM = {
|
|
|
178
180
|
"pipeline.py writes byte-identical render and deliverable files; it is content_equivalent, not bit_exact, "
|
|
179
181
|
"because its timeline.json records the input's absolute path",
|
|
180
182
|
"init.py (without --install) writes an identical project folder",
|
|
183
|
+
"ThreeScene (WebGL through @remotion/three, render.py --gl swangle by default) renders twice to byte-identical "
|
|
184
|
+
"files, --concurrency 1 included; the scene is a function of the frame and options.seed alone",
|
|
181
185
|
],
|
|
182
186
|
"does_not_hold": [
|
|
183
187
|
"another Chromium build: chrome-headless-shell 153 and 156 differed on every frame (PSNR 43 dB average, "
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Style presets and graphic layers (internal module, not a tool).
|
|
3
|
+
|
|
4
|
+
* STYLES: `--style NAME` on render.py / still.py / pipeline.py is a bundle of ordinary options (the keys of
|
|
5
|
+
`--options`, references/timeline.md). The order is style, then the brand kit (`--brand`), then the `--options`
|
|
6
|
+
file, each winning key by key over the one before -- a brand's colours and font always beat a style's.
|
|
7
|
+
* LAYER_GROUPS: what render.py --layers writes as separate transparent ProRes 4444 files, one per graphic group
|
|
8
|
+
of a composition (each composition draws only `props.layer` when it is set), and the frames each group shows
|
|
9
|
+
in, for the manifest. The composition files carry the same group names (a test checks they agree).
|
|
10
|
+
"""
|
|
11
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
12
|
+
|
|
13
|
+
from _common import sec_to_frames
|
|
14
|
+
from _sparse import CHAPTER_SECONDS, SCENE_CARD_SECONDS
|
|
15
|
+
|
|
16
|
+
_SANS = "'Noto Sans', 'Helvetica Neue', Arial, 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif"
|
|
17
|
+
_GROTESK = "'Helvetica Neue', Helvetica, Arial, 'Noto Sans', 'Noto Sans JP', 'Hiragino Sans', sans-serif"
|
|
18
|
+
_MINCHO = "'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif CJK JP', 'Noto Serif', serif"
|
|
19
|
+
_MONO = "'JetBrains Mono', 'Noto Sans Mono', Menlo, Consolas, 'Noto Sans JP', monospace"
|
|
20
|
+
|
|
21
|
+
STYLES: Dict[str, Dict[str, Any]] = {
|
|
22
|
+
# red on white, a grotesk, flush and plain
|
|
23
|
+
"swiss": {"accent": "#E30613", "textColor": "#111111", "background": "#F4F4F0", "fontFamily": _GROTESK,
|
|
24
|
+
"captionBox": "rgba(255,255,255,0.92)",
|
|
25
|
+
"captionSize": 0.05, "kineticStyle": "wipe", "kineticReveal": "unit", "visualizer": "bars"},
|
|
26
|
+
# white on near-black, small and quiet
|
|
27
|
+
"minimal": {"accent": "#FFFFFF", "textColor": "#E8E8E8", "background": "#101010", "fontFamily": _SANS,
|
|
28
|
+
"captionSize": 0.045, "pulse": 0.3, "progressBar": False, "kineticStyle": "rise",
|
|
29
|
+
"kineticReveal": "unit", "visualizer": "waveform"},
|
|
30
|
+
# glowing pink and cyan on deep blue
|
|
31
|
+
"neon": {"accent": "#FF2BD6", "textColor": "#7DF9FF", "background": "radial-gradient(circle, #1A0B3D 0%, #05010F 75%)",
|
|
32
|
+
"fontFamily": _SANS, "pulse": 0.9, "kineticStyle": "pop", "visualizer": "radial"},
|
|
33
|
+
# acid green on black, monospaced, hard cuts
|
|
34
|
+
"glitch": {"accent": "#00FF66", "textColor": "#F2F2F2", "background": "#000000", "fontFamily": _MONO,
|
|
35
|
+
"kineticStyle": "tracking", "kineticStagger": 0.02, "visualizer": "spectrum", "punchIn": 1.2},
|
|
36
|
+
# vermilion and sumi ink on washi (Japanese, opt-in): a mincho face
|
|
37
|
+
"wafu": {"accent": "#C73E3A", "textColor": "#2B2B2B", "background": "#F3EEDF", "fontFamily": _MINCHO,
|
|
38
|
+
"captionBox": "rgba(251,248,240,0.92)",
|
|
39
|
+
"captionSize": 0.052, "kineticStyle": "rise", "kineticReveal": "char", "kineticStagger": 0.06,
|
|
40
|
+
"visualizer": "bars"},
|
|
41
|
+
# navy and a calm blue, a plain sans
|
|
42
|
+
"corporate": {"accent": "#2F6FDE", "textColor": "#FFFFFF", "background": "#0B1F3A", "fontFamily": _SANS,
|
|
43
|
+
"captionSize": 0.05, "pulse": 0.4, "kineticStyle": "rise", "kineticReveal": "unit",
|
|
44
|
+
"visualizer": "bars"},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# The graphic groups of each composition --layers can split (the order is the stacking order, bottom first).
|
|
48
|
+
LAYER_GROUPS: Dict[str, Tuple[str, ...]] = {
|
|
49
|
+
"Captioned": ("captions",),
|
|
50
|
+
"Karaoke": ("captions",),
|
|
51
|
+
"Titled": ("sceneTitles", "chapters", "lowerThirds"),
|
|
52
|
+
"Emphasis": ("captions", "bubbles", "comments"),
|
|
53
|
+
"KineticType": ("text",),
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _span(start: float, end: float, fps: float) -> Tuple[int, int]:
|
|
58
|
+
s = sec_to_frames(start, fps)
|
|
59
|
+
return s, s + max(1, sec_to_frames(end, fps) - s)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def group_intervals(comp: str, group: str, timeline: Dict[str, Any],
|
|
63
|
+
options: Optional[Dict[str, Any]] = None) -> List[Tuple[int, int]]:
|
|
64
|
+
"""[from, end) frames in which `group` of `comp` draws anything (the Sequences of that group)."""
|
|
65
|
+
fps = float(timeline["source"]["fps"])
|
|
66
|
+
o = options or {}
|
|
67
|
+
out: List[Tuple[int, int]] = []
|
|
68
|
+
if group == "captions":
|
|
69
|
+
out = [_span(c["start"], c["end"], fps) for c in timeline.get("captions") or []]
|
|
70
|
+
elif group == "text":
|
|
71
|
+
out = [(sec_to_frames(ln["start"], fps), sec_to_frames(ln["end"], fps))
|
|
72
|
+
for ln in (timeline.get("kinetic") or {}).get("lines") or []]
|
|
73
|
+
elif group == "sceneTitles":
|
|
74
|
+
titles = o.get("sceneTitles") or []
|
|
75
|
+
for i, sc in enumerate(timeline.get("scenes") or []):
|
|
76
|
+
if i < len(titles) and titles[i]:
|
|
77
|
+
s = sec_to_frames(sc["start"], fps)
|
|
78
|
+
out.append((s, s + max(1, min(sec_to_frames(sc["end"], fps), s + sec_to_frames(SCENE_CARD_SECONDS, fps))
|
|
79
|
+
- s)))
|
|
80
|
+
elif group == "chapters":
|
|
81
|
+
seconds = float(o.get("chapterSeconds", CHAPTER_SECONDS))
|
|
82
|
+
for ch in (timeline.get("chapters") or []) if seconds > 0 else []:
|
|
83
|
+
s = sec_to_frames(ch["start"], fps)
|
|
84
|
+
out.append((s, s + max(1, min(sec_to_frames(ch["end"], fps), s + sec_to_frames(seconds, fps)) - s)))
|
|
85
|
+
elif group in ("lowerThirds", "bubbles", "comments"):
|
|
86
|
+
out = [_span(x["start"], x["end"], fps) for x in o.get(group) or []]
|
|
87
|
+
merged: List[List[int]] = []
|
|
88
|
+
for s, e in sorted(x for x in out if x[1] > x[0]):
|
|
89
|
+
if merged and s <= merged[-1][1]:
|
|
90
|
+
merged[-1][1] = max(merged[-1][1], e)
|
|
91
|
+
else:
|
|
92
|
+
merged.append([s, e])
|
|
93
|
+
return [(s, e) for s, e in merged]
|
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/pipeline.py
CHANGED
|
@@ -18,7 +18,7 @@ from typing import Any, Dict, List
|
|
|
18
18
|
|
|
19
19
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
20
20
|
from _common import (ASPECTS, BUILTIN_COMPOSITIONS, FITS, HERE, STATE, add_common, apply_common, die, emit, info,
|
|
21
|
-
platform_aspect, shell_join, parse_with_blank)
|
|
21
|
+
platform_aspect, shell_join, parse_with_blank, STYLE_NAMES)
|
|
22
22
|
from deliver import PLATFORMS
|
|
23
23
|
|
|
24
24
|
|
|
@@ -35,6 +35,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
35
35
|
"markers in the deliverable")
|
|
36
36
|
p.add_argument("--options", help="JSON options file passed to the composition")
|
|
37
37
|
p.add_argument("--brand", help="ffmpeg-skill brand.json: the look of the graphics and, on delivery, the logo")
|
|
38
|
+
p.add_argument("--style", choices=STYLE_NAMES,
|
|
39
|
+
help="a look in one word (render.py --style): --brand and --options win over it key by key")
|
|
38
40
|
p.add_argument("--platform", choices=PLATFORMS, help="deliver with this ffmpeg-skill template and check it")
|
|
39
41
|
p.add_argument("--out-dir", help="where the timeline, render and deliverable go (default: next to the input)")
|
|
40
42
|
p.add_argument("--beats", action="store_true", help="measure the beat grid too")
|
|
@@ -132,7 +134,8 @@ def main() -> None:
|
|
|
132
134
|
aspect = a.aspect or platform_aspect(a.platform)
|
|
133
135
|
if aspect:
|
|
134
136
|
r_args += ["--aspect", aspect]
|
|
135
|
-
for flag, val in (("--width", a.width), ("--fit", a.fit), ("--font-file", a.font_file), ("--brand", a.brand)
|
|
137
|
+
for flag, val in (("--width", a.width), ("--fit", a.fit), ("--font-file", a.font_file), ("--brand", a.brand),
|
|
138
|
+
("--style", a.style)):
|
|
136
139
|
if val is not None:
|
|
137
140
|
r_args += [flag, str(val)]
|
|
138
141
|
rendered = step("draw", "render", r_args, steps)
|
package/scripts/render.py
CHANGED
|
@@ -16,9 +16,11 @@ 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
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
from _looks import LAYER_GROUPS, group_intervals
|
|
20
|
+
from _common import (BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit, expected_frames,
|
|
21
|
+
ffskill, ffskill_cmd, frame_size, gl_backend, info, load_look, load_timeline, loop_range,
|
|
22
|
+
prepare_props, refuse_existing, remotion_bin, remotion_error, require_ffmpeg_skill,
|
|
23
|
+
require_project, resolve_font, run, shell_join, write_props)
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
def build_parser() -> argparse.ArgumentParser:
|
|
@@ -44,6 +46,11 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
44
46
|
"untouched source with ffmpeg-skill overlay.py (Captioned / PeakPulse, source frame only); "
|
|
45
47
|
"with --keep-graphics the layer is kept for an editing app (Premiere, Resolve, Final Cut)")
|
|
46
48
|
p.add_argument("--keep-graphics", action="store_true", help="with --overlay: keep the transparent graphics .mov")
|
|
49
|
+
p.add_argument("--layers", action="store_true",
|
|
50
|
+
help="also write each graphic group (captions, lower thirds, bubbles, ...) as its own transparent "
|
|
51
|
+
"ProRes 4444 .mov, full frame, in <output>.layers/, with a manifest <output>.layers.json "
|
|
52
|
+
"(the times each shows, its position and stacking order) beside the composite, for After "
|
|
53
|
+
"Effects or an NLE (Captioned, Karaoke, Titled, Emphasis, KineticType)")
|
|
47
54
|
p.add_argument("--sparse", action="store_true",
|
|
48
55
|
help="overlay mode that draws only the frames where something shows (Captioned / Karaoke / "
|
|
49
56
|
"Titled) and "
|
|
@@ -79,6 +86,8 @@ def remotion_render_cmd(project: Path, comp: str, output: Path, props: Path, a:
|
|
|
79
86
|
cmd.append(f"--frames={a.frames}")
|
|
80
87
|
if a.concurrency:
|
|
81
88
|
cmd.append(f"--concurrency={a.concurrency}")
|
|
89
|
+
if gl_backend(comp, getattr(a, "gl", None)):
|
|
90
|
+
cmd.append(f"--gl={gl_backend(comp, a.gl)}")
|
|
82
91
|
return cmd
|
|
83
92
|
cmd = [str(remotion_bin(project)), "render", "src/index.ts", comp, str(output), f"--props={props}",
|
|
84
93
|
f"--codec={a.codec}", "--log=warn"]
|
|
@@ -94,6 +103,8 @@ def remotion_render_cmd(project: Path, comp: str, output: Path, props: Path, a:
|
|
|
94
103
|
cmd.append("--crf=28")
|
|
95
104
|
if a.concurrency:
|
|
96
105
|
cmd.append(f"--concurrency={a.concurrency}")
|
|
106
|
+
if gl_backend(comp, getattr(a, "gl", None)):
|
|
107
|
+
cmd.append(f"--gl={gl_backend(comp, a.gl)}")
|
|
97
108
|
return cmd
|
|
98
109
|
|
|
99
110
|
|
|
@@ -182,6 +193,74 @@ def sparse_plan(timeline: Dict[str, Any], options: Dict[str, Any], a: argparse.N
|
|
|
182
193
|
return plan
|
|
183
194
|
|
|
184
195
|
|
|
196
|
+
LAYERS_SCHEMA = "remotion-ffmpeg-skill/layers@1"
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def render_layers(project: Path, timeline: Dict[str, Any], options: Dict[str, Any], frame: Optional[Dict[str, Any]],
|
|
200
|
+
a: argparse.Namespace, composite: Path, commands: List[str]) -> Dict[str, Any]:
|
|
201
|
+
"""--layers: each graphic group of the composition drawn alone on a transparent full frame (ProRes 4444), checked
|
|
202
|
+
with ffmpeg-skill probe (frame count, size, an alpha pixel format), and a manifest beside the composite. A group
|
|
203
|
+
that shows nothing in this timeline gets no file (listed with its reason)."""
|
|
204
|
+
import json
|
|
205
|
+
fps = float(timeline["source"]["fps"])
|
|
206
|
+
total = expected_frames(a.comp, timeline, options) or 1
|
|
207
|
+
fw, fh = frame_size(timeline, frame)
|
|
208
|
+
folder = composite.with_name(composite.stem + ".layers")
|
|
209
|
+
manifest_path = composite.with_name(composite.stem + ".layers.json")
|
|
210
|
+
refuse_existing(manifest_path)
|
|
211
|
+
folder.mkdir(parents=True, exist_ok=True)
|
|
212
|
+
font, _ = resolve_font(project, timeline, a.font_file, not a.no_auto_font)
|
|
213
|
+
layer_args = argparse.Namespace(**{**vars(a), "overlay": True})
|
|
214
|
+
entries: List[Dict[str, Any]] = []
|
|
215
|
+
for order, group in enumerate(LAYER_GROUPS[a.comp]):
|
|
216
|
+
spans = group_intervals(a.comp, group, timeline, options)
|
|
217
|
+
entry: Dict[str, Any] = {"group": group, "order": order, "file": None,
|
|
218
|
+
"position": {"x": 0, "y": 0, "width": fw, "height": fh},
|
|
219
|
+
"times": [{"start": round(s / fps, 3), "end": round(e / fps, 3),
|
|
220
|
+
"from_frame": s, "end_frame": e} for s, e in spans]}
|
|
221
|
+
if not spans:
|
|
222
|
+
entry["skipped"] = "nothing of this group shows in this timeline"
|
|
223
|
+
entries.append(entry)
|
|
224
|
+
continue
|
|
225
|
+
out = folder / f"{order:02d}_{group}.mov"
|
|
226
|
+
refuse_existing(out)
|
|
227
|
+
props, _ = write_props(project, a.comp, timeline, options, frame, font, overlay=True, layer=group)
|
|
228
|
+
cmd = remotion_render_cmd(project, a.comp, out, props, layer_args)
|
|
229
|
+
info(f"rendering layer {group} -> {out}")
|
|
230
|
+
proc = run(cmd, cwd=project)
|
|
231
|
+
if proc.returncode != 0 or not out.is_file():
|
|
232
|
+
tail = remotion_error((proc.stderr or "") + "\n" + (proc.stdout or ""))
|
|
233
|
+
die(f"Remotion render of layer {group} failed (exit {proc.returncode}):\n{tail}", "failed",
|
|
234
|
+
command=shell_join(cmd))
|
|
235
|
+
commands.append(shell_join(cmd))
|
|
236
|
+
pr = ffskill("probe", [str(out)])
|
|
237
|
+
commands.append(pr["_command"])
|
|
238
|
+
lv = pr.get("video") or {}
|
|
239
|
+
problems = []
|
|
240
|
+
if lv.get("nb_frames") not in (None, total):
|
|
241
|
+
problems.append(f"{lv.get('nb_frames')} frames, the composite has {total}")
|
|
242
|
+
if (lv.get("width"), lv.get("height")) != (fw, fh):
|
|
243
|
+
problems.append(f"{lv.get('width')}x{lv.get('height')}, the composite is {fw}x{fh}")
|
|
244
|
+
if "a" not in str(lv.get("pix_fmt") or ""):
|
|
245
|
+
problems.append(f"pixel format {lv.get('pix_fmt')} has no alpha")
|
|
246
|
+
if problems:
|
|
247
|
+
die(f"layer {group} ({out.name}) does not match the composite: {'; '.join(problems)}", "failed")
|
|
248
|
+
entry.update(file=str(out), codec="prores 4444", pix_fmt=lv.get("pix_fmt"), frames=total)
|
|
249
|
+
entries.append(entry)
|
|
250
|
+
src = timeline["source"]
|
|
251
|
+
manifest = {
|
|
252
|
+
"schema": LAYERS_SCHEMA, "composition": a.comp, "composite": str(composite), "fps": fps,
|
|
253
|
+
"width": fw, "height": fh, "frames": total, "duration": round(total / fps, 3),
|
|
254
|
+
# what the layers go over, bottom first: the source picture (or the blank's background), then each layer
|
|
255
|
+
"base": {"source": src.get("path") if src.get("has_video") else None,
|
|
256
|
+
"background": options.get("background", "#000000") if src.get("blank") or not src.get("has_video")
|
|
257
|
+
else None, "fit": (frame or {}).get("fit", "contain")},
|
|
258
|
+
"layers": entries,
|
|
259
|
+
}
|
|
260
|
+
manifest_path.write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
261
|
+
return {"manifest": str(manifest_path), "files": [e["file"] for e in entries if e["file"]]}
|
|
262
|
+
|
|
263
|
+
|
|
185
264
|
def main() -> None:
|
|
186
265
|
a = build_parser().parse_args()
|
|
187
266
|
apply_common(a)
|
|
@@ -229,6 +308,13 @@ def main() -> None:
|
|
|
229
308
|
if not timeline["source"].get("has_video"):
|
|
230
309
|
die("--overlay needs a video source to composite onto", "input")
|
|
231
310
|
|
|
311
|
+
if a.layers:
|
|
312
|
+
if a.comp not in LAYER_GROUPS:
|
|
313
|
+
die(f"--layers splits the graphic groups of {', '.join(LAYER_GROUPS)}; {a.comp} has none of its own",
|
|
314
|
+
"input")
|
|
315
|
+
if a.overlay or a.fast or frames:
|
|
316
|
+
die("--layers writes the full composite and full-size layers: drop --overlay / --sparse / --fast / "
|
|
317
|
+
"--frames", "input")
|
|
232
318
|
sparse = sparse_plan(timeline, options, a) if a.sparse else None
|
|
233
319
|
used = bool(sparse and sparse["used"])
|
|
234
320
|
props_path, frame, font_note = prepare_props(project, a.comp, sparse["timeline"] if used else timeline,
|
|
@@ -247,7 +333,8 @@ def main() -> None:
|
|
|
247
333
|
plan = [shell_join(cmd)] + ([shell_join(ffskill_cmd("overlay", ov_args))] if a.overlay else [])
|
|
248
334
|
emit({"output": str(output), "commands": plan, "props": str(props_path),
|
|
249
335
|
"expected_frames": (frames[1] - frames[0] + 1) if frames else expected_frames(a.comp, timeline, options),
|
|
250
|
-
"frame": frame, "font": font_note, "sparse": sparse_note
|
|
336
|
+
"frame": frame, "font": font_note, "sparse": sparse_note,
|
|
337
|
+
"layers": [g for g in LAYER_GROUPS[a.comp]] if a.layers else None},
|
|
251
338
|
f"would render {a.comp} -> {output}")
|
|
252
339
|
return
|
|
253
340
|
|
|
@@ -292,6 +379,7 @@ def main() -> None:
|
|
|
292
379
|
look_error += (" -- this FFmpeg build has no drawtext filter. macOS Homebrew: `brew install ffmpeg-full` "
|
|
293
380
|
"(the plain ffmpeg formula dropped it); use still.py frames to look meanwhile")
|
|
294
381
|
info(f"warning: contact sheet failed ({look_error}); view the render itself")
|
|
382
|
+
layers = render_layers(project, timeline, options, frame, a, output, commands) if a.layers and ok else None
|
|
295
383
|
v = probe.get("video") or {}
|
|
296
384
|
summary = (f"{output.name}: {float(probe.get('duration') or 0):.2f} s, {v.get('width')}x{v.get('height')}, "
|
|
297
385
|
f"{v.get('fps')} fps, {'audio' if probe.get('audio') else 'no audio'}")
|
|
@@ -299,6 +387,7 @@ def main() -> None:
|
|
|
299
387
|
"verification": rows, "commands": commands, "look": look, "summary": summary,
|
|
300
388
|
"frame": frame, "font": font_note, "mode": "overlay" if a.overlay else "full", "look_error": look_error,
|
|
301
389
|
"graphics": str(graphics) if a.overlay and a.keep_graphics else None, "sparse": sparse_note,
|
|
390
|
+
"layers": layers,
|
|
302
391
|
"kind": None if ok else "failed",
|
|
303
392
|
"error": None if ok else "verification failed: " + ", ".join(r["check"] for r in rows if r["status"] == "FAIL")}
|
|
304
393
|
table = "\n".join(f" {r['check']:<9} {r['status']:<4} {r['value']} (expected {r['expected']})" for r in rows)
|
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
|
);
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { AbsoluteFill, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig } from "remotion";
|
|
3
3
|
import { SourceVideo } from "../lib/SourceVideo";
|
|
4
4
|
import { useStagedFont } from "../lib/useStagedFont";
|
|
5
|
-
import { Props, fontStack, outputFrame, resolveOptions, secToFrames, type Options } from "../timeline";
|
|
5
|
+
import { Props, showLayer, fontStack, outputFrame, resolveOptions, secToFrames, type Options } from "../timeline";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Captioned: the source, full length, with each measured caption cue popping in on its own
|
|
@@ -17,7 +17,7 @@ export const Captioned: React.FC<Props> = (props) => {
|
|
|
17
17
|
return (
|
|
18
18
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
19
19
|
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
20
|
-
{timeline.captions.map((c, i) => {
|
|
20
|
+
{(showLayer(props, "captions") ? timeline.captions : []).map((c, i) => {
|
|
21
21
|
const from = secToFrames(c.start, fps);
|
|
22
22
|
const dur = Math.max(1, secToFrames(c.end, fps) - from);
|
|
23
23
|
return (
|
|
@@ -70,7 +70,7 @@ export const CaptionCard: React.FC<{ text: string; durationInFrames: number; o:
|
|
|
70
70
|
maxWidth: width * 0.86,
|
|
71
71
|
padding: `${size * 0.28}px ${size * 0.6}px`,
|
|
72
72
|
borderRadius: size * 0.35,
|
|
73
|
-
background: "rgba(0,0,0,0.62)",
|
|
73
|
+
background: o.captionBox ?? "rgba(0,0,0,0.62)",
|
|
74
74
|
borderBottom: `${Math.max(2, Math.round(size * 0.08))}px solid ${o.accent}`,
|
|
75
75
|
color: o.textColor,
|
|
76
76
|
fontFamily,
|
|
@@ -5,6 +5,7 @@ import { useStagedFont } from "../lib/useStagedFont";
|
|
|
5
5
|
import { captionMarginPx } from "./Captioned";
|
|
6
6
|
import {
|
|
7
7
|
Props,
|
|
8
|
+
showLayer,
|
|
8
9
|
fontStack,
|
|
9
10
|
outputFrame,
|
|
10
11
|
resolveOptions,
|
|
@@ -40,7 +41,7 @@ export const Emphasis: React.FC<Props> = (props) => {
|
|
|
40
41
|
return (
|
|
41
42
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
42
43
|
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
43
|
-
{timeline.captions.map((c, i) => {
|
|
44
|
+
{(showLayer(props, "captions") ? timeline.captions : []).map((c, i) => {
|
|
44
45
|
const from = secToFrames(c.start, fps);
|
|
45
46
|
const dur = Math.max(1, secToFrames(c.end, fps) - from);
|
|
46
47
|
return (
|
|
@@ -56,7 +57,7 @@ export const Emphasis: React.FC<Props> = (props) => {
|
|
|
56
57
|
</Sequence>
|
|
57
58
|
);
|
|
58
59
|
})}
|
|
59
|
-
{o.bubbles.map((b, i) => {
|
|
60
|
+
{(showLayer(props, "bubbles") ? o.bubbles : []).map((b, i) => {
|
|
60
61
|
const from = secToFrames(b.start, fps);
|
|
61
62
|
const dur = Math.max(1, secToFrames(b.end, fps) - from);
|
|
62
63
|
return (
|
|
@@ -65,7 +66,7 @@ export const Emphasis: React.FC<Props> = (props) => {
|
|
|
65
66
|
</Sequence>
|
|
66
67
|
);
|
|
67
68
|
})}
|
|
68
|
-
{o.comments.map((c, i) => {
|
|
69
|
+
{(showLayer(props, "comments") ? o.comments : []).map((c, i) => {
|
|
69
70
|
const from = secToFrames(c.start, fps);
|
|
70
71
|
const dur = Math.max(1, secToFrames(c.end, fps) - from);
|
|
71
72
|
const slot = slots[i];
|
|
@@ -126,7 +127,7 @@ const EmphasisCue: React.FC<{
|
|
|
126
127
|
maxWidth: width * 0.88,
|
|
127
128
|
padding: `${size * 0.25}px ${size * 0.55}px`,
|
|
128
129
|
borderRadius: size * 0.3,
|
|
129
|
-
background: "rgba(0,0,0,0.6)",
|
|
130
|
+
background: o.captionBox ?? "rgba(0,0,0,0.6)",
|
|
130
131
|
color: o.textColor,
|
|
131
132
|
fontFamily,
|
|
132
133
|
fontWeight: 800,
|
|
@@ -3,7 +3,7 @@ import { AbsoluteFill, Sequence, interpolate, spring, useCurrentFrame, useVideoC
|
|
|
3
3
|
import { SourceVideo } from "../lib/SourceVideo";
|
|
4
4
|
import { useStagedFont } from "../lib/useStagedFont";
|
|
5
5
|
import { captionMarginPx } from "./Captioned";
|
|
6
|
-
import { Props, fontStack, outputFrame, resolveOptions, secToFrames, type Caption, type Options } from "../timeline";
|
|
6
|
+
import { Props, showLayer, fontStack, outputFrame, resolveOptions, secToFrames, type Caption, type Options } from "../timeline";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Karaoke: each caption cue with its words lit one by one at the times the speech engine measured
|
|
@@ -20,7 +20,7 @@ export const Karaoke: React.FC<Props> = (props) => {
|
|
|
20
20
|
return (
|
|
21
21
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
22
22
|
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
23
|
-
{timeline.captions.map((c, i) => {
|
|
23
|
+
{(showLayer(props, "captions") ? timeline.captions : []).map((c, i) => {
|
|
24
24
|
const from = secToFrames(c.start, fps);
|
|
25
25
|
const dur = Math.max(1, secToFrames(c.end, fps) - from);
|
|
26
26
|
// Words that belong to this cue: their midpoint falls inside it.
|
|
@@ -60,7 +60,7 @@ export const KaraokeCue: React.FC<{ cue: Caption; words: Caption[]; len: number;
|
|
|
60
60
|
maxWidth: width * 0.88,
|
|
61
61
|
padding: `${size * 0.25}px ${size * 0.55}px`,
|
|
62
62
|
borderRadius: size * 0.3,
|
|
63
|
-
background: "rgba(0,0,0,0.6)",
|
|
63
|
+
background: o.captionBox ?? "rgba(0,0,0,0.6)",
|
|
64
64
|
fontFamily,
|
|
65
65
|
fontWeight: 800,
|
|
66
66
|
fontSize: size,
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { AbsoluteFill, interpolate, useCurrentFrame, useVideoConfig } from "remotion";
|
|
3
3
|
import { SourceVideo } from "../lib/SourceVideo";
|
|
4
4
|
import { useStagedFont } from "../lib/useStagedFont";
|
|
5
|
-
import { Props, fontStack, outputFrame, resolveOptions, secToFrames, type KineticLine, type Options } from "../timeline";
|
|
5
|
+
import { Props, showLayer, fontStack, outputFrame, resolveOptions, secToFrames, type KineticLine, type Options } from "../timeline";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* KineticType: the caption cues' words (or CJK characters) entering one by one at the times analyze.py
|
|
@@ -24,7 +24,7 @@ export const KineticType: React.FC<Props> = (props) => {
|
|
|
24
24
|
return (
|
|
25
25
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
26
26
|
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
27
|
-
{line ? <Line line={line} o={o} fontFamily={family} /> : null}
|
|
27
|
+
{line && showLayer(props, "text") ? <Line line={line} o={o} fontFamily={family} /> : null}
|
|
28
28
|
</AbsoluteFill>
|
|
29
29
|
);
|
|
30
30
|
};
|
|
@@ -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
|
+
};
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { AbsoluteFill, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig } from "remotion";
|
|
3
3
|
import { SourceVideo } from "../lib/SourceVideo";
|
|
4
4
|
import { useStagedFont } from "../lib/useStagedFont";
|
|
5
|
-
import { Props, chapterCardFrames, fontStack, outputFrame, resolveOptions, secToFrames, type Options } from "../timeline";
|
|
5
|
+
import { Props, showLayer, chapterCardFrames, fontStack, outputFrame, resolveOptions, secToFrames, type Options } from "../timeline";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Titled: the source, full length, with lower thirds the user wrote (options.lowerThirds), a
|
|
@@ -22,7 +22,7 @@ export const Titled: React.FC<Props> = (props) => {
|
|
|
22
22
|
return (
|
|
23
23
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
24
24
|
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
25
|
-
{sceneCards.map(({ sc, text }, i) => {
|
|
25
|
+
{(showLayer(props, "sceneTitles") ? sceneCards : []).map(({ sc, text }, i) => {
|
|
26
26
|
const from = secToFrames(sc.start, fps);
|
|
27
27
|
const dur = Math.max(1, Math.min(secToFrames(sc.end, fps), from + Math.round(fps * 2.5)) - from);
|
|
28
28
|
return (
|
|
@@ -31,7 +31,7 @@ export const Titled: React.FC<Props> = (props) => {
|
|
|
31
31
|
</Sequence>
|
|
32
32
|
);
|
|
33
33
|
})}
|
|
34
|
-
{o.chapterSeconds > 0
|
|
34
|
+
{o.chapterSeconds > 0 && showLayer(props, "chapters")
|
|
35
35
|
? (timeline.chapters ?? []).map((ch, i, all) => {
|
|
36
36
|
const [from, dur] = chapterCardFrames(ch, fps, o.chapterSeconds);
|
|
37
37
|
return (
|
|
@@ -41,7 +41,7 @@ export const Titled: React.FC<Props> = (props) => {
|
|
|
41
41
|
);
|
|
42
42
|
})
|
|
43
43
|
: null}
|
|
44
|
-
{o.lowerThirds.map((lt, i) => {
|
|
44
|
+
{(showLayer(props, "lowerThirds") ? o.lowerThirds : []).map((lt, i) => {
|
|
45
45
|
const from = secToFrames(lt.start, fps);
|
|
46
46
|
const dur = Math.max(1, secToFrames(lt.end, fps) - from);
|
|
47
47
|
return (
|
|
@@ -173,6 +173,12 @@ export type Options = {
|
|
|
173
173
|
loopBars: number | null;
|
|
174
174
|
/** Visualizer: measured beats per bar (4 for 4/4). */
|
|
175
175
|
beatsPerBar: number;
|
|
176
|
+
/** Captioned / Karaoke / Emphasis: the caption box colour (CSS); null = the dark box each draws by default. */
|
|
177
|
+
captionBox: string | null;
|
|
178
|
+
/** ThreeScene: the seed that places the particles (same seed, same scene). */
|
|
179
|
+
seed: number;
|
|
180
|
+
/** ThreeScene: number of particles, 1..5000. */
|
|
181
|
+
threeParticles: number;
|
|
176
182
|
};
|
|
177
183
|
|
|
178
184
|
export const DEFAULT_OPTIONS: Options = {
|
|
@@ -206,6 +212,9 @@ export const DEFAULT_OPTIONS: Options = {
|
|
|
206
212
|
visualizerBars: 48,
|
|
207
213
|
loopBars: null,
|
|
208
214
|
beatsPerBar: 4,
|
|
215
|
+
captionBox: null,
|
|
216
|
+
seed: 1,
|
|
217
|
+
threeParticles: 300,
|
|
209
218
|
};
|
|
210
219
|
|
|
211
220
|
/** Where the camera plays on the source timeline: [from, durationInFrames, trimBefore] in frames. */
|
|
@@ -243,8 +252,16 @@ export type Props = {
|
|
|
243
252
|
* ffmpeg-skill composites the result over it afterwards -- much faster on long footage.
|
|
244
253
|
*/
|
|
245
254
|
overlay?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* One graphic group only (render.py --layers): the composition draws just this group, e.g. "captions" or
|
|
257
|
+
* "lowerThirds", so each group becomes its own transparent layer. null / absent = every group.
|
|
258
|
+
*/
|
|
259
|
+
layer?: string | null;
|
|
246
260
|
};
|
|
247
261
|
|
|
262
|
+
/** Whether this group is drawn (every group unless render.py --layers asked for one). */
|
|
263
|
+
export const showLayer = (p: Props, group: string): boolean => !p.layer || p.layer === group;
|
|
264
|
+
|
|
248
265
|
export const resolveOptions = (o?: Partial<Options>): Options => ({ ...DEFAULT_OPTIONS, ...(o ?? {}) });
|
|
249
266
|
|
|
250
267
|
export const outputFrame = (p: Props): Frame =>
|