remotion-ffmpeg-skill 0.4.0 → 0.6.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/README.md +12 -3
- package/SKILL.md +14 -1
- package/package.json +40 -7
- package/references/scripts.md +34 -2
- package/scripts/_contract.py +65 -1
- package/scripts/_docs.py +10 -1
- package/scripts/_sparse.py +87 -0
- package/scripts/deliver.py +4 -1
- package/scripts/render.py +79 -4
- package/templates/remotion-project/src/compositions/Karaoke.tsx +3 -1
package/README.md
CHANGED
|
@@ -8,7 +8,14 @@ Built on [**ffmpeg-skill**](https://github.com/kajisho5/ffmpeg-skill). Unofficia
|
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
-
<sub>Fictional demo footage.
|
|
11
|
+
<sub>Fictional demo footage. ffmpeg-skill measured two silences and a scene cut; Remotion played only the speech ranges with punch-in zooms and re-timed captions; render.py verified 201 of 201 frames.</sub>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<tr>
|
|
15
|
+
<td width="62%"><img src="assets/demo-karaoke.gif" alt="Karaoke: each word lights up at the time a speech engine measured"><br><sub><b>Karaoke</b> — words light up at their measured times (250 / 250 frames verified)</sub></td>
|
|
16
|
+
<td width="38%"><img src="assets/demo-portrait-ja.gif" alt="9:16 jump cut with Japanese captions on a blurred fill"><br><sub><b>9:16 + Japanese</b> — silences cut, CJK font staged automatically, phrase-based line breaks</sub></td>
|
|
17
|
+
</tr>
|
|
18
|
+
</table>
|
|
12
19
|
|
|
13
20
|
## Why this and not just Remotion's own skills?
|
|
14
21
|
|
|
@@ -109,10 +116,12 @@ This skill is MIT. **Remotion itself has its own licence**: free for individuals
|
|
|
109
116
|
|
|
110
117
|
Remotion renders in a headless browser. Measured on a 2-core Linux machine: a 30 s 1080p30 render takes about 80 s (≈ 2.6× the clip length) with render.py's default of all CPU cores — Remotion's own default (half the cores) took 170 s. More cores scale it further. Check with `still.py` and `--fast` before a full render of long footage.
|
|
111
118
|
|
|
119
|
+
**`--sparse`** (Captioned, Karaoke): only the frames that show a caption are drawn; ffmpeg-skill places each stretch back at its time over the untouched source. Same picture frame for frame (checked by an integration test), and the render time follows the captioned share of the footage: 60 s with 7 s of captions took 46 s instead of 152 s. Needs an ffmpeg-skill whose `overlay.py` has `--place`; otherwise it draws the full layer and says why.
|
|
120
|
+
|
|
112
121
|
## Agent evals
|
|
113
122
|
|
|
114
|
-
Plain requests ("captions for YouTube", a Japanese Reels jump cut, "cut to the beat", a lower third without a name, a plain trim that is *not* this skill's job, a square highlight reel), run by an agent that only has the skill files, graded on what it leaves behind — plus a transparent layer for an editor, joining clips with titles, and karaoke from word timings: **9 / 9** ([run 1](evals/results/2026-10-24.md), [run 2](evals/results/2026-10-24b.md), [how to run](evals/README.md)).
|
|
123
|
+
Plain requests ("captions for YouTube", a Japanese Reels jump cut, "cut to the beat", a lower third without a name, a plain trim that is *not* this skill's job, a square highlight reel), run by an agent that only has the skill files, graded on what it leaves behind — plus a transparent layer for an editor, joining clips with titles, and karaoke from word timings: **9 / 9** ([run 1](evals/results/2026-10-24.md), [run 2](evals/results/2026-10-24b.md), [how to run](evals/README.md)). A third run with a neutral prompt (both skills installed, no hint) went to ffmpeg-skill alone for three requests it can finish by itself — 6 / 9 by the original checks, 9 / 9 once that route is accepted ([run 3](evals/results/2026-10-24c.md)).
|
|
115
124
|
|
|
116
125
|
## Status
|
|
117
126
|
|
|
118
|
-
0.
|
|
127
|
+
0.5. CI renders every composition on Linux, macOS and Windows (Node 22, Remotion 4.0.538, ffmpeg-skill main).
|
package/SKILL.md
CHANGED
|
@@ -20,6 +20,7 @@ Shared flags (every script): `--json` (one JSON object on stdout; prefer it), `-
|
|
|
20
20
|
- **Shape:** draw in the shape it will be delivered in. `--aspect 9:16` for Reels / TikTok / Shorts (`1:1`, `4:5`, `16:9` too); `--fit blur` (default when the shape changes: contained over a blurred copy), `contain` (bars) or `cover` (crop — check the subject in the still first). Never render 16:9 and let a 9:16 template crop it: captions lose their edges. `pipeline.py --platform` picks the aspect from ffmpeg-skill's template for you.
|
|
21
21
|
- **Fonts:** Japanese / Chinese / Korean captions get the CJK font ffmpeg-skill finds on the machine automatically (staged into the project, so no tofu); `--font-file F.ttf` uses a specific font; the report line `font:` says which was used, or that none was found.
|
|
22
22
|
- **Editing-app layer:** `--overlay --keep-graphics` (Captioned / PeakPulse, source shape) draws the graphics alone as a transparent ProRes 4444 `.graphics.mov` and composites it over the untouched source with ffmpeg-skill `overlay.py`; hand the `.mov` to someone finishing in Premiere / Resolve / Final Cut. It is not faster than a normal render.
|
|
23
|
+
- **Long footage with gaps between captions:** `--sparse` (Captioned / Karaoke) draws only the frames where a caption shows and places each stretch back at its time with ffmpeg-skill `overlay.py --place` — same picture, frame for frame. It needs an ffmpeg-skill with `--place`; without it (or when the source does not start at 0) it draws the full layer and says why in `sparse.reason`.
|
|
23
24
|
5. **Deliver.** `deliver.py OUT.mp4 --platform youtube|reels|tiktok|shorts|x|...` runs ffmpeg-skill's delivery template and its `check.py` table. Format rows are safe to fix; judgement rows (duration, aspect) change content — ask. Mention WARNs, don't chase them. No destination named: skip this step and say so.
|
|
24
25
|
6. **Look.** Not finished until the reply names the contact sheet render.py wrote (`Look: PATH`) and says what it shows. Mechanical (check and report): text is where it was asked, cues appear at their times, nothing is cut off by the frame. Judgement (say what you see, the user decides): text over a face, a jump that lands badly. No image view: `Look: PATH (pixels not inspected)` — never claim you looked. No contact sheet (`look_error` in the result, e.g. an FFmpeg without `drawtext`): look at `still.py` frames instead and pass on the fix the error names.
|
|
25
26
|
|
|
@@ -29,6 +30,17 @@ MCP: `mcp/server.py` exposes the same tools (schemas from `scripts/_contract.py`
|
|
|
29
30
|
|
|
30
31
|
Everything in one go: `pipeline.py SOURCE --project ./motion --comp NAME [--captions F] [--platform P]` runs 2→4→5 with the same checks and stops at the first failed step.
|
|
31
32
|
|
|
33
|
+
## This skill or ffmpeg-skill alone?
|
|
34
|
+
|
|
35
|
+
ffmpeg-skill by itself already does silence cuts, burned-in (also pop / karaoke) captions, title and lower-third templates, joins and platform templates, without a browser render. For a request that fits those, ffmpeg-skill alone is a valid and faster answer. Choose this skill when the request needs something ffmpeg-skill does not draw:
|
|
36
|
+
|
|
37
|
+
- motion tied to measurements: punch-in zooms on jump cuts, pulses on peaks or beats, picture cuts on a beat grid, a highlight counter;
|
|
38
|
+
- a different shape **without losing picture**: ffmpeg-skill's Reels / TikTok / Shorts templates centre-crop a 16:9 source (`fit: crop`), so the sides are cut off; `--aspect 9:16 --fit blur` keeps the whole frame;
|
|
39
|
+
- the graphics as a separate transparent layer for an editor (`--overlay --keep-graphics`);
|
|
40
|
+
- a custom React composition, or the user asks for Remotion.
|
|
41
|
+
|
|
42
|
+
Whichever you choose, say which one and the trade-off that matters (for example "centre-cropped: the left and right edges are gone").
|
|
43
|
+
|
|
32
44
|
## Request → script / composition
|
|
33
45
|
|
|
34
46
|
| Request | Run |
|
|
@@ -44,6 +56,7 @@ Everything in one go: `pipeline.py SOURCE --project ./motion --comp NAME [--capt
|
|
|
44
56
|
| "vertical / 9:16 / square" | `render.py --aspect 9:16` (or `1:1`, `4:5`) |
|
|
45
57
|
| "Japanese captions" / a specific font | nothing extra for CJK (auto font); `--font-file` for a chosen font |
|
|
46
58
|
| "give me the graphics as a separate layer" | `render.py --overlay --keep-graphics` |
|
|
59
|
+
| captions on long footage (a talk, a lecture) | `render.py --comp Captioned --sparse` (or `Karaoke`): only the captioned stretches are drawn |
|
|
47
60
|
| "change colour / font / caption size / zoom" | an `--options` JSON (`references/timeline.md`), re-render |
|
|
48
61
|
| 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 |
|
|
49
62
|
| "preview" / "show me a frame" | `still.py` |
|
|
@@ -62,6 +75,6 @@ Everything in one go: `pipeline.py SOURCE --project ./motion --comp NAME [--capt
|
|
|
62
75
|
- Remotion licence: free for individuals and for-profit organisations with up to 3 employees; larger companies need a Remotion company licence (https://www.remotion.dev/license). If the user is plainly a larger company, say so once.
|
|
63
76
|
- Keep the user's originals: sources are linked into `public/media/` of the project, never modified; outputs never overwrite an existing file without `--overwrite`.
|
|
64
77
|
- CJK captions: the auto font comes from ffmpeg-skill's font detection; when the report says no font was found, install one (Noto Sans CJK) or pass `--font-file` — tofu in the contact sheet is a failed job. Japanese lines break between phrases, not inside words.
|
|
65
|
-
- Speed (measured on a 2-core Linux machine, all cores — render.py's default): about 2.6× the clip length for 1080p30 (30 s took 80 s). Preview with `still.py` and `--fast` before a full render of long footage; tell the user the expected time before starting a long render. `--concurrency` above the core count is refused by Remotion.
|
|
78
|
+
- Speed (measured on a 2-core Linux machine, all cores — render.py's default): about 2.6× the clip length for 1080p30 (30 s took 80 s). Preview with `still.py` and `--fast` before a full render of long footage; tell the user the expected time before starting a long render. `--sparse` cuts that to the captioned share: 60 s with 7 s of captions went from 152 s to 46 s. `--concurrency` above the core count is refused by Remotion.
|
|
66
79
|
- Remotion packages in a project must all be the same version; the template pins them. Don't mix in a different `remotion` version.
|
|
67
80
|
- A render that fails verification is a failure: report the failed rows from `--json`, don't ship it.
|
package/package.json
CHANGED
|
@@ -1,14 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remotion-ffmpeg-skill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"remotion",
|
|
7
|
+
"ffmpeg",
|
|
8
|
+
"ffmpeg-skill",
|
|
9
|
+
"video",
|
|
10
|
+
"motion-graphics",
|
|
11
|
+
"captions",
|
|
12
|
+
"agent-skill",
|
|
13
|
+
"agent-skills",
|
|
14
|
+
"claude-code",
|
|
15
|
+
"claude-skill",
|
|
16
|
+
"cursor",
|
|
17
|
+
"codex",
|
|
18
|
+
"ai-agents"
|
|
19
|
+
],
|
|
6
20
|
"license": "MIT",
|
|
7
21
|
"author": "kajisho5",
|
|
8
|
-
"repository": {
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/kajisho5/remotion-ffmpeg-skill.git"
|
|
25
|
+
},
|
|
9
26
|
"homepage": "https://github.com/kajisho5/remotion-ffmpeg-skill#readme",
|
|
10
|
-
"bugs": {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/kajisho5/remotion-ffmpeg-skill/issues"
|
|
29
|
+
},
|
|
30
|
+
"bin": {
|
|
31
|
+
"remotion-ffmpeg-skill": "bin/remotion-ffmpeg-skill.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"bin",
|
|
35
|
+
"SKILL.md",
|
|
36
|
+
"scripts",
|
|
37
|
+
"templates",
|
|
38
|
+
"references",
|
|
39
|
+
"mcp",
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"README.md",
|
|
42
|
+
"!**/__pycache__"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
}
|
|
14
47
|
}
|
package/references/scripts.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- Generated by scripts/_docs.py from scripts/_contract.py. Do not edit by hand. -->
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Contract 1.0 · timeline schema `remotion-ffmpeg-skill/timeline@1`.
|
|
6
6
|
Every script also takes `--json`, `--dry-run`, `--overwrite` and `--timeout SECONDS`.
|
|
7
7
|
Exit codes: input = 2, missing_tool = 3, timeout = 4, failed = 1.
|
|
8
8
|
|
|
@@ -35,6 +35,10 @@ Measure a source with ffmpeg-skill and write timeline.json (+ captions from a fi
|
|
|
35
35
|
| `--margin` | number | | seconds of silence kept around speech (default 0.15) |
|
|
36
36
|
| `--scene-threshold` | number | | scenes.py --threshold (default 8) |
|
|
37
37
|
|
|
38
|
+
--json result (besides `status`, `dry_run`, `output`): `commands` (list[str]), `verified` (bool), `summary` (object: duration, fps, size, scenes, silences, speech_seconds, peaks, captions, beats, tempo_bpm, highlights, clips, words), `warnings` (list[str])
|
|
39
|
+
|
|
40
|
+
--dry-run --json result (besides `status`, `dry_run`, `output`): `commands` (list[str])
|
|
41
|
+
|
|
38
42
|
## init.py
|
|
39
43
|
|
|
40
44
|
Create a Remotion project with the built-in compositions (optionally npm install).
|
|
@@ -50,6 +54,10 @@ Create a Remotion project with the built-in compositions (optionally npm install
|
|
|
50
54
|
| `directory` | string | | new project folder (must not exist, or be empty) |
|
|
51
55
|
| `--install` | boolean | | run npm install after copying |
|
|
52
56
|
|
|
57
|
+
--json result (besides `status`, `dry_run`, `output`): `commands` (list[str]), `installed` (bool), `entry` (str), `compositions` (list[str])
|
|
58
|
+
|
|
59
|
+
--dry-run --json result (besides `status`, `dry_run`, `output`): `commands` (list[str])
|
|
60
|
+
|
|
53
61
|
## still.py
|
|
54
62
|
|
|
55
63
|
Render single frames as PNG to check the look before a full render.
|
|
@@ -75,6 +83,10 @@ Render single frames as PNG to check the look before a full render.
|
|
|
75
83
|
| `--font-file` | string | | caption font file (.ttf/.otf/.ttc/.woff2), staged into the project |
|
|
76
84
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
77
85
|
|
|
86
|
+
--json result (besides `status`, `dry_run`, `output`): `outputs` (list[str] (PNG paths)), `frames` (list[int]), `commands` (list[str]), `verified` (bool), `frame` (object|null {width, height, fit}), `font` (str|null)
|
|
87
|
+
|
|
88
|
+
--dry-run --json result (besides `status`, `dry_run`, `output`): `outputs` (list[str]), `frames` (list[int]), `commands` (list[str])
|
|
89
|
+
|
|
78
90
|
## render.py
|
|
79
91
|
|
|
80
92
|
Render a composition from a timeline, verify it (frames, fps, size, audio) and write a contact sheet.
|
|
@@ -82,7 +94,7 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
82
94
|
- Role: execution — writes a new media artifact; inputs are never modified
|
|
83
95
|
- Writes: video file (+ contact sheet PNG)
|
|
84
96
|
- Verifies: exact frame count / fps / size / audio against the timeline; non-zero exit on mismatch
|
|
85
|
-
- ffmpeg-skill: probe, look, overlay (--overlay), _contract doctor (CJK font lookup)
|
|
97
|
+
- ffmpeg-skill: probe, look, overlay (--overlay; --place with --sparse), _contract doctor (CJK font lookup)
|
|
86
98
|
- `--dry-run`: plans without writing
|
|
87
99
|
|
|
88
100
|
| Argument | Type | Default | Meaning |
|
|
@@ -100,12 +112,18 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
|
|
|
100
112
|
| `--no-look` | boolean | | skip the contact sheet |
|
|
101
113
|
| `--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) |
|
|
102
114
|
| `--keep-graphics` | boolean | | with --overlay: keep the transparent graphics .mov |
|
|
115
|
+
| `--sparse` | boolean | | overlay mode that draws only the frames where captions show (Captioned / Karaoke) 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 |
|
|
116
|
+
| `--merge-gap` | number | `2.0` | with --sparse: captions closer than this many seconds are drawn as one stretch (default 2) |
|
|
103
117
|
| `--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 |
|
|
104
118
|
| `--width` | integer | | output width in px (default: keep the source's short side) |
|
|
105
119
|
| `--fit` | string: blur / contain / cover | | how the source fills another shape: blur (default when the shape changes), contain (bars) or cover (crop) |
|
|
106
120
|
| `--font-file` | string | | caption font file (.ttf/.otf/.ttc/.woff2), staged into the project |
|
|
107
121
|
| `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
|
|
108
122
|
|
|
123
|
+
--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))
|
|
124
|
+
|
|
125
|
+
--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))
|
|
126
|
+
|
|
109
127
|
## deliver.py
|
|
110
128
|
|
|
111
129
|
Run an ffmpeg-skill delivery template (YouTube, Reels, ...) and its compliance check.
|
|
@@ -123,6 +141,10 @@ Run an ffmpeg-skill delivery template (YouTube, Reels, ...) and its compliance c
|
|
|
123
141
|
| `--output` | string | | deliverable path (default: <name>_<platform>.mp4) |
|
|
124
142
|
| `--check-only` | boolean | | run check.py only, write nothing |
|
|
125
143
|
|
|
144
|
+
--json result (besides `status`, `dry_run`, `output`): `checked` (str), `platform` (str|null), `verified` (bool), `checks` (list[{check, status, value, expected, ...}] (ffmpeg-skill check.py rows)), `failed` (list[str]), `warnings` (list[str]), `commands` (list[str]), `kind` (null|failed), `error` (null|str)
|
|
145
|
+
|
|
146
|
+
--dry-run --json result (besides `status`, `dry_run`, `output`): `commands` (list[str])
|
|
147
|
+
|
|
126
148
|
## pipeline.py
|
|
127
149
|
|
|
128
150
|
analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
@@ -149,6 +171,10 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
|
|
|
149
171
|
| `--fit` | string: blur / contain / cover | | blur (default when the shape changes), contain or cover |
|
|
150
172
|
| `--font-file` | string | | caption font file |
|
|
151
173
|
|
|
174
|
+
--json result (besides `status`, `dry_run`, `output`): `timeline` (str), `render` (str), `deliverable` (str|null), `look` (str|null), `verified` (bool), `warnings` (list[str]), `steps` (list[{step, status, output, command}])
|
|
175
|
+
|
|
176
|
+
--dry-run --json result (besides `status`, `dry_run`, `output`): `steps` (list[{step, status, output, command}])
|
|
177
|
+
|
|
152
178
|
## doctor.py
|
|
153
179
|
|
|
154
180
|
What this machine can do: Python, Node/npm, ffmpeg-skill, ffmpeg, a project's Remotion install.
|
|
@@ -162,3 +188,9 @@ What this machine can do: Python, Node/npm, ffmpeg-skill, ffmpeg, a project's Re
|
|
|
162
188
|
| Argument | Type | Default | Meaning |
|
|
163
189
|
|---|---|---|---|
|
|
164
190
|
| `--project` | string | | Remotion project folder to inspect |
|
|
191
|
+
|
|
192
|
+
--json result (besides `status`, `dry_run`, `output`): `ok` (bool), `version` (str), `checks` (list[{check, ok, value, fix}]), `ffmpeg_skill_doctor` (object|null)
|
|
193
|
+
|
|
194
|
+
## Failures
|
|
195
|
+
|
|
196
|
+
Every failure is one JSON object: `status` (failed), `error` (str), `kind` (input|missing_tool|timeout|failed), `dry_run` (bool).
|
package/scripts/_contract.py
CHANGED
|
@@ -62,7 +62,7 @@ TOOL_META: Dict[str, Dict[str, Any]] = {
|
|
|
62
62
|
"summary": "Render a composition from a timeline, verify it (frames, fps, size, audio) and write a contact sheet.",
|
|
63
63
|
"writes": "video file (+ contact sheet PNG)",
|
|
64
64
|
"verification": "exact frame count / fps / size / audio against the timeline; non-zero exit on mismatch",
|
|
65
|
-
"ffmpeg_skill": ["probe", "look", "overlay (--overlay)", "_contract doctor (CJK font lookup)"],
|
|
65
|
+
"ffmpeg_skill": ["probe", "look", "overlay (--overlay; --place with --sparse)", "_contract doctor (CJK font lookup)"],
|
|
66
66
|
"dry_run": True,
|
|
67
67
|
},
|
|
68
68
|
"deliver": {
|
|
@@ -91,6 +91,67 @@ TOOL_META: Dict[str, Dict[str, Any]] = {
|
|
|
91
91
|
},
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
# What each tool's --json result carries (beyond the shared status / dry_run / output), as
|
|
95
|
+
# key -> short type. "result" is a completed run, "dry_run" a --dry-run plan. tests check real
|
|
96
|
+
# outputs against these, so the contract cannot promise a key a script stopped writing.
|
|
97
|
+
OUTPUTS: Dict[str, Dict[str, Dict[str, str]]] = {
|
|
98
|
+
"analyze": {
|
|
99
|
+
"result": {"commands": "list[str]", "verified": "bool", "summary": "object: duration, fps, size, scenes, "
|
|
100
|
+
"silences, speech_seconds, peaks, captions, beats, tempo_bpm, highlights, clips, words",
|
|
101
|
+
"warnings": "list[str]"},
|
|
102
|
+
"dry_run": {"commands": "list[str]"},
|
|
103
|
+
},
|
|
104
|
+
"init": {
|
|
105
|
+
"result": {"commands": "list[str]", "installed": "bool", "entry": "str", "compositions": "list[str]"},
|
|
106
|
+
"dry_run": {"commands": "list[str]"},
|
|
107
|
+
},
|
|
108
|
+
"still": {
|
|
109
|
+
"result": {"outputs": "list[str] (PNG paths)", "frames": "list[int]", "commands": "list[str]",
|
|
110
|
+
"verified": "bool", "frame": "object|null {width, height, fit}", "font": "str|null"},
|
|
111
|
+
"dry_run": {"outputs": "list[str]", "frames": "list[int]", "commands": "list[str]"},
|
|
112
|
+
},
|
|
113
|
+
"render": {
|
|
114
|
+
"result": {"verified": "bool", "verification": "list[{check, status, value, expected}]",
|
|
115
|
+
"commands": "list[str]", "look": "str|null (contact sheet PNG)", "look_error": "str|null",
|
|
116
|
+
"summary": "str", "frame": "object|null", "font": "str|null", "mode": "full|overlay",
|
|
117
|
+
"graphics": "str|null (kept ProRes 4444 layer)",
|
|
118
|
+
"sparse": "null|{used, reason, stretches, drawn_frames, source_frames} (--sparse)",
|
|
119
|
+
"kind": "null|failed",
|
|
120
|
+
"error": "null|str (which verification rows failed)"},
|
|
121
|
+
"dry_run": {"commands": "list[str]", "props": "str", "expected_frames": "int|null", "frame": "object|null",
|
|
122
|
+
"font": "str|null", "sparse": "null|object (--sparse)"},
|
|
123
|
+
},
|
|
124
|
+
"deliver": {
|
|
125
|
+
"result": {"checked": "str", "platform": "str|null", "verified": "bool",
|
|
126
|
+
"checks": "list[{check, status, value, expected, ...}] (ffmpeg-skill check.py rows)",
|
|
127
|
+
"failed": "list[str]", "warnings": "list[str]", "commands": "list[str]",
|
|
128
|
+
"kind": "null|failed", "error": "null|str"},
|
|
129
|
+
"dry_run": {"commands": "list[str]"},
|
|
130
|
+
},
|
|
131
|
+
"pipeline": {
|
|
132
|
+
"result": {"timeline": "str", "render": "str", "deliverable": "str|null", "look": "str|null",
|
|
133
|
+
"verified": "bool", "warnings": "list[str]", "steps": "list[{step, status, output, command}]"},
|
|
134
|
+
"dry_run": {"steps": "list[{step, status, output, command}]"},
|
|
135
|
+
},
|
|
136
|
+
"doctor": {
|
|
137
|
+
"result": {"ok": "bool", "version": "str", "checks": "list[{check, ok, value, fix}]",
|
|
138
|
+
"ffmpeg_skill_doctor": "object|null"},
|
|
139
|
+
"dry_run": {},
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
SHARED_OUTPUT = {"status": "completed|failed", "dry_run": "bool", "output": "str|null (main artifact)"}
|
|
143
|
+
FAILURE_OUTPUT = {"status": "failed", "error": "str", "kind": "input|missing_tool|timeout|failed", "dry_run": "bool"}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def missing_output_keys(tool: str, doc: Dict[str, Any]) -> List[str]:
|
|
147
|
+
"""Keys the contract promises for this result that `doc` lacks (empty = conforms)."""
|
|
148
|
+
if doc.get("status") == "failed":
|
|
149
|
+
return [k for k in FAILURE_OUTPUT if k not in doc]
|
|
150
|
+
which = "dry_run" if doc.get("dry_run") else "result"
|
|
151
|
+
want = list(OUTPUTS[tool][which]) + [k for k in SHARED_OUTPUT if not (tool == "doctor" and k == "output")]
|
|
152
|
+
return [k for k in want if k not in doc]
|
|
153
|
+
|
|
154
|
+
|
|
94
155
|
# Flags every tool takes; the MCP server adds --json itself.
|
|
95
156
|
SHARED = {"json", "dry_run", "overwrite", "timeout", "help"}
|
|
96
157
|
|
|
@@ -170,6 +231,7 @@ def tool_spec(name: str) -> Dict[str, Any]:
|
|
|
170
231
|
"dry_run": meta["dry_run"],
|
|
171
232
|
"inputSchema": input_schema(parser),
|
|
172
233
|
"flags": flag_for(parser),
|
|
234
|
+
"output": OUTPUTS[name],
|
|
173
235
|
}
|
|
174
236
|
|
|
175
237
|
|
|
@@ -182,6 +244,8 @@ def build() -> Dict[str, Any]:
|
|
|
182
244
|
"depends_on": {"ffmpeg-skill": "https://github.com/kajisho5/ffmpeg-skill", "node": ">=18",
|
|
183
245
|
"python": ">=3.10"},
|
|
184
246
|
"roles": ROLES,
|
|
247
|
+
"output_shared": SHARED_OUTPUT,
|
|
248
|
+
"output_failure": FAILURE_OUTPUT,
|
|
185
249
|
"conventions": {
|
|
186
250
|
"output": "one JSON object on stdout with --json; human lines on stderr",
|
|
187
251
|
"errors": {"input": 2, "missing_tool": 3, "timeout": 4, "failed": 1},
|
package/scripts/_docs.py
CHANGED
|
@@ -23,7 +23,8 @@ def render() -> str:
|
|
|
23
23
|
"",
|
|
24
24
|
"<!-- Generated by scripts/_docs.py from scripts/_contract.py. Do not edit by hand. -->",
|
|
25
25
|
"",
|
|
26
|
-
|
|
26
|
+
# No package version here: a version bump must not make the generated reference stale.
|
|
27
|
+
f"Contract {c['contract_version']} · timeline schema `{c['timeline_schema']}`.",
|
|
27
28
|
"Every script also takes `--json`, `--dry-run`, `--overwrite` and `--timeout SECONDS`.",
|
|
28
29
|
"Exit codes: " + ", ".join(f"{k} = {v}" for k, v in c["conventions"]["errors"].items()) + ".",
|
|
29
30
|
"",
|
|
@@ -52,6 +53,14 @@ def render() -> str:
|
|
|
52
53
|
desc = (p.get("description") or "").replace("|", "\\|").replace("\n", " ")
|
|
53
54
|
lines.append(f"| `{arg}` | {typ} | {default} | {desc} |")
|
|
54
55
|
lines.append("")
|
|
56
|
+
for which, title in (("result", "--json result"), ("dry_run", "--dry-run --json result")):
|
|
57
|
+
keys = t["output"][which]
|
|
58
|
+
if keys:
|
|
59
|
+
lines.append(f"{title} (besides `status`, `dry_run`, `output`): " +
|
|
60
|
+
", ".join(f"`{k}` ({v})" for k, v in keys.items()))
|
|
61
|
+
lines.append("")
|
|
62
|
+
lines += ["## Failures", "",
|
|
63
|
+
"Every failure is one JSON object: " + ", ".join(f"`{k}` ({v})" for k, v in c["output_failure"].items()) + ".", ""]
|
|
55
64
|
return "\n".join(lines)
|
|
56
65
|
|
|
57
66
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Sparse overlay rendering: draw only the frames where captions show, then lay each drawn stretch
|
|
2
|
+
back at its own time with ffmpeg-skill `overlay.py --place`.
|
|
3
|
+
|
|
4
|
+
Remotion renders every frame in a browser, so a 30-minute talk with captions on a third of it spends
|
|
5
|
+
two thirds of the render on empty transparent frames. Here the caption cues are grouped into
|
|
6
|
+
stretches (cues closer than `merge_gap` seconds share one), the stretches are packed back to back
|
|
7
|
+
in a short timeline, Remotion draws that, and overlay.py places each stretch over the untouched
|
|
8
|
+
source. Frame numbers stay integers end to end, so the result matches the full-length overlay.
|
|
9
|
+
"""
|
|
10
|
+
import copy
|
|
11
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
12
|
+
|
|
13
|
+
from _common import sec_to_frames
|
|
14
|
+
|
|
15
|
+
SPARSE_COMPOSITIONS = ("Captioned", "Karaoke")
|
|
16
|
+
# One overlay filter per stretch: past this many, the filter chain costs more than it saves.
|
|
17
|
+
MAX_STRETCHES = 400
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def caption_stretches(timeline: Dict[str, Any], merge_gap: float) -> List[Tuple[int, int]]:
|
|
21
|
+
"""[(first_frame, end_frame)] of the frames that show a caption, cues closer than merge_gap merged."""
|
|
22
|
+
fps = float(timeline["source"]["fps"])
|
|
23
|
+
total = sec_to_frames(float(timeline["source"]["duration"]), fps)
|
|
24
|
+
gap = sec_to_frames(merge_gap, fps)
|
|
25
|
+
cues = sorted((sec_to_frames(c["start"], fps), sec_to_frames(c["end"], fps)) for c in timeline.get("captions") or [])
|
|
26
|
+
out: List[List[int]] = []
|
|
27
|
+
for s, e in cues:
|
|
28
|
+
# the same rule as the compositions: a cue lasts at least one frame, inside the source
|
|
29
|
+
s = max(0, min(s, total - 1))
|
|
30
|
+
e = min(total, max(e, s + 1))
|
|
31
|
+
if out and s <= out[-1][1] + gap:
|
|
32
|
+
out[-1][1] = max(out[-1][1], e)
|
|
33
|
+
else:
|
|
34
|
+
out.append([s, e])
|
|
35
|
+
return [(s, e) for s, e in out]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def pack(timeline: Dict[str, Any], stretches: List[Tuple[int, int]]) -> Tuple[Dict[str, Any], List[Tuple[int, int, int]]]:
|
|
39
|
+
"""A timeline with the stretches back to back (one blank frame between them) and, per stretch,
|
|
40
|
+
(packed_first_frame, length_frames, source_first_frame)."""
|
|
41
|
+
fps = float(timeline["source"]["fps"])
|
|
42
|
+
layout: List[Tuple[int, int, int]] = []
|
|
43
|
+
p = 0
|
|
44
|
+
for s, e in stretches:
|
|
45
|
+
layout.append((p, e - s, s))
|
|
46
|
+
p += (e - s) + 1
|
|
47
|
+
packed_frames = max(1, p - 1)
|
|
48
|
+
|
|
49
|
+
def offset(t: float) -> Optional[int]:
|
|
50
|
+
"""Whole frames to move a time by: its stretch's source start minus its packed start. Only
|
|
51
|
+
whole frames, so a word timed between two frames keeps exactly where it falls in its frame."""
|
|
52
|
+
f = sec_to_frames(t, fps)
|
|
53
|
+
for pp, n, s in layout:
|
|
54
|
+
if s <= f <= s + n:
|
|
55
|
+
return s - pp
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
out = copy.deepcopy(timeline)
|
|
59
|
+
out["source"]["duration"] = packed_frames / fps
|
|
60
|
+
for key in ("captions", "words"):
|
|
61
|
+
moved = []
|
|
62
|
+
for c in timeline.get(key) or []:
|
|
63
|
+
# a word belongs where Karaoke puts it: by its midpoint
|
|
64
|
+
k = offset(c["start"] if key == "captions" else (c["start"] + c["end"]) / 2)
|
|
65
|
+
if k is not None:
|
|
66
|
+
moved.append({**c, "start": c["start"] - k / fps, "end": c["end"] - k / fps})
|
|
67
|
+
out[key] = moved
|
|
68
|
+
# Captioned and Karaoke draw nothing else; measurements on the source clock would only mislead.
|
|
69
|
+
for k in ("scenes", "silences", "speech", "peaks", "highlights", "clips"):
|
|
70
|
+
out[k] = []
|
|
71
|
+
out["beats"] = None
|
|
72
|
+
return out, layout
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def place_args(layout: List[Tuple[int, int, int]], fps: float) -> List[str]:
|
|
76
|
+
"""overlay.py --place arguments. Range edges sit half a frame inside the stretch, so the blank
|
|
77
|
+
frame between stretches is never picked up whatever the float rounding of a timestamp."""
|
|
78
|
+
args: List[str] = []
|
|
79
|
+
for pp, n, s in layout:
|
|
80
|
+
a = max(0.0, (pp - 0.5) / fps)
|
|
81
|
+
b = (pp + n - 0.5) / fps
|
|
82
|
+
args += ["--place", f"{a:.6f}-{b:.6f}@{s / fps:.6f}"]
|
|
83
|
+
return args
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def packed_frames(layout: List[Tuple[int, int, int]]) -> int:
|
|
87
|
+
return max(1, sum(n for _, n, _ in layout) + len(layout) - 1)
|
package/scripts/deliver.py
CHANGED
|
@@ -69,7 +69,10 @@ def main() -> None:
|
|
|
69
69
|
lines = [f"{c['status']:4} {c['check']}: {c.get('value')} (expected {c.get('expected')})" for c in checks]
|
|
70
70
|
emit({"status": "completed" if ok else "failed", "output": str(target) if target != src else None,
|
|
71
71
|
"checked": str(target), "platform": a.platform, "verified": ok, "checks": checks,
|
|
72
|
-
"failed": [c["check"] for c in failed], "warnings": [c["check"] for c in warns], "commands": commands
|
|
72
|
+
"failed": [c["check"] for c in failed], "warnings": [c["check"] for c in warns], "commands": commands,
|
|
73
|
+
"kind": None if ok else "failed",
|
|
74
|
+
"error": None if ok else ("compliance check failed: " + ", ".join(c["check"] for c in failed)
|
|
75
|
+
if failed else (ck.get("error") or "check.py returned no rows"))},
|
|
73
76
|
"\n".join([f"{target.name}: {'PASS' if ok else 'FAIL'} ({len(failed)} fail, {len(warns)} warn)"] + lines))
|
|
74
77
|
if not ok:
|
|
75
78
|
sys.exit(1)
|
package/scripts/render.py
CHANGED
|
@@ -15,6 +15,7 @@ from pathlib import Path
|
|
|
15
15
|
from typing import Any, Dict, List, Optional, Tuple
|
|
16
16
|
|
|
17
17
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
18
|
+
import _sparse
|
|
18
19
|
from _common import (BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit, expected_frames,
|
|
19
20
|
ffskill, ffskill_cmd, frame_size, info, load_options, load_timeline, prepare_props, refuse_existing,
|
|
20
21
|
remotion_bin, require_ffmpeg_skill, require_project, remotion_error, run, shell_join)
|
|
@@ -43,6 +44,13 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
43
44
|
"untouched source with ffmpeg-skill overlay.py (Captioned / PeakPulse, source frame only); "
|
|
44
45
|
"with --keep-graphics the layer is kept for an editing app (Premiere, Resolve, Final Cut)")
|
|
45
46
|
p.add_argument("--keep-graphics", action="store_true", help="with --overlay: keep the transparent graphics .mov")
|
|
47
|
+
p.add_argument("--sparse", action="store_true",
|
|
48
|
+
help="overlay mode that draws only the frames where captions show (Captioned / Karaoke) and "
|
|
49
|
+
"places each stretch at its time with ffmpeg-skill overlay.py --place: much faster on long "
|
|
50
|
+
"footage with gaps between captions. Falls back to the full-length layer (and says why) "
|
|
51
|
+
"when this ffmpeg-skill has no --place or the source does not start at 0")
|
|
52
|
+
p.add_argument("--merge-gap", type=float, default=2.0,
|
|
53
|
+
help="with --sparse: captions closer than this many seconds are drawn as one stretch (default 2)")
|
|
46
54
|
add_frame_args(p)
|
|
47
55
|
add_common(p)
|
|
48
56
|
return p
|
|
@@ -126,6 +134,52 @@ def verify(out_probe: Dict[str, Any], timeline: Dict[str, Any], comp: str,
|
|
|
126
134
|
return all(r["status"] != "FAIL" for r in rows), rows
|
|
127
135
|
|
|
128
136
|
|
|
137
|
+
def ffskill_can_place() -> bool:
|
|
138
|
+
"""Whether this ffmpeg-skill's overlay.py has --place (ffmpeg-skill PR #353)."""
|
|
139
|
+
import subprocess
|
|
140
|
+
try:
|
|
141
|
+
proc = subprocess.run(ffskill_cmd("overlay", ["--help"]), capture_output=True, text=True, timeout=60)
|
|
142
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
143
|
+
return False
|
|
144
|
+
return "--place" in (proc.stdout or "")
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def sparse_plan(timeline: Dict[str, Any], a: argparse.Namespace) -> Dict[str, Any]:
|
|
148
|
+
"""What --sparse will draw, or why it falls back to the full-length layer."""
|
|
149
|
+
src = timeline["source"]
|
|
150
|
+
fps = float(src["fps"])
|
|
151
|
+
total = expected_frames(a.comp, timeline) or 1
|
|
152
|
+
plan: Dict[str, Any] = {"used": False, "reason": None, "stretches": 0, "drawn_frames": total,
|
|
153
|
+
"source_frames": total, "timeline": None, "place": []}
|
|
154
|
+
stretches = _sparse.caption_stretches(timeline, a.merge_gap)
|
|
155
|
+
start = None
|
|
156
|
+
if stretches and src.get("path") and not STATE.dry_run:
|
|
157
|
+
# the source as it is now (older timelines do not record where its first picture sits)
|
|
158
|
+
start = (ffskill("probe", [str(src["path"])], allow_fail=True).get("video") or {}).get("start_time")
|
|
159
|
+
if not stretches:
|
|
160
|
+
plan["reason"] = "no captions to draw"
|
|
161
|
+
elif len(stretches) > _sparse.MAX_STRETCHES:
|
|
162
|
+
plan["reason"] = (f"{len(stretches)} caption stretches (over {_sparse.MAX_STRETCHES}); raise --merge-gap")
|
|
163
|
+
elif isinstance(start, (int, float)) and abs(start) > 0.5 / fps:
|
|
164
|
+
plan["reason"] = (f"the source's first picture is at {start:.3f} s, not 0: placed stretches would be "
|
|
165
|
+
"shifted by that much")
|
|
166
|
+
elif not ffskill_can_place():
|
|
167
|
+
plan["reason"] = "this ffmpeg-skill's overlay.py has no --place yet (update ffmpeg-skill)"
|
|
168
|
+
else:
|
|
169
|
+
packed, layout = _sparse.pack(timeline, stretches)
|
|
170
|
+
drawn = _sparse.packed_frames(layout)
|
|
171
|
+
if drawn >= total:
|
|
172
|
+
plan["reason"] = "captions cover the whole source: nothing to skip"
|
|
173
|
+
else:
|
|
174
|
+
plan.update(used=True, stretches=len(layout), drawn_frames=drawn, timeline=packed,
|
|
175
|
+
place=_sparse.place_args(layout, fps))
|
|
176
|
+
if plan["reason"]:
|
|
177
|
+
info(f"--sparse: drawing the full length instead ({plan['reason']})")
|
|
178
|
+
else:
|
|
179
|
+
info(f"--sparse: drawing {plan['drawn_frames']} of {total} frames in {plan['stretches']} stretch(es)")
|
|
180
|
+
return plan
|
|
181
|
+
|
|
182
|
+
|
|
129
183
|
def main() -> None:
|
|
130
184
|
a = build_parser().parse_args()
|
|
131
185
|
apply_common(a)
|
|
@@ -147,6 +201,13 @@ def main() -> None:
|
|
|
147
201
|
output = output.resolve()
|
|
148
202
|
refuse_existing(output)
|
|
149
203
|
|
|
204
|
+
if a.sparse:
|
|
205
|
+
if a.comp not in _sparse.SPARSE_COMPOSITIONS:
|
|
206
|
+
die(f"--sparse draws caption stretches only: {a.comp} is not one of "
|
|
207
|
+
f"{', '.join(_sparse.SPARSE_COMPOSITIONS)} (use --overlay for the full-length layer)", "input")
|
|
208
|
+
if a.merge_gap < 0:
|
|
209
|
+
die("--merge-gap cannot be negative", "input")
|
|
210
|
+
a.overlay = True
|
|
150
211
|
if a.overlay:
|
|
151
212
|
if a.comp in ("Jumpcut", "Highlights", "BeatMontage"):
|
|
152
213
|
die(f"--overlay cannot do {a.comp}: its cuts move the picture itself (overlay works for "
|
|
@@ -158,18 +219,24 @@ def main() -> None:
|
|
|
158
219
|
if not timeline["source"].get("has_video"):
|
|
159
220
|
die("--overlay needs a video source to composite onto", "input")
|
|
160
221
|
|
|
161
|
-
|
|
222
|
+
sparse = sparse_plan(timeline, a) if a.sparse else None
|
|
223
|
+
drawn = sparse["timeline"] if sparse and sparse["used"] else timeline
|
|
224
|
+
props_path, frame, font_note = prepare_props(project, a.comp, drawn, options, a)
|
|
162
225
|
if font_note:
|
|
163
226
|
info(font_note)
|
|
164
227
|
graphics = output.with_name(output.stem + ".graphics.mov") if a.overlay else output
|
|
165
228
|
cmd = remotion_render_cmd(project, a.comp, graphics, props_path, a)
|
|
166
229
|
ov_args = [timeline["source"]["path"], "--video", str(graphics), "--position", "0,0", "--margin", "0",
|
|
167
230
|
"-o", str(output)] + (["--overwrite"] if STATE.overwrite else [])
|
|
231
|
+
if sparse and sparse["used"]:
|
|
232
|
+
ov_args += sparse["place"]
|
|
233
|
+
sparse_note = None if not sparse else {k: sparse[k] for k in ("used", "reason", "stretches", "drawn_frames",
|
|
234
|
+
"source_frames")}
|
|
168
235
|
if STATE.dry_run:
|
|
169
236
|
plan = [shell_join(cmd)] + ([shell_join(ffskill_cmd("overlay", ov_args))] if a.overlay else [])
|
|
170
237
|
emit({"output": str(output), "commands": plan, "props": str(props_path),
|
|
171
238
|
"expected_frames": (frames[1] - frames[0] + 1) if frames else expected_frames(a.comp, timeline),
|
|
172
|
-
"frame": frame, "font": font_note},
|
|
239
|
+
"frame": frame, "font": font_note, "sparse": sparse_note},
|
|
173
240
|
f"would render {a.comp} -> {output}")
|
|
174
241
|
return
|
|
175
242
|
|
|
@@ -182,6 +249,13 @@ def main() -> None:
|
|
|
182
249
|
tail = remotion_error((proc.stderr or "") + "\n" + (proc.stdout or ""))
|
|
183
250
|
die(f"Remotion render failed (exit {proc.returncode}):\n{tail}", "failed", command=shell_join(cmd))
|
|
184
251
|
commands = [shell_join(cmd)]
|
|
252
|
+
if sparse and sparse["used"]:
|
|
253
|
+
# the packed layer must hold exactly the frames the placements read
|
|
254
|
+
gp = ffskill("probe", [str(graphics)])
|
|
255
|
+
nb = (gp.get("video") or {}).get("nb_frames")
|
|
256
|
+
if isinstance(nb, int) and nb != sparse["drawn_frames"]:
|
|
257
|
+
die(f"--sparse: the drawn layer has {nb} frames, the placements expect {sparse['drawn_frames']}",
|
|
258
|
+
"failed", command=shell_join(cmd))
|
|
185
259
|
if a.overlay:
|
|
186
260
|
info(f"compositing the graphics over the source with ffmpeg-skill overlay.py -> {output}")
|
|
187
261
|
ov = ffskill("overlay", ov_args)
|
|
@@ -213,8 +287,9 @@ def main() -> None:
|
|
|
213
287
|
result = {"status": "completed" if ok else "failed", "output": str(output), "verified": ok,
|
|
214
288
|
"verification": rows, "commands": commands, "look": look, "summary": summary,
|
|
215
289
|
"frame": frame, "font": font_note, "mode": "overlay" if a.overlay else "full", "look_error": look_error,
|
|
216
|
-
"graphics": str(graphics) if a.overlay and a.keep_graphics else None,
|
|
217
|
-
"kind": None if ok else "failed"
|
|
290
|
+
"graphics": str(graphics) if a.overlay and a.keep_graphics else None, "sparse": sparse_note,
|
|
291
|
+
"kind": None if ok else "failed",
|
|
292
|
+
"error": None if ok else "verification failed: " + ", ".join(r["check"] for r in rows if r["status"] == "FAIL")}
|
|
218
293
|
table = "\n".join(f" {r['check']:<9} {r['status']:<4} {r['value']} (expected {r['expected']})" for r in rows)
|
|
219
294
|
emit(result, summary + "\n" + table + (f"\nLook: {look}" if look else "") +
|
|
220
295
|
("" if ok else "\nverification FAILED: " + ", ".join(r["check"] for r in rows if r["status"] == "FAIL")))
|
|
@@ -48,7 +48,9 @@ const KaraokeCue: React.FC<{ cue: Caption; words: Caption[]; len: number; o: Opt
|
|
|
48
48
|
const fade = Math.min(6, Math.floor(len / 3));
|
|
49
49
|
const exit = fade > 0 ? interpolate(frame, [len - fade, len], [1, 0], { extrapolateLeft: "clamp", extrapolateRight: "clamp" }) : 1;
|
|
50
50
|
const size = Math.round(Math.min(width, height) * o.captionSize * 1.1);
|
|
51
|
-
|
|
51
|
+
// Source time at this frame. The microsecond nudge settles a word boundary that falls exactly on a
|
|
52
|
+
// frame (5.2 + 21/30 vs 5.9) the same way whatever float rounding produced the two numbers.
|
|
53
|
+
const now = cue.start + frame / fps + 1e-6;
|
|
52
54
|
const lang = /[-ヿ]/.test(cue.text) ? "ja" : /[가-]/.test(cue.text) ? "ko" : undefined;
|
|
53
55
|
return (
|
|
54
56
|
<AbsoluteFill style={{ justifyContent: "flex-end", alignItems: "center", paddingBottom: captionMarginPx(o, width, height) }}>
|