remotion-ffmpeg-skill 0.14.5 → 0.15.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 +10 -2
- package/references/timeline.md +3 -0
- package/scripts/_common.py +19 -1
- package/scripts/analyze.py +223 -18
- package/scripts/pipeline.py +32 -7
- package/templates/remotion-project/src/compositions/BeatMontage.tsx +1 -1
- package/templates/remotion-project/src/compositions/Captioned.tsx +1 -1
- package/templates/remotion-project/src/compositions/Emphasis.tsx +1 -1
- package/templates/remotion-project/src/compositions/Highlights.tsx +1 -1
- package/templates/remotion-project/src/compositions/Jumpcut.tsx +1 -1
- package/templates/remotion-project/src/compositions/Karaoke.tsx +1 -1
- package/templates/remotion-project/src/compositions/PeakPulse.tsx +1 -1
- package/templates/remotion-project/src/compositions/Pip.tsx +1 -1
- package/templates/remotion-project/src/compositions/Titled.tsx +1 -1
- package/templates/remotion-project/src/lib/SourceVideo.tsx +13 -1
- package/templates/remotion-project/src/timeline.ts +16 -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
|
+
| "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 |
|
|
70
71
|
| "preview" / "show me a frame" | `still.py` |
|
|
71
72
|
| 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) |
|
|
72
73
|
| plain cut / trim / resize / loudness with no graphics | not this skill: use ffmpeg-skill directly |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remotion-ffmpeg-skill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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
|
@@ -19,7 +19,7 @@ Measure a source with ffmpeg-skill and write timeline.json (+ captions from a fi
|
|
|
19
19
|
|
|
20
20
|
| Argument | Type | Default | Meaning |
|
|
21
21
|
|---|---|---|---|
|
|
22
|
-
| `input` | string, repeatable | | source video (or audio) file; several are joined in order first |
|
|
22
|
+
| `input` | string, repeatable | | source video (or audio) file; several are joined in order first (with --blank: none, or `-`) |
|
|
23
23
|
| `--joined` | string | | with several inputs: where the joined source goes (default: <first>_joined.mp4) |
|
|
24
24
|
| `--join-transition` | string | `none` | with several inputs: ffmpeg-skill join.py --transition (default none = straight cuts) |
|
|
25
25
|
| `--join-duration` | number | `0.5` | transition length in seconds (default 0.5) |
|
|
@@ -35,6 +35,10 @@ Measure a source with ffmpeg-skill and write timeline.json (+ captions from a fi
|
|
|
35
35
|
| `--conform` | boolean | | a variable-frame-rate or HDR / BT.2020 source (or --pip camera) is first made into a constant-frame-rate, SDR BT.709 copy with ffmpeg-skill (fit.py --fps, color.py --to-sdr: tone-mapped, so the look changes) and everything is measured and drawn on that copy; the original is never modified. Without it such a source is refused |
|
|
36
36
|
| `--conformed` | string | | with --conform: where the conformed copy of the source goes (default: <name>_conformed.mp4) |
|
|
37
37
|
| `--conform-fps` | number | | with --conform: the constant frame rate for a VFR source (default: the stream's base rate, r_frame_rate, so no frame is dropped) |
|
|
38
|
+
| `--blank` | number | | a source-less run: a timeline of this many seconds with no footage (a plain background), so a composition draws from nothing. With --music the music plays under it and is measured for peaks (and --beats) as a source's audio is; no input file is given |
|
|
39
|
+
| `--size` | string | | with --blank: the frame size in px, even numbers (default 1920x1080) |
|
|
40
|
+
| `--fps` | string | | with --blank: the frame rate, e.g. 30, 25, 30000/1001 (default 30) |
|
|
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 |
|
|
38
42
|
| `--beats` | boolean | | also measure the beat grid (scenes.py --beats) |
|
|
39
43
|
| `--highlights` | integer | | also rank N highlight ranges (scenes.py --highlights; audio energy) for the Highlights composition |
|
|
40
44
|
| `--target` | number | | with --highlights: total length the picks add up to |
|
|
@@ -177,7 +181,7 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
|
177
181
|
|
|
178
182
|
| Argument | Type | Default | Meaning |
|
|
179
183
|
|---|---|---|---|
|
|
180
|
-
| `input` | string, repeatable | | source video; several are joined in order (ffmpeg-skill join.py) first |
|
|
184
|
+
| `input` | string, repeatable | | source video; several are joined in order (ffmpeg-skill join.py) first (with --blank: none, or `-`) |
|
|
181
185
|
| `--project (required)` | string | | Remotion project folder made by init.py |
|
|
182
186
|
| `--comp (required)` | string | | composition id (Captioned, Jumpcut, PeakPulse, Titled, Highlights, BeatMontage, Karaoke, Pip, Emphasis, or yours) |
|
|
183
187
|
| `--captions` | string | | SRT / WebVTT / JSON cues for the timeline |
|
|
@@ -187,6 +191,10 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
|
187
191
|
| `--platform` | string: youtube / youtube-shorts / shorts / reels / tiktok / x / facebook / linkedin / podcast / audiogram | | deliver with this ffmpeg-skill template and check it |
|
|
188
192
|
| `--out-dir` | string | | where the timeline, render and deliverable go (default: next to the input) |
|
|
189
193
|
| `--beats` | boolean | | measure the beat grid too |
|
|
194
|
+
| `--blank` | number | | no footage: draw the composition on a plain background this many seconds long (analyze.py --blank); give no input file |
|
|
195
|
+
| `--size` | string | | with --blank: frame size (default 1920x1080) |
|
|
196
|
+
| `--fps` | string | | with --blank: frame rate (default 30) |
|
|
197
|
+
| `--music` | string | | with --blank: music under it, measured for peaks and --beats |
|
|
190
198
|
| `--conform` | boolean | | a variable-frame-rate or HDR source is made into a constant-frame-rate, SDR BT.709 copy with ffmpeg-skill first (analyze.py --conform; the copy goes in --out-dir) and drawn on; without it such a source is refused |
|
|
191
199
|
| `--fast` | boolean | | preview-quality render |
|
|
192
200
|
| `--aspect` | string: source / 16:9 / 9:16 / 1:1 / 4:5 / 4:3 | | output shape (default: the shape the --platform template delivers, else the source's) |
|
package/references/timeline.md
CHANGED
|
@@ -17,6 +17,8 @@ props (`{ "timeline": ..., "options": ..., "frame": ..., "font": ..., "overlay":
|
|
|
17
17
|
| `source.fps` | number | probe.py | composition fps = source fps |
|
|
18
18
|
| `source.width` / `height` | px | probe.py | composition size = source size |
|
|
19
19
|
| `source.has_video` / `has_audio` | bool | probe.py | |
|
|
20
|
+
| `source.blank` | bool (optional) | analyze.py `--blank` | `true` for a source-less run: no footage, the picture is the `background` option; `source.path` is the music (or null), `has_video` false |
|
|
21
|
+
| `blank` | object \| null (optional) | analyze.py `--blank` | `{duration, width, height, fps, music}`: the caller's length, size and rate (not measurements) and the music's `{path, name, duration, fingerprint}` or null. The music's peaks, beats and silences fill `peaks`, `beats`, `silences` and `speech`, cut at the blank's end |
|
|
20
22
|
| `scenes` | `[{start, end}]` | scenes.py | shot boundaries (one scene = whole file when skipped) |
|
|
21
23
|
| `silences` | `[[start, end]]` | silence.py `--list` | measured silent gaps |
|
|
22
24
|
| `speech` | `[[start, end]]` | silence.py `--list` | ranges kept between silences (with margin) |
|
|
@@ -76,6 +78,7 @@ Every key is optional.
|
|
|
76
78
|
| `emphasisStyle` | `"pop"` | Emphasis: `pop` (scales up, accent colour), `color` (accent colour) or `box` (accent box, dark text) for an emphasised word without its own `style` |
|
|
77
79
|
| `bubbles` | `[]` | Emphasis: speech bubbles `[{"text", "start", "end", "side"?}]` (`side`: `left` or `right`), the user's text, seconds on the source timeline |
|
|
78
80
|
| `comments` | `[]` | Emphasis: comment-style cards `[{"text", "start", "end", "author"?}]`, top left, stacked while they overlap; the user's text |
|
|
81
|
+
| `background` | `"#000000"` | the picture of a source-less run (analyze.py `--blank`): any CSS colour or gradient |
|
|
79
82
|
| `chapterSeconds` | `4` | Titled: how long a chapter card stays up (cut short by the next chapter; 0 = none) |
|
|
80
83
|
|
|
81
84
|
Unknown keys and wrong types are refused by render.py / still.py before anything renders.
|
package/scripts/_common.py
CHANGED
|
@@ -674,7 +674,7 @@ _OPTION_TYPES: Dict[str, Any] = {
|
|
|
674
674
|
"progressBar": bool, "driver": str, "lowerThirds": list, "sceneTitles": list,
|
|
675
675
|
"title": (str, type(None)), "beatsPerCut": int, "chapterSeconds": (int, float),
|
|
676
676
|
"pipCorner": str, "pipSize": (int, float), "pipShape": str, "pipAudio": bool,
|
|
677
|
-
"emphasisStyle": str, "bubbles": list, "comments": list,
|
|
677
|
+
"emphasisStyle": str, "bubbles": list, "comments": list, "background": str,
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
|
|
@@ -727,5 +727,23 @@ def validate_options(o: Dict[str, Any]) -> List[str]:
|
|
|
727
727
|
return p
|
|
728
728
|
|
|
729
729
|
|
|
730
|
+
NO_INPUT = "-"
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
def parse_with_blank(parser: argparse.ArgumentParser, argv: Optional[List[str]] = None) -> argparse.Namespace:
|
|
734
|
+
"""Parse argv for analyze.py / pipeline.py. Their `input` takes one or more files (the contract's minItems 1);
|
|
735
|
+
a source-less run (--blank) has none: on the command line it may simply be left out, and `-` (NO_INPUT) is the
|
|
736
|
+
placeholder a caller that must send at least one item (an MCP client) gives instead. Either way the
|
|
737
|
+
namespace's `input` is then the real files only."""
|
|
738
|
+
argv = sys.argv[1:] if argv is None else list(argv)
|
|
739
|
+
if any(x == "--blank" or x.startswith("--blank=") for x in argv):
|
|
740
|
+
for act in parser._actions:
|
|
741
|
+
if act.dest == "input":
|
|
742
|
+
act.nargs = "*"
|
|
743
|
+
a = parser.parse_args(argv)
|
|
744
|
+
a.input = [i for i in (a.input or []) if i != NO_INPUT]
|
|
745
|
+
return a
|
|
746
|
+
|
|
747
|
+
|
|
730
748
|
def now() -> float:
|
|
731
749
|
return time.monotonic()
|
package/scripts/analyze.py
CHANGED
|
@@ -21,9 +21,11 @@ Examples:
|
|
|
21
21
|
python3 analyze.py talk.mp4 --words talk.transcript.json # captions from a transcription-skill transcript
|
|
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
|
+
python3 analyze.py --blank 15 --size 1080x1920 --music bgm.wav --beats # no footage: a 15 s blank timeline
|
|
24
25
|
"""
|
|
25
26
|
import argparse
|
|
26
27
|
import hashlib
|
|
28
|
+
import os
|
|
27
29
|
import shutil
|
|
28
30
|
import sys
|
|
29
31
|
import tempfile
|
|
@@ -34,7 +36,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
|
|
34
36
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
35
37
|
from _common import (STATE, TIMELINE_SCHEMA, SKILL_ID, add_common, apply_common, default_output, die,
|
|
36
38
|
emit, ffmpeg_skill_version, ffskill, ffskill_cmd, info, refuse_existing,
|
|
37
|
-
require_ffmpeg_skill, shell_join, stream_rate, version)
|
|
39
|
+
exact_rate, require_ffmpeg_skill, shell_join, stream_rate, version, parse_with_blank)
|
|
38
40
|
from _captions import (CaptionError, cues_from_words, parse_chapters, read_captions, read_emphasis,
|
|
39
41
|
read_word_timings, resolve_emphasis, youtube_chapter_warnings)
|
|
40
42
|
|
|
@@ -54,7 +56,8 @@ def file_fingerprint(path: Path) -> str:
|
|
|
54
56
|
def build_parser() -> argparse.ArgumentParser:
|
|
55
57
|
p = argparse.ArgumentParser(description=__doc__.split("\n\n")[0],
|
|
56
58
|
formatter_class=argparse.RawDescriptionHelpFormatter, epilog=__doc__)
|
|
57
|
-
p.add_argument("input", nargs="+", help="source video (or audio) file; several are joined in order first"
|
|
59
|
+
p.add_argument("input", nargs="+", help="source video (or audio) file; several are joined in order first "
|
|
60
|
+
"(with --blank: none, or `-`)")
|
|
58
61
|
p.add_argument("--joined", help="with several inputs: where the joined source goes (default: <first>_joined.mp4)")
|
|
59
62
|
p.add_argument("--join-transition", default="none",
|
|
60
63
|
help="with several inputs: ffmpeg-skill join.py --transition (default none = straight cuts)")
|
|
@@ -93,6 +96,16 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
93
96
|
p.add_argument("--conform-fps", type=float, metavar="FPS",
|
|
94
97
|
help="with --conform: the constant frame rate for a VFR source (default: the stream's base rate, "
|
|
95
98
|
"r_frame_rate, so no frame is dropped)")
|
|
99
|
+
p.add_argument("--blank", type=float, metavar="SECONDS",
|
|
100
|
+
help="a source-less run: a timeline of this many seconds with no footage (a plain background), "
|
|
101
|
+
"so a composition draws from nothing. With --music the music plays under it and is measured "
|
|
102
|
+
"for peaks (and --beats) as a source's audio is; no input file is given")
|
|
103
|
+
p.add_argument("--size", metavar="WxH", help="with --blank: the frame size in px, even numbers (default 1920x1080)")
|
|
104
|
+
p.add_argument("--fps", metavar="RATE", help="with --blank: the frame rate, e.g. 30, 25, 30000/1001 (default 30)")
|
|
105
|
+
p.add_argument("--music", metavar="FILE",
|
|
106
|
+
help="with --blank: the music (any file with an audio stream) that plays under the blank timeline "
|
|
107
|
+
"from 0 s; measured with ffmpeg-skill (scenes.py peaks and --beats, silence.py). Cut at the "
|
|
108
|
+
"blank's end when longer, silence after it when shorter")
|
|
96
109
|
p.add_argument("--beats", action="store_true", help="also measure the beat grid (scenes.py --beats)")
|
|
97
110
|
p.add_argument("--highlights", type=int, metavar="N",
|
|
98
111
|
help="also rank N highlight ranges (scenes.py --highlights; audio energy) for the Highlights composition")
|
|
@@ -272,25 +285,190 @@ def conform_source(label: str, src: Path, probe: Dict[str, Any], out: Path, fps:
|
|
|
272
285
|
return out, after, record
|
|
273
286
|
|
|
274
287
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
288
|
+
# ---------------------------------------------------------------- source-less runs (--blank)
|
|
289
|
+
|
|
290
|
+
BLANK_MAX_SECONDS = 24 * 3600.0
|
|
291
|
+
# Flags that only mean something with footage: refused with --blank instead of silently doing nothing.
|
|
292
|
+
BLANK_REFUSES = (("joined", "--joined"), ("pip", "--pip"), ("pip_offset", "--pip-offset"), ("conform", "--conform"),
|
|
293
|
+
("conformed", "--conformed"), ("conform_fps", "--conform-fps"), ("highlights", "--highlights"),
|
|
294
|
+
("target", "--target"))
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def parse_size(spec: Optional[str]) -> Tuple[int, int]:
|
|
298
|
+
"""`WxH` -> (W, H): positive even integers (H.264 needs even sides), at most 8192."""
|
|
299
|
+
if spec is None:
|
|
300
|
+
return 1920, 1080
|
|
301
|
+
parts = str(spec).lower().replace("×", "x").split("x")
|
|
302
|
+
try:
|
|
303
|
+
w, h = (int(x) for x in parts)
|
|
304
|
+
except ValueError:
|
|
305
|
+
die(f"--size must look like 1080x1920, got {spec!r}", "input")
|
|
306
|
+
if not (16 <= w <= 8192 and 16 <= h <= 8192) or w % 2 or h % 2:
|
|
307
|
+
die(f"--size {spec}: both sides must be even numbers between 16 and 8192 px", "input")
|
|
308
|
+
return w, h
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def parse_fps(spec: Optional[str]) -> float:
|
|
312
|
+
if spec is None:
|
|
313
|
+
return 30.0
|
|
314
|
+
r = exact_rate(spec)
|
|
315
|
+
if r is None or not 1 <= r <= 240:
|
|
316
|
+
die(f"--fps must be a frame rate between 1 and 240 (30, 25, 29.97, 30000/1001), got {spec!r}", "input")
|
|
317
|
+
return float(r)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def blank_flags_check(a: argparse.Namespace) -> None:
|
|
321
|
+
if a.blank is None:
|
|
322
|
+
given = [f for f, v in (("--size", a.size), ("--fps", a.fps), ("--music", a.music)) if v is not None]
|
|
323
|
+
if given:
|
|
324
|
+
die(f"{', '.join(given)} {'needs' if len(given) == 1 else 'need'} --blank SECONDS (a source's own size, rate and audio are measured)", "input")
|
|
325
|
+
if not a.input:
|
|
326
|
+
die("give an input file, or --blank SECONDS for a timeline with no footage", "input")
|
|
327
|
+
return
|
|
328
|
+
if a.input:
|
|
329
|
+
die("--blank makes a timeline with no footage: give no input file (the music goes in --music)", "input")
|
|
330
|
+
if not (0.001 <= a.blank <= BLANK_MAX_SECONDS):
|
|
331
|
+
die(f"--blank must be at least 0.001 and at most {BLANK_MAX_SECONDS:g} seconds, got {a.blank:g}", "input")
|
|
332
|
+
bad = [flag for dest, flag in BLANK_REFUSES if getattr(a, dest, None) not in (None, False)]
|
|
333
|
+
if a.chapters == "source":
|
|
334
|
+
bad.append("--chapters source")
|
|
335
|
+
if bad:
|
|
336
|
+
die(f"{', '.join(bad)} {'needs' if len(bad) == 1 else 'need'} footage; --blank has none", "input")
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def blank_main(a: argparse.Namespace) -> None:
|
|
340
|
+
"""A timeline with no footage: the given size, rate and length, and the music measured as a source's audio is."""
|
|
341
|
+
width, height = parse_size(a.size)
|
|
342
|
+
fps = parse_fps(a.fps)
|
|
343
|
+
duration = round(float(a.blank), 3)
|
|
344
|
+
music = Path(a.music).expanduser() if a.music else None
|
|
345
|
+
if music is not None and not music.is_file():
|
|
346
|
+
die(f"--music not found: {music}", "input")
|
|
347
|
+
if a.output:
|
|
348
|
+
out = Path(a.output).expanduser()
|
|
349
|
+
else:
|
|
350
|
+
out = default_output(music, "_blank.timeline", ".json") if music else Path("blank.timeline.json")
|
|
351
|
+
if music is not None and (out.resolve() == music.resolve() or (out.exists() and os.path.samefile(out, music))):
|
|
352
|
+
die(f"-o {out} is the --music file itself: the original is never overwritten", "input")
|
|
285
353
|
refuse_existing(out)
|
|
286
|
-
if (a.conformed or a.conform_fps is not None) and not a.conform:
|
|
287
|
-
die("--conformed / --conform-fps need --conform", "input")
|
|
288
|
-
if a.conform_fps is not None and not 0 < a.conform_fps <= 240:
|
|
289
|
-
die(f"--conform-fps must be between 0 and 240, got {a.conform_fps:g}", "input")
|
|
290
|
-
conformed: Path = (Path(a.conformed).expanduser() if a.conformed
|
|
291
|
-
else default_output(joined if len(inputs) > 1 else src, "_conformed", ".mp4"))
|
|
292
354
|
skill = require_ffmpeg_skill()
|
|
355
|
+
captions, words, transcript, emphasis, emphasis_warnings = read_text_inputs(a)
|
|
356
|
+
|
|
357
|
+
plan = []
|
|
358
|
+
if music is not None:
|
|
359
|
+
plan.append(shell_join(ffskill_cmd("probe", [str(music)])))
|
|
360
|
+
if not a.no_scenes:
|
|
361
|
+
plan.append(shell_join(ffskill_cmd("scenes", [str(music), *(["--beats"] if a.beats else [])])))
|
|
362
|
+
if not a.no_silence:
|
|
363
|
+
plan.append(shell_join(ffskill_cmd("silence", [str(music), *silence_args(a)])))
|
|
364
|
+
if STATE.dry_run:
|
|
365
|
+
emit({"output": str(out), "commands": plan}, f"would write {out} (blank {duration:g} s, {width}x{height} at "
|
|
366
|
+
f"{fps:g} fps{', music ' + music.name if music else ''}) after {len(plan)} ffmpeg-skill steps")
|
|
367
|
+
return
|
|
293
368
|
|
|
369
|
+
commands: List[str] = []
|
|
370
|
+
warnings: List[str] = []
|
|
371
|
+
peaks: List[Dict[str, float]] = []
|
|
372
|
+
beats: Any = None
|
|
373
|
+
silences: List[List[float]] = []
|
|
374
|
+
speech: List[List[float]] = [[0.0, duration]]
|
|
375
|
+
music_rec: Optional[Dict[str, Any]] = None
|
|
376
|
+
if music is not None:
|
|
377
|
+
pr = ffskill("probe", [str(music)])
|
|
378
|
+
commands.append(pr["_command"])
|
|
379
|
+
if not pr.get("audio"):
|
|
380
|
+
die(f"--music {music.name} has no audio stream", "input")
|
|
381
|
+
mdur = float((pr.get("audio") or {}).get("duration") or pr.get("duration") or 0)
|
|
382
|
+
if mdur <= 0:
|
|
383
|
+
die(f"--music {music.name} has no measurable duration", "input")
|
|
384
|
+
music_rec = {"path": str(music.resolve()), "name": music.name, "duration": round(mdur, 3),
|
|
385
|
+
"fingerprint": file_fingerprint(music)}
|
|
386
|
+
if mdur < duration - 0.05:
|
|
387
|
+
warnings.append(f"--music {music.name} is {mdur:.3f} s, the blank {duration:g} s: silence after "
|
|
388
|
+
f"{mdur:.3f} s")
|
|
389
|
+
elif mdur > duration + 0.05:
|
|
390
|
+
warnings.append(f"--music {music.name} is {mdur:.3f} s: cut at the blank's end ({duration:g} s)")
|
|
391
|
+
if not a.no_scenes:
|
|
392
|
+
# ffmpeg-skill 3.2.0 and later measure an audio-only file: peaks, and the beat grid with --beats.
|
|
393
|
+
sc = ffskill("scenes", [str(music), *(["--beats"] if a.beats else [])])
|
|
394
|
+
commands.append(sc["_command"])
|
|
395
|
+
peaks = [pk for pk in ({"time": round(float(p["time"]), 3), "rms": float(p.get("rms", 0))}
|
|
396
|
+
for p in sc.get("audio_peaks", [])) if pk["time"] < duration]
|
|
397
|
+
if a.beats:
|
|
398
|
+
grid = sc.get("beat_grid") or {}
|
|
399
|
+
times = [t for t in (round(float(b), 3) for b in (sc.get("beats") or [])) if t < duration]
|
|
400
|
+
beats = {"times": times, "tempo_bpm": grid.get("tempo_bpm"), "confidence": grid.get("confidence"),
|
|
401
|
+
"usable": bool(grid.get("usable")) and bool(times)}
|
|
402
|
+
if not a.no_silence:
|
|
403
|
+
si = ffskill("silence", [str(music), *silence_args(a)])
|
|
404
|
+
commands.append(si["_command"])
|
|
405
|
+
clip = lambda r: [round(min(float(r[0]), duration), 3), round(min(float(r[1]), duration), 3)] # noqa: E731
|
|
406
|
+
silences = [c for c in map(clip, si.get("silences", [])) if c[1] > c[0]]
|
|
407
|
+
if mdur < duration - 0.05:
|
|
408
|
+
silences.append([round(mdur, 3), duration])
|
|
409
|
+
speech = [c for c in map(clip, si.get("keep", [])) if c[1] > c[0]] or speech
|
|
410
|
+
|
|
411
|
+
if transcript:
|
|
412
|
+
ref = music_rec or {}
|
|
413
|
+
if not ref:
|
|
414
|
+
warnings.append("--words: a transcript with no --music: its times are used as written on the blank")
|
|
415
|
+
elif abs(transcript["duration"] - ref["duration"]) > TRANSCRIPT_DURATION_TOLERANCE:
|
|
416
|
+
die(f"--words: the transcript is of a {transcript['duration']:.3f} s file ({transcript['filename']}), "
|
|
417
|
+
f"the music measures {ref['duration']:.3f} s; transcribe this music", "input")
|
|
418
|
+
elif transcript["fingerprint"] != ref["fingerprint"]:
|
|
419
|
+
warnings.append(f"--words: the transcript was made from {transcript['filename']}, not these exact bytes "
|
|
420
|
+
"(same length, so its times are used as written)")
|
|
421
|
+
warnings += transcript["warnings"]
|
|
422
|
+
late = [c for c in captions if c["start"] >= duration]
|
|
423
|
+
if late:
|
|
424
|
+
warnings.append(f"{len(late)} caption cue(s) start at or after the blank's end ({duration:g} s) and never show")
|
|
425
|
+
|
|
426
|
+
chapters: List[Dict[str, Any]] = []
|
|
427
|
+
if a.chapters:
|
|
428
|
+
chpath = Path(a.chapters).expanduser()
|
|
429
|
+
if not chpath.is_file():
|
|
430
|
+
die(f"chapters file not found: {chpath}", "input")
|
|
431
|
+
try:
|
|
432
|
+
chapters = parse_chapters(chpath.read_text(encoding="utf-8-sig"), duration)
|
|
433
|
+
except CaptionError as e:
|
|
434
|
+
die(f"{chpath}: {e}", "input")
|
|
435
|
+
|
|
436
|
+
timeline: Dict[str, Any] = {
|
|
437
|
+
"schema": TIMELINE_SCHEMA,
|
|
438
|
+
"generator": {"name": SKILL_ID, "version": version(), "ffmpeg_skill": ffmpeg_skill_version(skill)},
|
|
439
|
+
# No footage: the picture is the composition's own background; the music (if any) is the source's audio.
|
|
440
|
+
"source": {"path": music_rec["path"] if music_rec else None,
|
|
441
|
+
"name": music.name if music else "blank", "duration": duration, "fps": fps,
|
|
442
|
+
"width": width, "height": height, "has_video": False, "has_audio": bool(music_rec),
|
|
443
|
+
"blank": True},
|
|
444
|
+
"blank": {"duration": duration, "width": width, "height": height, "fps": fps, "music": music_rec},
|
|
445
|
+
"scenes": [{"start": 0.0, "end": duration}],
|
|
446
|
+
"silences": silences, "speech": speech, "peaks": peaks, "beats": beats, "highlights": [], "clips": [],
|
|
447
|
+
"captions": captions, "words": words, "emphasis": emphasis, "chapters": chapters, "pip": None,
|
|
448
|
+
"conform": None,
|
|
449
|
+
"warnings": warnings + (youtube_chapter_warnings(chapters) if chapters else []) + emphasis_warnings,
|
|
450
|
+
}
|
|
451
|
+
for w in timeline["warnings"]:
|
|
452
|
+
info(f"warning: {w}")
|
|
453
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
454
|
+
import json
|
|
455
|
+
out.write_text(json.dumps(timeline, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
456
|
+
emit({"output": str(out), "commands": commands, "verified": True,
|
|
457
|
+
"summary": {"duration": duration, "fps": fps, "size": f"{width}x{height}", "scenes": 1,
|
|
458
|
+
"silences": len(silences), "speech_seconds": round(sum(e - s for s, e in speech), 3),
|
|
459
|
+
"peaks": len(peaks), "captions": len(captions), "chapters": len(chapters), "pip_offset": None,
|
|
460
|
+
"beats": bool(beats and beats.get("usable")), "tempo_bpm": (beats or {}).get("tempo_bpm"),
|
|
461
|
+
"highlights": 0, "clips": 1, "words": len(words), "emphasis": len(emphasis), "conformed": [],
|
|
462
|
+
"blank": True, "music": music.name if music else None},
|
|
463
|
+
"warnings": timeline["warnings"]},
|
|
464
|
+
f"wrote {out}: blank {duration:g} s, {width}x{height} at {fps:g} fps, "
|
|
465
|
+
+ (f"music {music.name} ({len(peaks)} peaks" + (f", {len((beats or {}).get('times') or [])} beats" if beats else "")
|
|
466
|
+
+ ")" if music else "no music") + f", {len(captions)} captions")
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def read_text_inputs(a: argparse.Namespace) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]], Optional[Dict[str, Any]],
|
|
470
|
+
List[Dict[str, Any]], List[str]]:
|
|
471
|
+
"""--captions, --words and --emphasis: (captions, words, transcript or None, emphasis, emphasis warnings)."""
|
|
294
472
|
captions: List[Dict[str, Any]] = []
|
|
295
473
|
if a.captions:
|
|
296
474
|
cpath = Path(a.captions).expanduser()
|
|
@@ -336,6 +514,33 @@ def main() -> None:
|
|
|
336
514
|
emphasis, emphasis_warnings = resolve_emphasis(captions, words, entries, auto)
|
|
337
515
|
except (CaptionError, ValueError) as e:
|
|
338
516
|
die(f"--emphasis: {e}", "input")
|
|
517
|
+
return captions, words, transcript, emphasis, emphasis_warnings
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def main() -> None:
|
|
521
|
+
a = parse_with_blank(build_parser())
|
|
522
|
+
apply_common(a)
|
|
523
|
+
blank_flags_check(a)
|
|
524
|
+
if a.blank is not None:
|
|
525
|
+
blank_main(a)
|
|
526
|
+
return
|
|
527
|
+
inputs = [Path(i).expanduser() for i in a.input]
|
|
528
|
+
missing = [str(i) for i in inputs if not i.is_file()]
|
|
529
|
+
if missing:
|
|
530
|
+
die(f"input not found: {', '.join(missing)}", "input")
|
|
531
|
+
src = inputs[0]
|
|
532
|
+
joined: Path = Path(a.joined).expanduser() if a.joined else default_output(src, "_joined", ".mp4")
|
|
533
|
+
out = Path(a.output) if a.output else default_output(joined if len(inputs) > 1 else src, ".timeline", ".json")
|
|
534
|
+
refuse_existing(out)
|
|
535
|
+
if (a.conformed or a.conform_fps is not None) and not a.conform:
|
|
536
|
+
die("--conformed / --conform-fps need --conform", "input")
|
|
537
|
+
if a.conform_fps is not None and not 0 < a.conform_fps <= 240:
|
|
538
|
+
die(f"--conform-fps must be between 0 and 240, got {a.conform_fps:g}", "input")
|
|
539
|
+
conformed: Path = (Path(a.conformed).expanduser() if a.conformed
|
|
540
|
+
else default_output(joined if len(inputs) > 1 else src, "_conformed", ".mp4"))
|
|
541
|
+
skill = require_ffmpeg_skill()
|
|
542
|
+
|
|
543
|
+
captions, words, transcript, emphasis, emphasis_warnings = read_text_inputs(a)
|
|
339
544
|
|
|
340
545
|
join_args = [*map(str, inputs), "-o", str(joined), "--transition", a.join_transition,
|
|
341
546
|
"--duration", str(a.join_duration)] + (["--overwrite"] if STATE.overwrite else [])
|
package/scripts/pipeline.py
CHANGED
|
@@ -7,6 +7,7 @@ Examples:
|
|
|
7
7
|
python3 pipeline.py talk.mp4 --project ./motion --comp Jumpcut --captions talk.srt --platform youtube
|
|
8
8
|
python3 pipeline.py clip.mp4 --project ./motion --comp PeakPulse --platform reels --out-dir out/
|
|
9
9
|
python3 pipeline.py talk.mp4 --project ./motion --comp Captioned --captions talk.srt # no delivery step
|
|
10
|
+
python3 pipeline.py --blank 15 --size 1080x1920 --music bgm.wav --project ./motion --comp PeakPulse # no footage
|
|
10
11
|
"""
|
|
11
12
|
import argparse
|
|
12
13
|
import json
|
|
@@ -17,14 +18,15 @@ from typing import Any, Dict, List
|
|
|
17
18
|
|
|
18
19
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
19
20
|
from _common import (ASPECTS, BUILTIN_COMPOSITIONS, FITS, HERE, STATE, add_common, apply_common, die, emit, info,
|
|
20
|
-
platform_aspect, shell_join)
|
|
21
|
+
platform_aspect, shell_join, parse_with_blank)
|
|
21
22
|
from deliver import PLATFORMS
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
def build_parser() -> argparse.ArgumentParser:
|
|
25
26
|
p = argparse.ArgumentParser(description=__doc__.split("\n\n")[0],
|
|
26
27
|
formatter_class=argparse.RawDescriptionHelpFormatter, epilog=__doc__)
|
|
27
|
-
p.add_argument("input", nargs="+", help="source video; several are joined in order (ffmpeg-skill join.py) first"
|
|
28
|
+
p.add_argument("input", nargs="+", help="source video; several are joined in order (ffmpeg-skill join.py) first "
|
|
29
|
+
"(with --blank: none, or `-`)")
|
|
28
30
|
p.add_argument("--project", required=True, help="Remotion project folder made by init.py")
|
|
29
31
|
p.add_argument("--comp", required=True, help=f"composition id ({', '.join(BUILTIN_COMPOSITIONS)}, or yours)")
|
|
30
32
|
p.add_argument("--captions", help="SRT / WebVTT / JSON cues for the timeline")
|
|
@@ -36,6 +38,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
36
38
|
p.add_argument("--platform", choices=PLATFORMS, help="deliver with this ffmpeg-skill template and check it")
|
|
37
39
|
p.add_argument("--out-dir", help="where the timeline, render and deliverable go (default: next to the input)")
|
|
38
40
|
p.add_argument("--beats", action="store_true", help="measure the beat grid too")
|
|
41
|
+
p.add_argument("--blank", type=float, metavar="SECONDS",
|
|
42
|
+
help="no footage: draw the composition on a plain background this many seconds long "
|
|
43
|
+
"(analyze.py --blank); give no input file")
|
|
44
|
+
p.add_argument("--size", metavar="WxH", help="with --blank: frame size (default 1920x1080)")
|
|
45
|
+
p.add_argument("--fps", metavar="RATE", help="with --blank: frame rate (default 30)")
|
|
46
|
+
p.add_argument("--music", metavar="FILE", help="with --blank: music under it, measured for peaks and --beats")
|
|
39
47
|
p.add_argument("--conform", action="store_true",
|
|
40
48
|
help="a variable-frame-rate or HDR source is made into a constant-frame-rate, SDR BT.709 copy "
|
|
41
49
|
"with ffmpeg-skill first (analyze.py --conform; the copy goes in --out-dir) and drawn on; "
|
|
@@ -71,22 +79,39 @@ def step(name: str, script: str, args: List[str], steps: List[Dict[str, Any]]) -
|
|
|
71
79
|
|
|
72
80
|
|
|
73
81
|
def main() -> None:
|
|
74
|
-
a = build_parser()
|
|
82
|
+
a = parse_with_blank(build_parser())
|
|
75
83
|
apply_common(a)
|
|
76
84
|
inputs = [Path(i).expanduser() for i in a.input]
|
|
77
85
|
missing = [str(i) for i in inputs if not i.is_file()]
|
|
78
86
|
if missing:
|
|
79
87
|
die(f"input not found: {', '.join(missing)}", "input")
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
if a.blank is None and not inputs:
|
|
89
|
+
die("give an input file, or --blank SECONDS for a run with no footage", "input")
|
|
90
|
+
if a.blank is not None and inputs:
|
|
91
|
+
die("--blank makes a run with no footage: give no input file (the music goes in --music)", "input")
|
|
92
|
+
if a.blank is None:
|
|
93
|
+
given = [f for f, v in (("--size", a.size), ("--fps", a.fps), ("--music", a.music)) if v is not None]
|
|
94
|
+
if given:
|
|
95
|
+
die(f"{', '.join(given)} {'needs' if len(given) == 1 else 'need'} --blank SECONDS", "input")
|
|
96
|
+
blank_args: List[str] = []
|
|
97
|
+
if a.blank is not None:
|
|
98
|
+
music = Path(a.music).expanduser() if a.music else None
|
|
99
|
+
blank_args = ["--blank", repr(a.blank)] + [x for flag, v in (("--size", a.size), ("--fps", a.fps),
|
|
100
|
+
("--music", a.music)) if v for x in (flag, v)]
|
|
101
|
+
out_dir = Path(a.out_dir).expanduser() if a.out_dir else (music.parent if music else Path.cwd())
|
|
102
|
+
stem = f"{music.stem}_blank" if music else "blank"
|
|
103
|
+
else:
|
|
104
|
+
src = inputs[0]
|
|
105
|
+
out_dir = Path(a.out_dir).expanduser() if a.out_dir else src.parent
|
|
106
|
+
stem = src.stem + ("_joined" if len(inputs) > 1 else "")
|
|
82
107
|
if not STATE.dry_run:
|
|
83
108
|
out_dir.mkdir(parents=True, exist_ok=True)
|
|
84
|
-
stem = src.stem + ("_joined" if len(inputs) > 1 else "")
|
|
85
109
|
tl = out_dir / f"{stem}.timeline.json"
|
|
86
110
|
render_out = out_dir / f"{stem}_{a.comp}.mp4"
|
|
87
111
|
steps: List[Dict[str, Any]] = []
|
|
88
112
|
|
|
89
|
-
an_args = [*map(str, inputs), "-o", str(tl)]
|
|
113
|
+
an_args = [*map(str, inputs), *blank_args, "-o", str(tl)]
|
|
114
|
+
an_args += ["--joined", str(out_dir / f"{stem}.mp4")] if len(inputs) > 1 else []
|
|
90
115
|
an_args += (["--captions", a.captions] if a.captions else []) + (["--beats"] if a.beats else [])
|
|
91
116
|
an_args += ["--chapters", a.chapters] if a.chapters else []
|
|
92
117
|
an_args += ["--conform", "--conformed", str(out_dir / f"{stem}_conformed.mp4")] if a.conform else []
|
|
@@ -40,7 +40,7 @@ export const BeatMontage: React.FC<Props> = (props) => {
|
|
|
40
40
|
const src = { ...timeline.source, has_audio: false };
|
|
41
41
|
return (
|
|
42
42
|
<Sequence key={i} from={from} durationInFrames={len} name={`shot ${i + 1}`}>
|
|
43
|
-
<SourceVideo source={src} fit={fit} trimBefore={start} trimAfter={start + len} />
|
|
43
|
+
<SourceVideo background={o.background} source={src} fit={fit} trimBefore={start} trimAfter={start + len} />
|
|
44
44
|
{i > 0 ? <BeatFlash accent={o.accent} /> : null}
|
|
45
45
|
</Sequence>
|
|
46
46
|
);
|
|
@@ -16,7 +16,7 @@ export const Captioned: React.FC<Props> = (props) => {
|
|
|
16
16
|
const { fps } = useVideoConfig();
|
|
17
17
|
return (
|
|
18
18
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
19
|
-
{overlay ? null : <SourceVideo source={timeline.source} fit={outputFrame(props).fit} />}
|
|
19
|
+
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
20
20
|
{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);
|
|
@@ -39,7 +39,7 @@ export const Emphasis: React.FC<Props> = (props) => {
|
|
|
39
39
|
});
|
|
40
40
|
return (
|
|
41
41
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
42
|
-
{overlay ? null : <SourceVideo source={timeline.source} fit={outputFrame(props).fit} />}
|
|
42
|
+
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
43
43
|
{timeline.captions.map((c, i) => {
|
|
44
44
|
const from = secToFrames(c.start, fps);
|
|
45
45
|
const dur = Math.max(1, secToFrames(c.end, fps) - from);
|
|
@@ -25,7 +25,7 @@ export const Highlights: React.FC<Props> = (props) => {
|
|
|
25
25
|
const len = Math.max(1, secToFrames(e, fps) - a);
|
|
26
26
|
return (
|
|
27
27
|
<Series.Sequence key={i} durationInFrames={len} name={`highlight ${i + 1}`}>
|
|
28
|
-
<SourceVideo source={timeline.source} fit={fit} trimBefore={a} trimAfter={a + len} />
|
|
28
|
+
<SourceVideo background={o.background} source={timeline.source} fit={fit} trimBefore={a} trimAfter={a + len} />
|
|
29
29
|
{i > 0 ? <CutFlash /> : null}
|
|
30
30
|
<Counter index={i} total={ranges.length} o={o} fontFamily={family} />
|
|
31
31
|
{i === 0 && o.title ? <Title text={o.title} len={len} o={o} fontFamily={family} /> : null}
|
|
@@ -29,7 +29,7 @@ export const Jumpcut: React.FC<Props> = (props) => {
|
|
|
29
29
|
return (
|
|
30
30
|
<Series.Sequence key={i} durationInFrames={len} name={`cut ${i + 1}`}>
|
|
31
31
|
<Punch zoom={zoom} len={len}>
|
|
32
|
-
<SourceVideo source={timeline.source} fit={fit} trimBefore={a} trimAfter={a + len} />
|
|
32
|
+
<SourceVideo background={o.background} source={timeline.source} fit={fit} trimBefore={a} trimAfter={a + len} />
|
|
33
33
|
</Punch>
|
|
34
34
|
</Series.Sequence>
|
|
35
35
|
);
|
|
@@ -19,7 +19,7 @@ export const Karaoke: React.FC<Props> = (props) => {
|
|
|
19
19
|
const words = timeline.words ?? [];
|
|
20
20
|
return (
|
|
21
21
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
22
|
-
{overlay ? null : <SourceVideo source={timeline.source} fit={outputFrame(props).fit} />}
|
|
22
|
+
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
23
23
|
{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);
|
|
@@ -45,7 +45,7 @@ export const PeakPulse: React.FC<Props> = (props) => {
|
|
|
45
45
|
return (
|
|
46
46
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
47
47
|
{/* In overlay mode the source (and its slight zoom on peaks) is left to the composite step. */}
|
|
48
|
-
{overlay ? null : <SourceVideo source={timeline.source} fit={outputFrame(props).fit} style={{ transform: `scale(${1 + 0.02 * o.pulse * hit})` }} />}
|
|
48
|
+
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} style={{ transform: `scale(${1 + 0.02 * o.pulse * hit})` }} />}
|
|
49
49
|
<AbsoluteFill style={{ boxShadow: `inset 0 0 ${glow * 2}px ${glow}px ${o.accent}`, opacity: 0.85, pointerEvents: "none" }} />
|
|
50
50
|
{flash > 0 ? <AbsoluteFill style={{ backgroundColor: "white", opacity: 0.18 * flash }} /> : null}
|
|
51
51
|
{o.progressBar ? (
|
|
@@ -38,7 +38,7 @@ export const Pip: React.FC<Props> = (props) => {
|
|
|
38
38
|
const [from, dur, trimBefore] = pip ? pipFrames(pip, fps, durationInFrames) : [0, 1, 0];
|
|
39
39
|
return (
|
|
40
40
|
<AbsoluteFill style={{ backgroundColor: "black" }}>
|
|
41
|
-
<SourceVideo source={timeline.source} fit={outputFrame(props).fit} />
|
|
41
|
+
<SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />
|
|
42
42
|
{pip && pip.src ? (
|
|
43
43
|
<Sequence from={from} durationInFrames={dur} name="camera" layout="none">
|
|
44
44
|
<div style={box}>
|
|
@@ -21,7 +21,7 @@ export const Titled: React.FC<Props> = (props) => {
|
|
|
21
21
|
.filter((x): x is { sc: { start: number; end: number }; text: string } => Boolean(x.text));
|
|
22
22
|
return (
|
|
23
23
|
<AbsoluteFill style={{ backgroundColor: overlay ? "transparent" : "black" }}>
|
|
24
|
-
{overlay ? null : <SourceVideo source={timeline.source} fit={outputFrame(props).fit} />}
|
|
24
|
+
{overlay ? null : <SourceVideo background={o.background} source={timeline.source} fit={outputFrame(props).fit} />}
|
|
25
25
|
{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);
|
|
@@ -11,15 +11,27 @@ type Props = {
|
|
|
11
11
|
/** Source frame to stop at. */
|
|
12
12
|
trimAfter?: number;
|
|
13
13
|
style?: React.CSSProperties;
|
|
14
|
+
/** The picture of a blank source (analyze.py --blank): options.background. */
|
|
15
|
+
background?: string;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* The measured source as the bottom layer.
|
|
18
20
|
* - video: OffthreadVideo, placed by `fit` (contain / cover / blur)
|
|
19
21
|
* - audio only: a neutral placeholder picture with the audio playing under it
|
|
22
|
+
* - blank (analyze.py --blank): the background, with the music (if any) playing under it
|
|
20
23
|
* - nothing staged: the placeholder alone (Studio previews)
|
|
21
24
|
*/
|
|
22
|
-
export const SourceVideo: React.FC<Props> = ({ source, fit = "contain", trimBefore, trimAfter, style }) => {
|
|
25
|
+
export const SourceVideo: React.FC<Props> = ({ source, fit = "contain", trimBefore, trimAfter, style, background }) => {
|
|
26
|
+
if (source.blank) {
|
|
27
|
+
return (
|
|
28
|
+
<AbsoluteFill style={{ ...style, background: background ?? "#000000" }}>
|
|
29
|
+
{source.src && source.has_audio ? (
|
|
30
|
+
<Audio src={staticFile(source.src)} trimBefore={trimBefore} trimAfter={trimAfter} />
|
|
31
|
+
) : null}
|
|
32
|
+
</AbsoluteFill>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
23
35
|
if (!source.src) {
|
|
24
36
|
return <Placeholder label={source.name} />;
|
|
25
37
|
}
|
|
@@ -15,6 +15,17 @@ export type Source = {
|
|
|
15
15
|
height: number;
|
|
16
16
|
has_video: boolean;
|
|
17
17
|
has_audio: boolean;
|
|
18
|
+
/** analyze.py --blank: no footage. The picture is options.background; src (if any) is the music. */
|
|
19
|
+
blank?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** A source-less run (analyze.py --blank): the asked size, rate and length, and the music measured (or null). */
|
|
23
|
+
export type Blank = {
|
|
24
|
+
duration: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
fps: number;
|
|
28
|
+
music: { path: string; name: string; duration: number; fingerprint: string } | null;
|
|
18
29
|
};
|
|
19
30
|
|
|
20
31
|
export type Caption = { start: number; end: number; text: string };
|
|
@@ -87,6 +98,8 @@ export type Timeline = {
|
|
|
87
98
|
/** Emphasised caption words (analyze.py --emphasis); drawn by the Emphasis composition. */
|
|
88
99
|
emphasis?: Emphasis[];
|
|
89
100
|
pip?: Pip | null;
|
|
101
|
+
/** Set by analyze.py --blank (a timeline with no footage); absent or null otherwise. */
|
|
102
|
+
blank?: Blank | null;
|
|
90
103
|
/** Set when analyze.py --conform measured a conformed copy instead of the original (null otherwise). */
|
|
91
104
|
conform?: Conform | null;
|
|
92
105
|
warnings?: string[];
|
|
@@ -133,6 +146,8 @@ export type Options = {
|
|
|
133
146
|
bubbles: Bubble[];
|
|
134
147
|
/** Emphasis: comment-style cards (text and author from the user). */
|
|
135
148
|
comments: CommentCard[];
|
|
149
|
+
/** The picture of a source-less run (analyze.py --blank): a CSS colour or gradient. */
|
|
150
|
+
background: string;
|
|
136
151
|
};
|
|
137
152
|
|
|
138
153
|
export const DEFAULT_OPTIONS: Options = {
|
|
@@ -157,6 +172,7 @@ export const DEFAULT_OPTIONS: Options = {
|
|
|
157
172
|
emphasisStyle: "pop",
|
|
158
173
|
bubbles: [],
|
|
159
174
|
comments: [],
|
|
175
|
+
background: "#000000",
|
|
160
176
|
};
|
|
161
177
|
|
|
162
178
|
/** Where the camera plays on the source timeline: [from, durationInFrames, trimBefore] in frames. */
|