remotion-ffmpeg-skill 0.14.3 → 0.14.5
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/package.json +1 -1
- package/scripts/_contract.py +3 -2
- package/scripts/deliver.py +96 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remotion-ffmpeg-skill",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.5",
|
|
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/scripts/_contract.py
CHANGED
|
@@ -299,8 +299,9 @@ def tool_spec(name: str) -> Dict[str, Any]:
|
|
|
299
299
|
# The AI Video Production OS registry's keys (skill_id, provides[], dependencies[]): one capability
|
|
300
300
|
# per public tool except doctor, all EXPERIMENTAL; ffmpeg-skill is the only Skill this one calls.
|
|
301
301
|
PROVIDES_EXCLUDE = {"doctor"}
|
|
302
|
-
# 3.x accepted (docs/design-decisions.md): 3.0.0 removed nothing this skill calls, and
|
|
303
|
-
|
|
302
|
+
# 3.x and 4.x accepted (docs/design-decisions.md): 3.0.0 and 4.0.0 removed nothing this skill calls, and their
|
|
303
|
+
# behaviour changes (cut.py in 3.0; export loudness, fit --method, join --copy in 4.0) do not reach the calls made here
|
|
304
|
+
FFMPEG_SKILL_RANGE = ">=2.0.0 <5.0.0"
|
|
304
305
|
|
|
305
306
|
|
|
306
307
|
def provides() -> List[Dict[str, str]]:
|
package/scripts/deliver.py
CHANGED
|
@@ -11,14 +11,16 @@ Examples:
|
|
|
11
11
|
"""
|
|
12
12
|
import argparse
|
|
13
13
|
import json
|
|
14
|
+
import shutil
|
|
14
15
|
import sys
|
|
16
|
+
import tempfile
|
|
15
17
|
from pathlib import Path
|
|
16
|
-
from typing import Optional
|
|
18
|
+
from typing import List, Optional
|
|
17
19
|
|
|
18
20
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
19
21
|
from _captions import parse_chapters
|
|
20
|
-
from _common import (STATE, add_common, apply_common, default_output, die, emit,
|
|
21
|
-
refuse_existing, require_ffmpeg_skill, shell_join)
|
|
22
|
+
from _common import (STATE, add_common, apply_common, default_output, die, emit, ffmpeg_skill_version, ffskill,
|
|
23
|
+
ffskill_cmd, info, refuse_existing, require_ffmpeg_skill, shell_join)
|
|
22
24
|
|
|
23
25
|
# ffmpeg-skill's templates/*.json names (render.py --list-templates).
|
|
24
26
|
PLATFORMS = ["youtube", "youtube-shorts", "shorts", "reels", "tiktok", "x", "facebook", "linkedin", "podcast", "audiogram"]
|
|
@@ -39,6 +41,76 @@ def brand_logo(brand: Optional[str]) -> Optional[Path]:
|
|
|
39
41
|
return lp if lp.is_absolute() else bp.resolve().parent / lp
|
|
40
42
|
|
|
41
43
|
|
|
44
|
+
def kit_projection(path: Path) -> Optional[dict]:
|
|
45
|
+
"""Project a Velisa kit for delivery (ADR-030); native brand files go to the engine unchanged."""
|
|
46
|
+
try:
|
|
47
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
48
|
+
except (ValueError, OSError) as exc:
|
|
49
|
+
die(f"cannot read brand file {path}: {exc}", "input")
|
|
50
|
+
if not isinstance(data, dict):
|
|
51
|
+
die(f"{path} must hold a JSON object", "input")
|
|
52
|
+
if "colours" not in data and data.get("schema") != "velisa/kit@1":
|
|
53
|
+
return None
|
|
54
|
+
if "colors" in data and "colours" in data:
|
|
55
|
+
die(f"{path} defines both colors and colours", "input")
|
|
56
|
+
|
|
57
|
+
def subset(obj, keys):
|
|
58
|
+
if not isinstance(obj, dict):
|
|
59
|
+
die(f"expected an object in brand file {path}", "input")
|
|
60
|
+
return {key: obj[key] for key in keys if key in obj}
|
|
61
|
+
|
|
62
|
+
brand = subset(data, ("font", "font_file", "logo", "logo_position", "logo_scale", "logo_opacity",
|
|
63
|
+
"safe_margin", "lang"))
|
|
64
|
+
for key in ("logo", "font_file"):
|
|
65
|
+
if key in brand:
|
|
66
|
+
if not isinstance(brand[key], str) or not brand[key]:
|
|
67
|
+
die(f"{path}: {key} must be a non-empty path", "input")
|
|
68
|
+
brand[key] = str((path.parent / Path(brand[key]).expanduser()).resolve())
|
|
69
|
+
colors = "colors" if "colors" in data else "colours"
|
|
70
|
+
if colors in data:
|
|
71
|
+
brand["colors"] = subset(data[colors], ("primary", "text", "outline", "background", "accent"))
|
|
72
|
+
if "caption" in data:
|
|
73
|
+
brand["caption"] = subset(data["caption"], ("size", "position", "animate", "karaoke", "bold", "outline"))
|
|
74
|
+
if "styles" in data:
|
|
75
|
+
styles = subset(data["styles"], ("caption",))
|
|
76
|
+
if "caption" in styles:
|
|
77
|
+
brand["styles"] = {"caption": subset(styles["caption"], ("font", "size", "colour", "color", "box", "position"))}
|
|
78
|
+
if "loudness" in data:
|
|
79
|
+
brand["loudness"] = subset(data["loudness"], ("lufs", "tp"))
|
|
80
|
+
return brand
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def template_runs_content_check() -> bool:
|
|
84
|
+
"""ffmpeg-skill 4.0.0 (#575) made a delivery template's check stage also run check.py --content (black frames,
|
|
85
|
+
freezes, flashes, silence), and a failed row fails the render. A Remotion deliverable often holds a still picture
|
|
86
|
+
on purpose (a title card, a slide), which 4.0 reads as `frozen`. deliver keeps 3.x's template (platform rows
|
|
87
|
+
only); its own check.py --platform still runs on the result (docs/design-decisions.md)."""
|
|
88
|
+
version = ffmpeg_skill_version(require_ffmpeg_skill()) or ""
|
|
89
|
+
try:
|
|
90
|
+
return int(version.split(".")[0]) >= 4
|
|
91
|
+
except ValueError:
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def render_template(args: List[str], commands: List[str]) -> None:
|
|
96
|
+
"""render.py --template with args; on ffmpeg-skill 4.x through --write-project with the check stage's
|
|
97
|
+
`content` set to false (the migration ffmpeg-skill's docs/contract.md gives), so only the platform rows run."""
|
|
98
|
+
if not template_runs_content_check():
|
|
99
|
+
commands.append(ffskill("render", args)["_command"])
|
|
100
|
+
return
|
|
101
|
+
work = Path(tempfile.mkdtemp(prefix="rfs-deliver-"))
|
|
102
|
+
try:
|
|
103
|
+
project = work / "project.json"
|
|
104
|
+
commands.append(ffskill("render", [*args, "--write-project", str(project)])["_command"])
|
|
105
|
+
proj = json.loads(project.read_text(encoding="utf-8"))
|
|
106
|
+
if isinstance(proj.get("check"), dict):
|
|
107
|
+
proj["check"]["content"] = False
|
|
108
|
+
project.write_text(json.dumps(proj, indent=2) + "\n", encoding="utf-8")
|
|
109
|
+
commands.append(ffskill("render", [str(project)] + (["--overwrite"] if "--overwrite" in args else []))["_command"])
|
|
110
|
+
finally:
|
|
111
|
+
shutil.rmtree(work, ignore_errors=True)
|
|
112
|
+
|
|
113
|
+
|
|
42
114
|
def youtube_description(chapters_file: Path) -> str:
|
|
43
115
|
"""The chapter list as YouTube reads it from a description: `00:00 Title` per line."""
|
|
44
116
|
chapters = parse_chapters(chapters_file.read_text(encoding="utf-8-sig"), 0)
|
|
@@ -86,12 +158,16 @@ def main() -> None:
|
|
|
86
158
|
out = Path(a.output).expanduser() if a.output else default_output(src, f"_{a.platform}", ".mp4")
|
|
87
159
|
refuse_existing(out)
|
|
88
160
|
templated = out.with_name(out.stem + ".nochapters" + out.suffix) if a.chapters else out
|
|
89
|
-
|
|
161
|
+
# absolute paths: on ffmpeg-skill 4.x the filled project is rendered from a temporary directory
|
|
162
|
+
args = ["--template", a.platform, str(src.resolve()), "-o", str(templated.resolve())]
|
|
163
|
+
projection = None
|
|
90
164
|
if a.brand:
|
|
91
165
|
bp = Path(a.brand).expanduser().resolve()
|
|
92
166
|
if not bp.is_file():
|
|
93
167
|
die(f"brand file not found: {a.brand}", "input")
|
|
94
|
-
|
|
168
|
+
projection = kit_projection(bp)
|
|
169
|
+
if projection is None:
|
|
170
|
+
args += ["--brand", str(bp)]
|
|
95
171
|
logo = Path(a.logo).expanduser() if a.logo else brand_logo(a.brand)
|
|
96
172
|
if logo:
|
|
97
173
|
if not logo.is_file():
|
|
@@ -103,14 +179,26 @@ def main() -> None:
|
|
|
103
179
|
meta_args = ([str(templated), "--chapters", str(Path(a.chapters).expanduser()), "-o", str(out)]
|
|
104
180
|
+ (["--overwrite"] if STATE.overwrite else [])) if a.chapters else []
|
|
105
181
|
if STATE.dry_run:
|
|
106
|
-
|
|
182
|
+
if projection is not None:
|
|
183
|
+
args += ["--brand", "<tmp>/brand.json"]
|
|
184
|
+
if template_runs_content_check():
|
|
185
|
+
project = "<tmp>/project.json"
|
|
186
|
+
commands.append(shell_join(ffskill_cmd("render", [*args, "--write-project", project])))
|
|
187
|
+
commands.append(shell_join(ffskill_cmd("render", [project] + (["--overwrite"] if "--overwrite" in args else []))))
|
|
188
|
+
else:
|
|
189
|
+
commands.append(shell_join(ffskill_cmd("render", args)))
|
|
107
190
|
if a.chapters:
|
|
108
191
|
commands.append(shell_join(ffskill_cmd("metadata", meta_args)))
|
|
109
192
|
commands.append(shell_join(ffskill_cmd("check", [str(out), "--platform", a.platform])))
|
|
110
193
|
emit({"output": str(out), "commands": commands}, f"would deliver {out}")
|
|
111
194
|
return
|
|
112
|
-
|
|
113
|
-
|
|
195
|
+
if projection is None:
|
|
196
|
+
render_template(args, commands)
|
|
197
|
+
else:
|
|
198
|
+
with tempfile.TemporaryDirectory(prefix="rfs-kit-") as directory:
|
|
199
|
+
projected = Path(directory) / "brand.json"
|
|
200
|
+
projected.write_text(json.dumps(projection) + "\n", encoding="utf-8")
|
|
201
|
+
render_template([*args, "--brand", str(projected)], commands)
|
|
114
202
|
if a.chapters:
|
|
115
203
|
m = ffskill("metadata", meta_args)
|
|
116
204
|
commands.append(m["_command"])
|