remotion-ffmpeg-skill 0.18.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 +2 -0
- package/package.json +1 -1
- package/references/scripts.md +6 -2
- package/references/timeline.md +27 -0
- package/scripts/_common.py +19 -5
- package/scripts/_contract.py +3 -1
- package/scripts/_looks.py +93 -0
- package/scripts/pipeline.py +5 -2
- package/scripts/render.py +89 -4
- 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/Titled.tsx +4 -4
- package/templates/remotion-project/src/timeline.ts +11 -0
package/SKILL.md
CHANGED
|
@@ -70,6 +70,8 @@ Moving text has three owners: word-timed caption effects are this skill's, anima
|
|
|
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
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 |
|
|
73
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 |
|
|
74
76
|
| "preview" / "show me a frame" | `still.py` |
|
|
75
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
|
@@ -99,6 +99,7 @@ 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) |
|
|
103
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 |
|
|
104
105
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
@@ -133,19 +134,21 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
133
134
|
| `--no-look` | boolean | | skip the contact sheet |
|
|
134
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) |
|
|
135
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) |
|
|
136
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 |
|
|
137
139
|
| `--merge-gap` | number | `2.0` | with --sparse: graphics closer than this many seconds are drawn as one stretch (default 2) |
|
|
138
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 |
|
|
139
141
|
| `--width` | integer | | output width in px (default: keep the source's short side) |
|
|
140
142
|
| `--fit` | string: blur / contain / cover | | how the source fills another shape: blur (default when the shape changes), contain (bars) or cover (crop) |
|
|
141
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 |
|
|
142
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) |
|
|
143
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 |
|
|
144
147
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
145
148
|
|
|
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))
|
|
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))
|
|
147
150
|
|
|
148
|
-
--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))
|
|
149
152
|
|
|
150
153
|
## deliver.py
|
|
151
154
|
|
|
@@ -192,6 +195,7 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
|
192
195
|
| `--chapters` | string | | chapters (`TIME TITLE` per line, or `source`): cards in Titled and, with --platform, chapter markers in the deliverable |
|
|
193
196
|
| `--options` | string | | JSON options file passed to the composition |
|
|
194
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 |
|
|
195
199
|
| `--platform` | string: youtube / youtube-shorts / shorts / reels / tiktok / x / facebook / linkedin / podcast / audiogram | | deliver with this ffmpeg-skill template and check it |
|
|
196
200
|
| `--out-dir` | string | | where the timeline, render and deliverable go (default: next to the input) |
|
|
197
201
|
| `--beats` | boolean | | measure the beat grid too |
|
package/references/timeline.md
CHANGED
|
@@ -93,6 +93,7 @@ Every key is optional.
|
|
|
93
93
|
| `beatsPerBar` | `4` | Visualizer: measured beats per bar for `loopBars`, 1–16 |
|
|
94
94
|
| `seed` | `1` | ThreeScene: places the particles; same seed, same scene (0–4294967295) |
|
|
95
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 |
|
|
96
97
|
| `chapterSeconds` | `4` | Titled: how long a chapter card stays up (cut short by the next chapter; 0 = none) |
|
|
97
98
|
|
|
98
99
|
Unknown keys and wrong types are refused by render.py / still.py before anything renders.
|
|
@@ -128,3 +129,29 @@ Example:
|
|
|
128
129
|
2. Register it in `src/Root.tsx` with a `calculateMetadata` that derives length from the timeline.
|
|
129
130
|
3. `render.py --comp YourId ...` — the output is still probed and contact-sheeted; the frame
|
|
130
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
|
@@ -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,10 @@ 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
|
+
|
|
590
596
|
# Chromium's OpenGL backends Remotion accepts (--gl). None = Remotion's own default (4.x: none passed, Chrome
|
|
591
597
|
# chooses), as render.py has always rendered the 2D compositions; WebGL compositions get GL_DEFAULTS.
|
|
592
598
|
GL_BACKENDS = ("angle", "egl", "swiftshader", "swangle", "vulkan", "angle-egl")
|
|
@@ -606,6 +612,9 @@ def add_frame_args(p: argparse.ArgumentParser) -> None:
|
|
|
606
612
|
g.add_argument("--fit", choices=FITS, help="how the source fills another shape: blur (default when the shape "
|
|
607
613
|
"changes), contain (bars) or cover (crop)")
|
|
608
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")
|
|
609
618
|
g.add_argument("--brand", help="ffmpeg-skill brand.json: its colours, caption colour, font and font file set "
|
|
610
619
|
"the look (an --options file still wins key by key)")
|
|
611
620
|
g.add_argument("--gl", choices=GL_BACKENDS,
|
|
@@ -687,16 +696,21 @@ def brand_look(path: str) -> Tuple[Dict[str, Any], Optional[str], List[str]]:
|
|
|
687
696
|
|
|
688
697
|
|
|
689
698
|
def load_look(a: argparse.Namespace) -> Dict[str, Any]:
|
|
690
|
-
"""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."""
|
|
691
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])
|
|
692
706
|
if not getattr(a, "brand", None):
|
|
693
|
-
return options
|
|
707
|
+
return {**style, **options}
|
|
694
708
|
b, font_file, notes = brand_look(a.brand)
|
|
695
709
|
for n in notes:
|
|
696
710
|
info(n)
|
|
697
711
|
if font_file and not a.font_file:
|
|
698
712
|
a.font_file = font_file
|
|
699
|
-
return {**b, **options}
|
|
713
|
+
return {**style, **b, **options}
|
|
700
714
|
|
|
701
715
|
|
|
702
716
|
def load_options(path: Optional[str]) -> Dict[str, Any]:
|
|
@@ -727,7 +741,7 @@ _OPTION_TYPES: Dict[str, Any] = {
|
|
|
727
741
|
"emphasisStyle": str, "bubbles": list, "comments": list, "background": str,
|
|
728
742
|
"kineticStyle": str, "kineticReveal": str, "kineticStagger": (int, float), "kineticSize": (int, float),
|
|
729
743
|
"visualizer": str, "visualizerBars": int, "loopBars": (int, type(None)), "beatsPerBar": int,
|
|
730
|
-
"seed": int, "threeParticles": int,
|
|
744
|
+
"seed": int, "threeParticles": int, "captionBox": (str, type(None)),
|
|
731
745
|
}
|
|
732
746
|
|
|
733
747
|
|
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",
|
|
@@ -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/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 "
|
|
@@ -186,6 +193,74 @@ def sparse_plan(timeline: Dict[str, Any], options: Dict[str, Any], a: argparse.N
|
|
|
186
193
|
return plan
|
|
187
194
|
|
|
188
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
|
+
|
|
189
264
|
def main() -> None:
|
|
190
265
|
a = build_parser().parse_args()
|
|
191
266
|
apply_common(a)
|
|
@@ -233,6 +308,13 @@ def main() -> None:
|
|
|
233
308
|
if not timeline["source"].get("has_video"):
|
|
234
309
|
die("--overlay needs a video source to composite onto", "input")
|
|
235
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")
|
|
236
318
|
sparse = sparse_plan(timeline, options, a) if a.sparse else None
|
|
237
319
|
used = bool(sparse and sparse["used"])
|
|
238
320
|
props_path, frame, font_note = prepare_props(project, a.comp, sparse["timeline"] if used else timeline,
|
|
@@ -251,7 +333,8 @@ def main() -> None:
|
|
|
251
333
|
plan = [shell_join(cmd)] + ([shell_join(ffskill_cmd("overlay", ov_args))] if a.overlay else [])
|
|
252
334
|
emit({"output": str(output), "commands": plan, "props": str(props_path),
|
|
253
335
|
"expected_frames": (frames[1] - frames[0] + 1) if frames else expected_frames(a.comp, timeline, options),
|
|
254
|
-
"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},
|
|
255
338
|
f"would render {a.comp} -> {output}")
|
|
256
339
|
return
|
|
257
340
|
|
|
@@ -296,6 +379,7 @@ def main() -> None:
|
|
|
296
379
|
look_error += (" -- this FFmpeg build has no drawtext filter. macOS Homebrew: `brew install ffmpeg-full` "
|
|
297
380
|
"(the plain ffmpeg formula dropped it); use still.py frames to look meanwhile")
|
|
298
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
|
|
299
383
|
v = probe.get("video") or {}
|
|
300
384
|
summary = (f"{output.name}: {float(probe.get('duration') or 0):.2f} s, {v.get('width')}x{v.get('height')}, "
|
|
301
385
|
f"{v.get('fps')} fps, {'audio' if probe.get('audio') else 'no audio'}")
|
|
@@ -303,6 +387,7 @@ def main() -> None:
|
|
|
303
387
|
"verification": rows, "commands": commands, "look": look, "summary": summary,
|
|
304
388
|
"frame": frame, "font": font_note, "mode": "overlay" if a.overlay else "full", "look_error": look_error,
|
|
305
389
|
"graphics": str(graphics) if a.overlay and a.keep_graphics else None, "sparse": sparse_note,
|
|
390
|
+
"layers": layers,
|
|
306
391
|
"kind": None if ok else "failed",
|
|
307
392
|
"error": None if ok else "verification failed: " + ", ".join(r["check"] for r in rows if r["status"] == "FAIL")}
|
|
308
393
|
table = "\n".join(f" {r['check']:<9} {r['status']:<4} {r['value']} (expected {r['expected']})" for r in rows)
|
|
@@ -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
|
};
|
|
@@ -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,8 @@ 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;
|
|
176
178
|
/** ThreeScene: the seed that places the particles (same seed, same scene). */
|
|
177
179
|
seed: number;
|
|
178
180
|
/** ThreeScene: number of particles, 1..5000. */
|
|
@@ -210,6 +212,7 @@ export const DEFAULT_OPTIONS: Options = {
|
|
|
210
212
|
visualizerBars: 48,
|
|
211
213
|
loopBars: null,
|
|
212
214
|
beatsPerBar: 4,
|
|
215
|
+
captionBox: null,
|
|
213
216
|
seed: 1,
|
|
214
217
|
threeParticles: 300,
|
|
215
218
|
};
|
|
@@ -249,8 +252,16 @@ export type Props = {
|
|
|
249
252
|
* ffmpeg-skill composites the result over it afterwards -- much faster on long footage.
|
|
250
253
|
*/
|
|
251
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;
|
|
252
260
|
};
|
|
253
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
|
+
|
|
254
265
|
export const resolveOptions = (o?: Partial<Options>): Options => ({ ...DEFAULT_OPTIONS, ...(o ?? {}) });
|
|
255
266
|
|
|
256
267
|
export const outputFrame = (p: Props): Frame =>
|