remotion-ffmpeg-skill 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +1 -0
- package/package.json +1 -1
- package/references/scripts.md +5 -3
- package/references/timeline.md +6 -0
- package/scripts/_common.py +16 -2
- package/scripts/_kinetic.py +139 -0
- package/scripts/analyze.py +33 -4
- package/scripts/render.py +3 -0
- package/templates/remotion-project/src/Root.tsx +2 -0
- package/templates/remotion-project/src/compositions/KineticType.tsx +121 -0
- package/templates/remotion-project/src/timeline.ts +20 -0
package/SKILL.md
CHANGED
|
@@ -67,6 +67,7 @@ Moving text has three owners: word-timed caption effects are this skill's, anima
|
|
|
67
67
|
| "use our brand" / a `brand.json` (ffmpeg-skill's format) | `--brand brand.json` on render / still / pipeline: its colours, caption colour, font and font file set the look (an `--options` file wins key by key); `deliver.py` / `pipeline.py --brand` places its logo with the template |
|
|
68
68
|
| a phone clip (VFR) or HDR / iPhone HDR / HLG footage | `analyze.py --conform` (or `pipeline.py --conform`): drawn on a CFR SDR BT.709 copy ffmpeg-skill made; without the flag it is refused |
|
|
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
|
+
| "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 |
|
|
70
71
|
| "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 |
|
|
71
72
|
| "preview" / "show me a frame" | `still.py` |
|
|
72
73
|
| 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.16.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
|
@@ -40,6 +40,8 @@ Measure a source with ffmpeg-skill and write timeline.json (+ captions from a fi
|
|
|
40
40
|
| `--fps` | string | | with --blank: the frame rate, e.g. 30, 25, 30000/1001 (default 30) |
|
|
41
41
|
| `--music` | string | | with --blank: the music (any file with an audio stream) that plays under the blank timeline from 0 s; measured with ffmpeg-skill (scenes.py peaks and --beats, silence.py). Cut at the blank's end when longer, silence after it when shorter |
|
|
42
42
|
| `--beats` | boolean | | also measure the beat grid (scenes.py --beats) |
|
|
43
|
+
| `--kinetic` | string: auto / words / beats | | schedule the caption cues' words for the KineticType composition: `words` (each word at the time --words measured), `beats` (each word, or CJK character, on the next measured beat; needs --beats) or `auto` (words when given, else beats). Never from unmeasured times |
|
|
44
|
+
| `--kinetic-step` | integer | `1` | with --kinetic beats: measured beats per word (default 1) |
|
|
43
45
|
| `--highlights` | integer | | also rank N highlight ranges (scenes.py --highlights; audio energy) for the Highlights composition |
|
|
44
46
|
| `--target` | number | | with --highlights: total length the picks add up to |
|
|
45
47
|
| `--no-scenes` | boolean | | skip scene-cut detection |
|
|
@@ -87,7 +89,7 @@ Render single frames as PNG to check the look before a full render.
|
|
|
87
89
|
| Argument | Type | Default | Meaning |
|
|
88
90
|
|---|---|---|---|
|
|
89
91
|
| `--project (required)` | string | | Remotion project folder made by init.py |
|
|
90
|
-
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, or yours) |
|
|
92
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, or yours) |
|
|
91
93
|
| `--timeline (required)` | string | | timeline.json written by analyze.py |
|
|
92
94
|
| `--options` | string | | JSON object of look-and-feel options |
|
|
93
95
|
| `--at` | number, repeatable | | time in seconds (repeatable) |
|
|
@@ -118,7 +120,7 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
118
120
|
| Argument | Type | Default | Meaning |
|
|
119
121
|
|---|---|---|---|
|
|
120
122
|
| `--project (required)` | string | | Remotion project folder made by init.py |
|
|
121
|
-
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, or one you added) |
|
|
123
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, or one you added) |
|
|
122
124
|
| `--timeline (required)` | string | | timeline.json written by analyze.py |
|
|
123
125
|
| `--options` | string | | JSON object of look-and-feel options (see references/timeline.md) |
|
|
124
126
|
| `--output` | string | | output file (default: <source>_<comp>.mp4, .mov for prores) |
|
|
@@ -183,7 +185,7 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
|
183
185
|
|---|---|---|---|
|
|
184
186
|
| `input` | string, repeatable | | source video; several are joined in order (ffmpeg-skill join.py) first (with --blank: none, or `-`) |
|
|
185
187
|
| `--project (required)` | string | | Remotion project folder made by init.py |
|
|
186
|
-
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, or yours) |
|
|
188
|
+
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, KineticType, or yours) |
|
|
187
189
|
| `--captions` | string | | SRT / WebVTT / JSON cues for the timeline |
|
|
188
190
|
| `--chapters` | string | | chapters (`TIME TITLE` per line, or `source`): cards in Titled and, with --platform, chapter markers in the deliverable |
|
|
189
191
|
| `--options` | string | | JSON options file passed to the composition |
|
package/references/timeline.md
CHANGED
|
@@ -31,6 +31,7 @@ props (`{ "timeline": ..., "options": ..., "frame": ..., "font": ..., "overlay":
|
|
|
31
31
|
| `pip` | `{path, name, duration, width, height, fps, offset, confidence, measured}` or null | `--pip CAMERA` (offset from ffmpeg-skill sync.py over both audio tracks) or `--pip-offset` | offset = seconds after the source's start at which the camera's first frame belongs (negative: the camera started first) |
|
|
32
32
|
| `words` | `[{start, end, text}]` | `--words` (whisper JSON with word timestamps, `{"words": [...]}` or a list) | per-word timings with the engine's own spacing; Karaoke lights them up |
|
|
33
33
|
| `emphasis` | `[{start, end, text, style, cue, span, words, by}]` | `--emphasis FILE` (the caller's words: a JSON list of words or `{text, at?, style?}`) and / or `--emphasis-auto numbers,names`; needs `--words` | each emphasised word as a slice of caption cue `cue`'s own timed words (`words` = [first, last] index into `words`): `start` / `end` are the engine's times of those words, `text` the caption's own spelling, `span` its [start, end) code-point offsets in the cue's text (the cue text is what is drawn; when `--captions` and `--words` disagree about a word, it is refused). `style` is `pop`, `color`, `box` or null (= the `emphasisStyle` option); `by` is `caller`, `numbers` or `names`. A caller's word that is not a whole, timed word of the cue (or of the cue showing at `at`) is refused (`kind: input`) |
|
|
34
|
+
| `kinetic` | object \| null (optional) | analyze.py `--kinetic words\|beats\|auto` | the KineticType schedule: `{by, step, lines: [{cue, start, end, units: [{text, gap, start}]}]}`. One line per caption cue; a unit is a word (split at spaces) or, in text written without spaces (Japanese, Chinese), one character, punctuation staying with the one before. `start` is measured: the word's own time from `--words` (`by: words`), or the next measured beat from `--beats`, `step` beats apart (`by: beats`, `--kinetic-step`). `gap`: a space before the unit. A line shows from its first unit's start until `end` (its cue's end, later when the beats run past it, never into the next line). No measurement, no schedule: refused (`kind: input`) |
|
|
34
35
|
| `conform` | object \| null | analyze.py `--conform` | provenance when the source was VFR or HDR: `reasons` (`vfr`, `hdr`), `original` (path, name, sha256 fingerprint, duration, frame rates, colour tags), `output` (= `source.path`), `steps` (`{reason, tool, args, command, notes}` per ffmpeg-skill call: `fit.py --fps`, then `color.py --to-sdr`), `measured` (ffmpeg-skill probe of the copy: CFR, BT.709). `pip.conform` is the same for a conformed camera. null = the source was drawn on as it is |
|
|
35
36
|
| `warnings` | `[string]` | analyze.py | rotation, odd frame rate, chapters, transcript (VFR and HDR are never warnings: conformed or refused) |
|
|
36
37
|
|
|
@@ -50,6 +51,7 @@ composition exactly.
|
|
|
50
51
|
| `Karaoke` | source duration | caption cues whose words light up at their measured times (current word accent + lift, spoken white, upcoming dimmed); cues without timed words show plain |
|
|
51
52
|
| `Emphasis` | source duration | YouTube-style captions: each cue as written; its `emphasis` words pop, take the accent colour or get an accent box from the time they are spoken to the end of the cue; speech bubbles (`bubbles`) and comment-style cards (`comments`) with the user's text at their own times |
|
|
52
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
|
+
| `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` |
|
|
53
55
|
| `BeatMontage` | source duration | audio unbroken; the picture cuts every `beatsPerCut` measured beats, cycling through highlights (or scenes); no usable grid → cuts on scene changes |
|
|
54
56
|
|
|
55
57
|
## Options (`--options look.json`)
|
|
@@ -79,6 +81,10 @@ Every key is optional.
|
|
|
79
81
|
| `bubbles` | `[]` | Emphasis: speech bubbles `[{"text", "start", "end", "side"?}]` (`side`: `left` or `right`), the user's text, seconds on the source timeline |
|
|
80
82
|
| `comments` | `[]` | Emphasis: comment-style cards `[{"text", "start", "end", "author"?}]`, top left, stacked while they overlap; the user's text |
|
|
81
83
|
| `background` | `"#000000"` | the picture of a source-less run (analyze.py `--blank`): any CSS colour or gradient |
|
|
84
|
+
| `kineticStyle` | `"pop"` | KineticType: how a unit enters: `pop` (scales down into place), `wipe` (a mask opens left to right), `tracking` (its characters close in), `rise` |
|
|
85
|
+
| `kineticReveal` | `"char"` | KineticType: `char` (characters one after another from the unit's start) or `unit` (the whole unit at its start) |
|
|
86
|
+
| `kineticStagger` | `0.04` | KineticType: seconds between characters with `kineticReveal: "char"`, 0–1 |
|
|
87
|
+
| `kineticSize` | `0.09` | KineticType: text size as a fraction of the frame's short side, 0.01–0.5 |
|
|
82
88
|
| `chapterSeconds` | `4` | Titled: how long a chapter card stays up (cut short by the next chapter; 0 = none) |
|
|
83
89
|
|
|
84
90
|
Unknown keys and wrong types are refused by render.py / still.py before anything renders.
|
package/scripts/_common.py
CHANGED
|
@@ -27,6 +27,8 @@ from fractions import Fraction
|
|
|
27
27
|
from pathlib import Path
|
|
28
28
|
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
|
29
29
|
|
|
30
|
+
from _kinetic import validate as validate_kinetic
|
|
31
|
+
|
|
30
32
|
HERE = Path(__file__).resolve().parent
|
|
31
33
|
ROOT = HERE.parent
|
|
32
34
|
SKILL_ID = "remotion-ffmpeg-skill"
|
|
@@ -257,6 +259,7 @@ def validate_timeline(t: Any) -> List[str]:
|
|
|
257
259
|
p.append(f"emphasis[{i}] needs start < end, text, its caption cue, the span of the text in that cue, "
|
|
258
260
|
"its word range and a style (pop, color, box or null) -- analyze.py --emphasis writes it")
|
|
259
261
|
break
|
|
262
|
+
p += validate_kinetic(t.get("kinetic"), len(caps))
|
|
260
263
|
for i, r in enumerate(t.get("speech", []) or []):
|
|
261
264
|
if not (isinstance(r, list) and len(r) == 2 and r[1] > r[0]):
|
|
262
265
|
p.append(f"speech[{i}] must be [start, end] with start < end")
|
|
@@ -334,7 +337,7 @@ def expected_frames(comp: str, t: Dict[str, Any]) -> Optional[int]:
|
|
|
334
337
|
and render.py then only reports the measured numbers.
|
|
335
338
|
"""
|
|
336
339
|
fps = float(t["source"]["fps"])
|
|
337
|
-
if comp in ("Captioned", "PeakPulse", "Titled", "BeatMontage", "Karaoke", "Pip", "Emphasis"):
|
|
340
|
+
if comp in ("Captioned", "PeakPulse", "Titled", "BeatMontage", "Karaoke", "Pip", "Emphasis", "KineticType"):
|
|
338
341
|
return max(1, sec_to_frames(float(t["source"]["duration"]), fps))
|
|
339
342
|
if comp in ("Jumpcut", "Highlights"):
|
|
340
343
|
if comp == "Jumpcut":
|
|
@@ -349,7 +352,7 @@ def expected_frames(comp: str, t: Dict[str, Any]) -> Optional[int]:
|
|
|
349
352
|
# ---------------------------------------------------------------- Remotion project
|
|
350
353
|
|
|
351
354
|
BUILTIN_COMPOSITIONS = ("Captioned", "Jumpcut", "PeakPulse", "Titled", "Highlights", "BeatMontage", "Karaoke", "Pip",
|
|
352
|
-
"Emphasis")
|
|
355
|
+
"Emphasis", "KineticType")
|
|
353
356
|
|
|
354
357
|
|
|
355
358
|
def remotion_bin(project: Path) -> Path:
|
|
@@ -675,6 +678,7 @@ _OPTION_TYPES: Dict[str, Any] = {
|
|
|
675
678
|
"title": (str, type(None)), "beatsPerCut": int, "chapterSeconds": (int, float),
|
|
676
679
|
"pipCorner": str, "pipSize": (int, float), "pipShape": str, "pipAudio": bool,
|
|
677
680
|
"emphasisStyle": str, "bubbles": list, "comments": list, "background": str,
|
|
681
|
+
"kineticStyle": str, "kineticReveal": str, "kineticStagger": (int, float), "kineticSize": (int, float),
|
|
678
682
|
}
|
|
679
683
|
|
|
680
684
|
|
|
@@ -707,6 +711,16 @@ def validate_options(o: Dict[str, Any]) -> List[str]:
|
|
|
707
711
|
if isinstance(o.get("pipSize"), (int, float)) and not isinstance(o["pipSize"], bool) \
|
|
708
712
|
and not 0.05 <= o["pipSize"] <= 0.6:
|
|
709
713
|
p.append("pipSize must be between 0.05 and 0.6 (a fraction of the frame width)")
|
|
714
|
+
if "kineticStyle" in o and o["kineticStyle"] not in ("pop", "wipe", "tracking", "rise"):
|
|
715
|
+
p.append("kineticStyle must be pop, wipe, tracking or rise")
|
|
716
|
+
if "kineticReveal" in o and o["kineticReveal"] not in ("unit", "char"):
|
|
717
|
+
p.append("kineticReveal must be unit or char")
|
|
718
|
+
if isinstance(o.get("kineticStagger"), (int, float)) and not isinstance(o["kineticStagger"], bool) \
|
|
719
|
+
and not 0 <= o["kineticStagger"] <= 1:
|
|
720
|
+
p.append("kineticStagger must be between 0 and 1 second")
|
|
721
|
+
if isinstance(o.get("kineticSize"), (int, float)) and not isinstance(o["kineticSize"], bool) \
|
|
722
|
+
and not 0.01 <= o["kineticSize"] <= 0.5:
|
|
723
|
+
p.append("kineticSize must be between 0.01 and 0.5 (a fraction of the frame's short side)")
|
|
710
724
|
if "emphasisStyle" in o and o["emphasisStyle"] not in ("pop", "color", "box"):
|
|
711
725
|
p.append("emphasisStyle must be pop, color or box")
|
|
712
726
|
for key, extra in (("bubbles", "side"), ("comments", "author")):
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""The KineticType schedule (internal module, not a tool): when each word (or CJK character) of the caption
|
|
3
|
+
cues starts, from a measurement only -- the speech engine's word timings (analyze.py --words) or the measured
|
|
4
|
+
beat grid (analyze.py --beats). analyze.py --kinetic writes it into the timeline as `kinetic`; the composition
|
|
5
|
+
draws it and computes no time of its own, so the frame a unit starts on is round(start * fps) on both sides.
|
|
6
|
+
|
|
7
|
+
Kinetic typography with no measured timing belongs to hyperframes-skill (Velisa ownership decisions O17), so
|
|
8
|
+
there is no fallback to evenly spread or guessed times: no usable measurement, no schedule.
|
|
9
|
+
"""
|
|
10
|
+
import re
|
|
11
|
+
import unicodedata
|
|
12
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
13
|
+
|
|
14
|
+
KINETIC_TIMINGS = ("auto", "words", "beats")
|
|
15
|
+
# A character that is never a unit of its own: it stays with the character before it.
|
|
16
|
+
_ATTACH = set("、。,.・:;!?!?,.)])」』】〉》〕”’ー〜ゝゞヽヾ")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class KineticError(ValueError):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _is_cjk(ch: str) -> bool:
|
|
24
|
+
o = ord(ch)
|
|
25
|
+
return (0x3040 <= o <= 0x30FF or 0x3400 <= o <= 0x4DBF or 0x4E00 <= o <= 0x9FFF or 0xAC00 <= o <= 0xD7AF
|
|
26
|
+
or 0xF900 <= o <= 0xFAFF or 0xFF66 <= o <= 0xFF9F)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def split_units(text: str) -> List[Tuple[str, bool]]:
|
|
30
|
+
"""A cue's text as (unit, space before it): words split at whitespace; a run of CJK characters (written
|
|
31
|
+
without spaces) is one unit per character, punctuation and the long-vowel mark staying with the character
|
|
32
|
+
before. The text itself is never changed: joining the units (a space where marked) gives it back, apart
|
|
33
|
+
from runs of whitespace, which become one space."""
|
|
34
|
+
out: List[Tuple[str, bool]] = []
|
|
35
|
+
for ti, tok in enumerate(t for t in re.split(r"\s+", unicodedata.normalize("NFC", text)) if t):
|
|
36
|
+
gap = ti > 0
|
|
37
|
+
if not any(_is_cjk(ch) for ch in tok):
|
|
38
|
+
out.append((tok, gap))
|
|
39
|
+
continue
|
|
40
|
+
buf = ""
|
|
41
|
+
for ch in tok:
|
|
42
|
+
latin_run = buf and not _is_cjk(ch) and not _is_cjk(buf[-1]) and ch not in _ATTACH
|
|
43
|
+
if buf and (ch in _ATTACH or latin_run):
|
|
44
|
+
buf += ch
|
|
45
|
+
continue
|
|
46
|
+
if buf:
|
|
47
|
+
out.append((buf, gap))
|
|
48
|
+
gap = False
|
|
49
|
+
buf = ch
|
|
50
|
+
if buf:
|
|
51
|
+
out.append((buf, gap))
|
|
52
|
+
return out
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _cue_words(cue: Dict[str, Any], words: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
56
|
+
"""The timed words of a cue: their midpoint falls inside it (as the Karaoke composition takes them)."""
|
|
57
|
+
return [w for w in words if cue["start"] <= (w["start"] + w["end"]) / 2 <= cue["end"]]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def schedule(captions: List[Dict[str, Any]], words: List[Dict[str, Any]], beats: Optional[Dict[str, Any]],
|
|
61
|
+
timing: str = "auto", step: int = 1, duration: Optional[float] = None) -> Dict[str, Any]:
|
|
62
|
+
"""{by, step, lines, warnings}: one line per caption cue, `units` = [{text, gap, start}] in order, `start` the
|
|
63
|
+
measured time the unit first shows; `start`/`end` of the line = its first unit's start and the time it clears
|
|
64
|
+
(the cue's end, or later when the beats run past it -- a warning says so)."""
|
|
65
|
+
if timing not in KINETIC_TIMINGS:
|
|
66
|
+
raise KineticError(f"--kinetic must be one of {', '.join(KINETIC_TIMINGS)}, got {timing!r}")
|
|
67
|
+
if step < 1:
|
|
68
|
+
raise KineticError("--kinetic-step must be at least 1 beat per unit")
|
|
69
|
+
if not captions:
|
|
70
|
+
raise KineticError("--kinetic needs text: caption cues from --captions (a lyric SRT) or --words")
|
|
71
|
+
beat_times = sorted(float(b) for b in ((beats or {}).get("times") or [])) if (beats or {}).get("usable") else []
|
|
72
|
+
if timing == "auto":
|
|
73
|
+
timing = "words" if words else "beats"
|
|
74
|
+
if timing == "words" and not words:
|
|
75
|
+
raise KineticError("--kinetic words needs word timings (--words): every word starts at the time the "
|
|
76
|
+
"speech engine measured")
|
|
77
|
+
if timing == "beats" and not beat_times:
|
|
78
|
+
why = "was not measured (add --beats)" if not beats else "is not usable (too little confidence)"
|
|
79
|
+
raise KineticError(f"--kinetic beats needs the measured beat grid, which {why}; kinetic type from no "
|
|
80
|
+
"measurement is hyperframes-skill's")
|
|
81
|
+
lines: List[Dict[str, Any]] = []
|
|
82
|
+
warnings: List[str] = []
|
|
83
|
+
bi = 0 # next beat a unit may take (beats are used in order, each by one unit at most)
|
|
84
|
+
for ci, cue in enumerate(captions):
|
|
85
|
+
if timing == "words":
|
|
86
|
+
own = _cue_words(cue, words)
|
|
87
|
+
if not own:
|
|
88
|
+
warnings.append(f"kinetic: cue {ci + 1} ({cue['text'][:24]!r}) has no timed words and is not drawn")
|
|
89
|
+
continue
|
|
90
|
+
units = []
|
|
91
|
+
for wi, w in enumerate(own):
|
|
92
|
+
raw = str(w["text"])
|
|
93
|
+
# a word the engine timed is one unit, its spacing the engine's own (a leading space)
|
|
94
|
+
units.append({"text": raw.strip(), "gap": wi > 0 and raw[:1].isspace(),
|
|
95
|
+
"start": round(float(w["start"]), 3)})
|
|
96
|
+
units = [u for u in units if u["text"]]
|
|
97
|
+
else:
|
|
98
|
+
parts = split_units(cue["text"])
|
|
99
|
+
while bi < len(beat_times) and beat_times[bi] < cue["start"] - 1e-6:
|
|
100
|
+
bi += 1
|
|
101
|
+
units = []
|
|
102
|
+
for text, gap in parts:
|
|
103
|
+
if bi >= len(beat_times):
|
|
104
|
+
break
|
|
105
|
+
units.append({"text": text, "gap": gap, "start": round(beat_times[bi], 3)})
|
|
106
|
+
bi += step
|
|
107
|
+
if len(units) < len(parts):
|
|
108
|
+
warnings.append(f"kinetic: cue {ci + 1} ({cue['text'][:24]!r}): the measured beats ran out after "
|
|
109
|
+
f"{len(units)} of {len(parts)} units; the rest is not drawn")
|
|
110
|
+
if not units:
|
|
111
|
+
continue
|
|
112
|
+
end = max(float(cue["end"]), units[-1]["start"] + 0.25)
|
|
113
|
+
if timing == "beats" and units[-1]["start"] >= cue["end"]:
|
|
114
|
+
warnings.append(f"kinetic: cue {ci + 1} ({cue['text'][:24]!r}) needs beats up to "
|
|
115
|
+
f"{units[-1]['start']:.3f} s, past its end {cue['end']:.3f} s: it stays up until then")
|
|
116
|
+
if duration is not None:
|
|
117
|
+
end = min(end, duration)
|
|
118
|
+
lines.append({"cue": ci, "start": units[0]["start"], "end": round(end, 3), "units": units})
|
|
119
|
+
# a line clears when the next one starts, so two lines never overlap
|
|
120
|
+
for a, b in zip(lines, lines[1:]):
|
|
121
|
+
if a["end"] > b["start"]:
|
|
122
|
+
a["end"] = b["start"]
|
|
123
|
+
if not lines:
|
|
124
|
+
raise KineticError("--kinetic: no caption cue could be timed")
|
|
125
|
+
return {"by": timing, "step": step if timing == "beats" else None, "lines": lines, "warnings": warnings}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def validate(k: Any, n_captions: int) -> List[str]:
|
|
129
|
+
if k is None:
|
|
130
|
+
return []
|
|
131
|
+
ok = isinstance(k, dict) and k.get("by") in ("words", "beats") and isinstance(k.get("lines"), list)
|
|
132
|
+
for ln in (k.get("lines") if ok else []):
|
|
133
|
+
ok = ok and isinstance(ln, dict) and isinstance(ln.get("cue"), int) and 0 <= ln["cue"] < n_captions \
|
|
134
|
+
and isinstance(ln.get("units"), list) and ln["units"] and isinstance(ln.get("end"), (int, float))
|
|
135
|
+
for u in (ln.get("units") if ok else []):
|
|
136
|
+
ok = ok and isinstance(u, dict) and isinstance(u.get("text"), str) and u["text"] \
|
|
137
|
+
and isinstance(u.get("start"), (int, float)) and isinstance(u.get("gap"), bool)
|
|
138
|
+
return [] if ok else ["kinetic must be {by: words|beats, lines: [{cue, start, end, units: [{text, gap, start}]}]} "
|
|
139
|
+
"-- analyze.py --kinetic writes it"]
|
package/scripts/analyze.py
CHANGED
|
@@ -22,6 +22,7 @@ Examples:
|
|
|
22
22
|
python3 analyze.py talk.mp4 --words talk.transcript.json --emphasis words.json # Emphasis composition
|
|
23
23
|
python3 analyze.py phone_hdr.mov --conform # VFR / HDR: measure and draw on a CFR SDR copy
|
|
24
24
|
python3 analyze.py --blank 15 --size 1080x1920 --music bgm.wav --beats # no footage: a 15 s blank timeline
|
|
25
|
+
python3 analyze.py --blank 15 --music song.wav --beats --captions lyrics.srt --kinetic beats # KineticType
|
|
25
26
|
"""
|
|
26
27
|
import argparse
|
|
27
28
|
import hashlib
|
|
@@ -37,6 +38,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
37
38
|
from _common import (STATE, TIMELINE_SCHEMA, SKILL_ID, add_common, apply_common, default_output, die,
|
|
38
39
|
emit, ffmpeg_skill_version, ffskill, ffskill_cmd, info, refuse_existing,
|
|
39
40
|
exact_rate, require_ffmpeg_skill, shell_join, stream_rate, version, parse_with_blank)
|
|
41
|
+
from _kinetic import KINETIC_TIMINGS, KineticError, schedule as kinetic_schedule
|
|
40
42
|
from _captions import (CaptionError, cues_from_words, parse_chapters, read_captions, read_emphasis,
|
|
41
43
|
read_word_timings, resolve_emphasis, youtube_chapter_warnings)
|
|
42
44
|
|
|
@@ -107,6 +109,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
107
109
|
"from 0 s; measured with ffmpeg-skill (scenes.py peaks and --beats, silence.py). Cut at the "
|
|
108
110
|
"blank's end when longer, silence after it when shorter")
|
|
109
111
|
p.add_argument("--beats", action="store_true", help="also measure the beat grid (scenes.py --beats)")
|
|
112
|
+
p.add_argument("--kinetic", choices=KINETIC_TIMINGS, metavar="TIMING",
|
|
113
|
+
help="schedule the caption cues' words for the KineticType composition: `words` (each word at "
|
|
114
|
+
"the time --words measured), `beats` (each word, or CJK character, on the next measured "
|
|
115
|
+
"beat; needs --beats) or `auto` (words when given, else beats). Never from unmeasured times")
|
|
116
|
+
p.add_argument("--kinetic-step", type=int, default=1, metavar="N",
|
|
117
|
+
help="with --kinetic beats: measured beats per word (default 1)")
|
|
110
118
|
p.add_argument("--highlights", type=int, metavar="N",
|
|
111
119
|
help="also rank N highlight ranges (scenes.py --highlights; audio energy) for the Highlights composition")
|
|
112
120
|
p.add_argument("--target", type=float, metavar="SECONDS", help="with --highlights: total length the picks add up to")
|
|
@@ -285,6 +293,20 @@ def conform_source(label: str, src: Path, probe: Dict[str, Any], out: Path, fps:
|
|
|
285
293
|
return out, after, record
|
|
286
294
|
|
|
287
295
|
|
|
296
|
+
def kinetic_for(a: argparse.Namespace, captions: List[Dict[str, Any]], words: List[Dict[str, Any]], beats: Any,
|
|
297
|
+
duration: float) -> Tuple[Optional[Dict[str, Any]], List[str]]:
|
|
298
|
+
"""The KineticType schedule (scripts/_kinetic.py) when --kinetic was given, and its warnings."""
|
|
299
|
+
if a.kinetic is None:
|
|
300
|
+
if a.kinetic_step != 1:
|
|
301
|
+
die("--kinetic-step needs --kinetic", "input")
|
|
302
|
+
return None, []
|
|
303
|
+
try:
|
|
304
|
+
k = kinetic_schedule(captions, words, beats, a.kinetic, a.kinetic_step, duration)
|
|
305
|
+
except KineticError as e:
|
|
306
|
+
die(str(e), "input")
|
|
307
|
+
return {key: k[key] for key in ("by", "step", "lines")}, k["warnings"]
|
|
308
|
+
|
|
309
|
+
|
|
288
310
|
# ---------------------------------------------------------------- source-less runs (--blank)
|
|
289
311
|
|
|
290
312
|
BLANK_MAX_SECONDS = 24 * 3600.0
|
|
@@ -433,6 +455,8 @@ def blank_main(a: argparse.Namespace) -> None:
|
|
|
433
455
|
except CaptionError as e:
|
|
434
456
|
die(f"{chpath}: {e}", "input")
|
|
435
457
|
|
|
458
|
+
kinetic, kinetic_warnings = kinetic_for(a, captions, words, beats, duration)
|
|
459
|
+
warnings += kinetic_warnings
|
|
436
460
|
timeline: Dict[str, Any] = {
|
|
437
461
|
"schema": TIMELINE_SCHEMA,
|
|
438
462
|
"generator": {"name": SKILL_ID, "version": version(), "ffmpeg_skill": ffmpeg_skill_version(skill)},
|
|
@@ -445,7 +469,7 @@ def blank_main(a: argparse.Namespace) -> None:
|
|
|
445
469
|
"scenes": [{"start": 0.0, "end": duration}],
|
|
446
470
|
"silences": silences, "speech": speech, "peaks": peaks, "beats": beats, "highlights": [], "clips": [],
|
|
447
471
|
"captions": captions, "words": words, "emphasis": emphasis, "chapters": chapters, "pip": None,
|
|
448
|
-
"conform": None,
|
|
472
|
+
"kinetic": kinetic, "conform": None,
|
|
449
473
|
"warnings": warnings + (youtube_chapter_warnings(chapters) if chapters else []) + emphasis_warnings,
|
|
450
474
|
}
|
|
451
475
|
for w in timeline["warnings"]:
|
|
@@ -459,7 +483,8 @@ def blank_main(a: argparse.Namespace) -> None:
|
|
|
459
483
|
"peaks": len(peaks), "captions": len(captions), "chapters": len(chapters), "pip_offset": None,
|
|
460
484
|
"beats": bool(beats and beats.get("usable")), "tempo_bpm": (beats or {}).get("tempo_bpm"),
|
|
461
485
|
"highlights": 0, "clips": 1, "words": len(words), "emphasis": len(emphasis), "conformed": [],
|
|
462
|
-
"blank": True, "music": music.name if music else None
|
|
486
|
+
"blank": True, "music": music.name if music else None,
|
|
487
|
+
"kinetic": sum(len(ln["units"]) for ln in kinetic["lines"]) if kinetic else 0},
|
|
463
488
|
"warnings": timeline["warnings"]},
|
|
464
489
|
f"wrote {out}: blank {duration:g} s, {width}x{height} at {fps:g} fps, "
|
|
465
490
|
+ (f"music {music.name} ({len(peaks)} peaks" + (f", {len((beats or {}).get('times') or [])} beats" if beats else "")
|
|
@@ -710,6 +735,7 @@ def main() -> None:
|
|
|
710
735
|
if pip["offset"] >= duration or pip["offset"] + pip["duration"] <= 0:
|
|
711
736
|
die(f"--pip: with an offset of {pip['offset']:g} s the camera never overlaps the source", "input")
|
|
712
737
|
|
|
738
|
+
kinetic, kinetic_warnings = kinetic_for(a, captions, words, beats, duration)
|
|
713
739
|
v = video or {}
|
|
714
740
|
timeline: Dict[str, Any] = {
|
|
715
741
|
"schema": TIMELINE_SCHEMA,
|
|
@@ -737,10 +763,12 @@ def main() -> None:
|
|
|
737
763
|
"emphasis": emphasis,
|
|
738
764
|
"chapters": chapters,
|
|
739
765
|
"pip": pip,
|
|
766
|
+
# The KineticType schedule (--kinetic): when each word or CJK character starts, from words or beats.
|
|
767
|
+
"kinetic": kinetic,
|
|
740
768
|
# Provenance of a conformed source (--conform): the original, each ffmpeg-skill step, the measured copy.
|
|
741
769
|
"conform": conform,
|
|
742
770
|
"warnings": warnings_for(probe) + (youtube_chapter_warnings(chapters) if chapters else []) + transcript_warnings
|
|
743
|
-
+ emphasis_warnings,
|
|
771
|
+
+ emphasis_warnings + kinetic_warnings,
|
|
744
772
|
}
|
|
745
773
|
if pip and pip["measured"] and (pip["confidence"] or 0) < 0.3:
|
|
746
774
|
timeline["warnings"].append(f"pip: the measured offset ({pip['offset']:g} s) has low confidence "
|
|
@@ -767,7 +795,8 @@ def main() -> None:
|
|
|
767
795
|
"pip_offset": pip["offset"] if pip else None, "beats": bool(beats and beats.get("usable")),
|
|
768
796
|
"tempo_bpm": (beats or {}).get("tempo_bpm"), "highlights": len(highlights),
|
|
769
797
|
"clips": len(clips) or 1, "words": len(words), "emphasis": len(emphasis),
|
|
770
|
-
"conformed": (conform or {}).get("reasons", [])
|
|
798
|
+
"conformed": (conform or {}).get("reasons", []),
|
|
799
|
+
"kinetic": sum(len(ln["units"]) for ln in kinetic["lines"]) if kinetic else 0},
|
|
771
800
|
"warnings": timeline["warnings"]},
|
|
772
801
|
f"wrote {out}: {timeline['source']['duration']}s, {len(scenes)} scenes, {len(silences)} silences "
|
|
773
802
|
f"(speech {speech_total:.2f}s), {len(peaks)} peaks, {len(captions)} captions"
|
package/scripts/render.py
CHANGED
|
@@ -202,6 +202,9 @@ def main() -> None:
|
|
|
202
202
|
output = output.resolve()
|
|
203
203
|
refuse_existing(output)
|
|
204
204
|
|
|
205
|
+
if a.comp == "KineticType" and not timeline.get("kinetic"):
|
|
206
|
+
die("KineticType draws the schedule analyze.py --kinetic writes (words or measured beats); this timeline "
|
|
207
|
+
"has none: re-run analyze.py with --kinetic", "input")
|
|
205
208
|
if a.sparse:
|
|
206
209
|
if a.comp not in _sparse.SPARSE_COMPOSITIONS:
|
|
207
210
|
die(f"--sparse draws only the stretches where graphics show: {a.comp} is not one of "
|
|
@@ -9,6 +9,7 @@ import { BeatMontage } from "./compositions/BeatMontage";
|
|
|
9
9
|
import { Karaoke } from "./compositions/Karaoke";
|
|
10
10
|
import { Pip } from "./compositions/Pip";
|
|
11
11
|
import { Emphasis } from "./compositions/Emphasis";
|
|
12
|
+
import { KineticType } from "./compositions/KineticType";
|
|
12
13
|
import { SAMPLE_TIMELINE, fullLengthFrames, highlightFrames, jumpcutFrames, outputFrame, type Props, type Timeline } from "./timeline";
|
|
13
14
|
|
|
14
15
|
// Length and fps come from the measured timeline, never from constants; the frame is the
|
|
@@ -34,5 +35,6 @@ export const RemotionRoot: React.FC = () => (
|
|
|
34
35
|
<Composition id="Karaoke" component={Karaoke} {...base} calculateMetadata={metadataFrom(fullLengthFrames)} />
|
|
35
36
|
<Composition id="Pip" component={Pip} {...base} calculateMetadata={metadataFrom(fullLengthFrames)} />
|
|
36
37
|
<Composition id="Emphasis" component={Emphasis} {...base} calculateMetadata={metadataFrom(fullLengthFrames)} />
|
|
38
|
+
<Composition id="KineticType" component={KineticType} {...base} calculateMetadata={metadataFrom(fullLengthFrames)} />
|
|
37
39
|
</>
|
|
38
40
|
);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AbsoluteFill, interpolate, useCurrentFrame, useVideoConfig } from "remotion";
|
|
3
|
+
import { SourceVideo } from "../lib/SourceVideo";
|
|
4
|
+
import { useStagedFont } from "../lib/useStagedFont";
|
|
5
|
+
import { Props, fontStack, outputFrame, resolveOptions, secToFrames, type KineticLine, type Options } from "../timeline";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* KineticType: the caption cues' words (or CJK characters) entering one by one at the times analyze.py
|
|
9
|
+
* --kinetic scheduled from a measurement -- each word's own time from a speech engine (--words) or the next
|
|
10
|
+
* measured beat (--beats). Nothing here makes up a time: a unit is invisible before the frame of its `start`
|
|
11
|
+
* and visible on it. Units keep their place in the line while hidden, so nothing reflows as they enter.
|
|
12
|
+
* kineticStyle: pop (scale), wipe (a mask from the left), tracking (characters closing in), rise.
|
|
13
|
+
* kineticReveal "char": a unit's characters follow each other kineticStagger seconds apart from its start.
|
|
14
|
+
*/
|
|
15
|
+
export const KineticType: React.FC<Props> = (props) => {
|
|
16
|
+
const { timeline, options, font, overlay } = props;
|
|
17
|
+
useStagedFont(font);
|
|
18
|
+
const o = resolveOptions(options);
|
|
19
|
+
const family = fontStack(o, font);
|
|
20
|
+
const frame = useCurrentFrame();
|
|
21
|
+
const { fps } = useVideoConfig();
|
|
22
|
+
const lines = timeline.kinetic?.lines ?? [];
|
|
23
|
+
const line = lines.find((ln) => frame >= secToFrames(ln.start, fps) && frame < secToFrames(ln.end, fps));
|
|
24
|
+
return (
|
|
25
|
+
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
26
|
+
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
27
|
+
{line ? <Line line={line} o={o} fontFamily={family} /> : null}
|
|
28
|
+
</AbsoluteFill>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Frames a unit (or character) takes to settle once it has started. */
|
|
33
|
+
const ENTER_SECONDS = 0.18;
|
|
34
|
+
|
|
35
|
+
const Line: React.FC<{ line: KineticLine; o: Options; fontFamily: string }> = ({ line, o, fontFamily }) => {
|
|
36
|
+
const frame = useCurrentFrame();
|
|
37
|
+
const { fps, width, height } = useVideoConfig();
|
|
38
|
+
const size = Math.round(Math.min(width, height) * o.kineticSize);
|
|
39
|
+
const enter = Math.max(1, Math.round(fps * ENTER_SECONDS));
|
|
40
|
+
const endFrame = secToFrames(line.end, fps);
|
|
41
|
+
const fade = Math.min(6, Math.max(0, endFrame - secToFrames(line.start, fps) - 1));
|
|
42
|
+
const exit = fade > 0 ? interpolate(frame, [endFrame - fade, endFrame], [1, 0], { extrapolateLeft: "clamp", extrapolateRight: "clamp" }) : 1;
|
|
43
|
+
const text = line.units.map((u) => u.text).join("");
|
|
44
|
+
const lang = /[-ヿ]/.test(text) ? "ja" : /[가-]/.test(text) ? "ko" : undefined;
|
|
45
|
+
const starts = line.units.map((u) => secToFrames(u.start, fps));
|
|
46
|
+
// The unit that started last is the current one: it takes the accent colour.
|
|
47
|
+
let current = -1;
|
|
48
|
+
starts.forEach((s, i) => {
|
|
49
|
+
if (s <= frame) current = i;
|
|
50
|
+
});
|
|
51
|
+
// progress 0 before the start frame, > 0 on it, 1 once settled
|
|
52
|
+
const progress = (start: number): number => (frame < start ? 0 : Math.min(1, (frame - start + 1) / enter));
|
|
53
|
+
return (
|
|
54
|
+
<AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>
|
|
55
|
+
<div
|
|
56
|
+
lang={lang}
|
|
57
|
+
style={{
|
|
58
|
+
maxWidth: width * 0.88,
|
|
59
|
+
display: "flex",
|
|
60
|
+
flexWrap: "wrap",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
alignItems: "baseline",
|
|
63
|
+
fontFamily,
|
|
64
|
+
fontWeight: 800,
|
|
65
|
+
fontSize: size,
|
|
66
|
+
lineHeight: 1.25,
|
|
67
|
+
color: o.textColor,
|
|
68
|
+
opacity: exit,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{line.units.map((u, i) => {
|
|
72
|
+
const chars = Array.from(u.text);
|
|
73
|
+
const charStart = (j: number) =>
|
|
74
|
+
o.kineticReveal === "char" ? secToFrames(u.start + j * o.kineticStagger, fps) : starts[i];
|
|
75
|
+
return (
|
|
76
|
+
<span
|
|
77
|
+
key={i}
|
|
78
|
+
style={{
|
|
79
|
+
display: "inline-flex",
|
|
80
|
+
whiteSpace: "pre",
|
|
81
|
+
marginLeft: u.gap ? "0.28em" : 0,
|
|
82
|
+
color: i === current ? o.accent : o.textColor,
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{chars.map((ch, j) => {
|
|
86
|
+
const p = progress(Math.max(starts[i], charStart(j)));
|
|
87
|
+
return (
|
|
88
|
+
<span key={j} style={{ display: "inline-block", ...enterStyle(o.kineticStyle, p, j, chars.length) }}>
|
|
89
|
+
{ch}
|
|
90
|
+
</span>
|
|
91
|
+
);
|
|
92
|
+
})}
|
|
93
|
+
</span>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
</div>
|
|
97
|
+
</AbsoluteFill>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const ease = (p: number): number => 1 - Math.pow(1 - p, 3);
|
|
102
|
+
|
|
103
|
+
/** How a character looks at progress p (0 = not started: drawn invisibly so the line keeps its layout). */
|
|
104
|
+
const enterStyle = (style: Options["kineticStyle"], p: number, j: number, n: number): React.CSSProperties => {
|
|
105
|
+
if (p <= 0) return { opacity: 0 };
|
|
106
|
+
const e = ease(p);
|
|
107
|
+
switch (style) {
|
|
108
|
+
case "wipe":
|
|
109
|
+
return { clipPath: `inset(0 ${(1 - e) * 100}% 0 0)` };
|
|
110
|
+
case "tracking": {
|
|
111
|
+
// characters start spread out from the unit's centre and close in: a transform, so nothing reflows
|
|
112
|
+
const offset = (j - (n - 1) / 2) * 0.35 * (1 - e);
|
|
113
|
+
return { opacity: Math.min(1, 0.35 + e), transform: `translateX(${offset}em)` };
|
|
114
|
+
}
|
|
115
|
+
case "rise":
|
|
116
|
+
return { opacity: Math.min(1, 0.25 + e), transform: `translateY(${(1 - e) * 0.5}em)` };
|
|
117
|
+
case "pop":
|
|
118
|
+
default:
|
|
119
|
+
return { opacity: Math.min(1, 0.4 + e), transform: `scale(${1 + 0.6 * (1 - e)})` };
|
|
120
|
+
}
|
|
121
|
+
};
|
|
@@ -77,6 +77,12 @@ export type Highlight = { start: number; end: number };
|
|
|
77
77
|
/** A lower third: text from the user (options), timing in source seconds. */
|
|
78
78
|
export type LowerThird = { text: string; sub?: string; start: number; end: number };
|
|
79
79
|
export type Peak = { time: number; rms: number };
|
|
80
|
+
/** The KineticType schedule (analyze.py --kinetic): one line per caption cue, each unit (a word, or one CJK
|
|
81
|
+
* character) starting at a measured time -- its word's (by "words") or a beat's (by "beats"). gap: a space before
|
|
82
|
+
* the unit. The line shows from its first unit's start until `end`. */
|
|
83
|
+
export type KineticUnit = { text: string; gap: boolean; start: number };
|
|
84
|
+
export type KineticLine = { cue: number; start: number; end: number; units: KineticUnit[] };
|
|
85
|
+
export type Kinetic = { by: "words" | "beats"; step: number | null; lines: KineticLine[] };
|
|
80
86
|
export type Scene = { start: number; end: number };
|
|
81
87
|
|
|
82
88
|
export type Timeline = {
|
|
@@ -98,6 +104,8 @@ export type Timeline = {
|
|
|
98
104
|
/** Emphasised caption words (analyze.py --emphasis); drawn by the Emphasis composition. */
|
|
99
105
|
emphasis?: Emphasis[];
|
|
100
106
|
pip?: Pip | null;
|
|
107
|
+
/** The KineticType schedule (analyze.py --kinetic); absent or null otherwise. */
|
|
108
|
+
kinetic?: Kinetic | null;
|
|
101
109
|
/** Set by analyze.py --blank (a timeline with no footage); absent or null otherwise. */
|
|
102
110
|
blank?: Blank | null;
|
|
103
111
|
/** Set when analyze.py --conform measured a conformed copy instead of the original (null otherwise). */
|
|
@@ -148,6 +156,14 @@ export type Options = {
|
|
|
148
156
|
comments: CommentCard[];
|
|
149
157
|
/** The picture of a source-less run (analyze.py --blank): a CSS colour or gradient. */
|
|
150
158
|
background: string;
|
|
159
|
+
/** KineticType: how a unit enters -- scale pop, a mask wipe, tracking (letter-spacing closing in) or a rise. */
|
|
160
|
+
kineticStyle: "pop" | "wipe" | "tracking" | "rise";
|
|
161
|
+
/** KineticType: the whole unit enters at its start, or its characters one after another from that start. */
|
|
162
|
+
kineticReveal: "unit" | "char";
|
|
163
|
+
/** KineticType: seconds between characters with kineticReveal "char" (the first is at the unit's start). */
|
|
164
|
+
kineticStagger: number;
|
|
165
|
+
/** KineticType: text size as a fraction of the frame's short side. */
|
|
166
|
+
kineticSize: number;
|
|
151
167
|
};
|
|
152
168
|
|
|
153
169
|
export const DEFAULT_OPTIONS: Options = {
|
|
@@ -173,6 +189,10 @@ export const DEFAULT_OPTIONS: Options = {
|
|
|
173
189
|
bubbles: [],
|
|
174
190
|
comments: [],
|
|
175
191
|
background: "#000000",
|
|
192
|
+
kineticStyle: "pop",
|
|
193
|
+
kineticReveal: "char",
|
|
194
|
+
kineticStagger: 0.04,
|
|
195
|
+
kineticSize: 0.09,
|
|
176
196
|
};
|
|
177
197
|
|
|
178
198
|
/** Where the camera plays on the source timeline: [from, durationInFrames, trimBefore] in frames. */
|