remotion-ffmpeg-skill 0.8.1 → 0.9.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 CHANGED
@@ -94,6 +94,8 @@ Tool names and input schemas come from the machine-readable contract (`npx remot
94
94
 
95
95
  **A layer for your editor:** `--overlay --keep-graphics` renders the graphics alone as transparent ProRes 4444 and composites it over the untouched source with ffmpeg-skill — keep the `.mov` for Premiere, Resolve or Final Cut.
96
96
 
97
+ **One brand file for both skills:** `--brand brand.json` reads ffmpeg-skill's own brand file — colours, caption colour, font, font file — and on delivery the template places its logo, so graphics drawn here match what ffmpeg-skill draws.
98
+
97
99
  Colours, font, caption size, zoom and pulse strength are options (`--options look.json`); the timeline format and every option are in [`references/timeline.md`](references/timeline.md). Add your own composition to the generated project and render it with `--comp YourId`.
98
100
 
99
101
  ### What render.py verifies
package/SKILL.md CHANGED
@@ -58,6 +58,7 @@ Changing the shape alone is not a reason: ffmpeg-skill's Reels / TikTok / Shorts
58
58
  | "give me the graphics as a separate layer" | `render.py --overlay --keep-graphics` |
59
59
  | captions or name titles on long footage (a talk, a lecture) | `render.py --comp Captioned --sparse` (or `Karaoke`, `Titled`): only the stretches where something shows are drawn |
60
60
  | "change colour / font / caption size / zoom" | an `--options` JSON (`references/timeline.md`), re-render |
61
+ | "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 |
61
62
  | 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 |
62
63
  | "preview" / "show me a frame" | `still.py` |
63
64
  | a new kind of graphic | add a composition to `src/` of the project that reads `Props` from `src/timeline.ts`; render with `--comp YourId` (render.py then reports measured numbers without a built-in expectation) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion-ffmpeg-skill",
3
- "version": "0.8.1",
3
+ "version": "0.9.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",
@@ -82,6 +82,7 @@ Render single frames as PNG to check the look before a full render.
82
82
  | `--width` | integer | | output width in px (default: keep the source's short side) |
83
83
  | `--fit` | string: blur / contain / cover | | how the source fills another shape: blur (default when the shape changes), contain (bars) or cover (crop) |
84
84
  | `--font-file` | string | | caption font file (.ttf/.otf/.ttc/.woff2), staged into the project |
85
+ | `--brand` | string | | ffmpeg-skill brand.json: its colours, caption colour, font and font file set the look (an --options file still wins key by key) |
85
86
  | `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
86
87
 
87
88
  --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)
@@ -119,6 +120,7 @@ Render a composition from a timeline, verify it (frames, fps, size, audio) and w
119
120
  | `--width` | integer | | output width in px (default: keep the source's short side) |
120
121
  | `--fit` | string: blur / contain / cover | | how the source fills another shape: blur (default when the shape changes), contain (bars) or cover (crop) |
121
122
  | `--font-file` | string | | caption font file (.ttf/.otf/.ttc/.woff2), staged into the project |
123
+ | `--brand` | string | | ffmpeg-skill brand.json: its colours, caption colour, font and font file set the look (an --options file still wins key by key) |
122
124
  | `--no-auto-font` | boolean | | don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions |
123
125
 
124
126
  --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))
@@ -141,6 +143,8 @@ Run an ffmpeg-skill delivery template (YouTube, Reels, ...) and its compliance c
141
143
  | `--platform` | string: youtube / youtube-shorts / shorts / reels / tiktok / x / facebook / linkedin / podcast / audiogram | | ffmpeg-skill delivery template to run |
142
144
  | `--output` | string | | deliverable path (default: <name>_<platform>.mp4) |
143
145
  | `--check-only` | boolean | | run check.py only, write nothing |
146
+ | `--brand` | string | | ffmpeg-skill brand.json for the template (its logo, safe margins, loudness) |
147
+ | `--logo` | string | | logo image the template places (default: the brand file's logo) |
144
148
  | `--chapters` | string | | also write these chapters (`TIME TITLE` per line) into the deliverable with ffmpeg-skill metadata.py, plus the YouTube description block next to it (<name>_description.txt) |
145
149
 
146
150
  --json result (besides `status`, `dry_run`, `output`): `checked` (str), `platform` (str|null), `verified` (bool), `description` (str|null (YouTube description block with the chapters, --chapters)), `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)
@@ -165,6 +169,7 @@ analyze -> render -> deliver in one call, stopping at the first failed step.
165
169
  | `--captions` | string | | SRT / WebVTT / JSON cues for the timeline |
166
170
  | `--chapters` | string | | chapters (`TIME TITLE` per line, or `source`): cards in Titled and, with --platform, chapter markers in the deliverable |
167
171
  | `--options` | string | | JSON options file passed to the composition |
172
+ | `--brand` | string | | ffmpeg-skill brand.json: the look of the graphics and, on delivery, the logo |
168
173
  | `--platform` | string: youtube / youtube-shorts / shorts / reels / tiktok / x / facebook / linkedin / podcast / audiogram | | deliver with this ffmpeg-skill template and check it |
169
174
  | `--out-dir` | string | | where the timeline, render and deliverable go (default: next to the input) |
170
175
  | `--beats` | boolean | | measure the beat grid too |
@@ -18,6 +18,7 @@ import hashlib
18
18
  import json
19
19
  import math
20
20
  import os
21
+ import re
21
22
  import shutil
22
23
  import subprocess
23
24
  import sys
@@ -472,6 +473,8 @@ def add_frame_args(p: argparse.ArgumentParser) -> None:
472
473
  g.add_argument("--fit", choices=FITS, help="how the source fills another shape: blur (default when the shape "
473
474
  "changes), contain (bars) or cover (crop)")
474
475
  g.add_argument("--font-file", help="caption font file (.ttf/.otf/.ttc/.woff2), staged into the project")
476
+ g.add_argument("--brand", help="ffmpeg-skill brand.json: its colours, caption colour, font and font file set "
477
+ "the look (an --options file still wins key by key)")
475
478
  g.add_argument("--no-auto-font", action="store_true",
476
479
  help="don't stage the CJK font ffmpeg-skill finds for Japanese/Chinese/Korean captions")
477
480
 
@@ -487,6 +490,78 @@ def prepare_props(project: Path, comp: str, timeline: Dict[str, Any], options: D
487
490
  return props_path, frame, note
488
491
 
489
492
 
493
+ # Mirrors DEFAULT_OPTIONS.fontFamily in src/timeline.ts: a brand font goes in front of it, so CJK
494
+ # and other scripts still fall back to a font that has them.
495
+ DEFAULT_FONT_STACK = ("'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', 'Noto Sans', 'Helvetica Neue', Arial, "
496
+ "sans-serif")
497
+
498
+
499
+ def _hex_colour(v: Any, where: str) -> str:
500
+ s = str(v).strip()
501
+ for prefix in ("#", "0x", "0X", "&H"):
502
+ if s.startswith(prefix):
503
+ s = s[len(prefix):]
504
+ if not re.fullmatch(r"[0-9a-fA-F]{6}", s):
505
+ die(f"{where}: {v!r} is not a colour (use RRGGBB, as ffmpeg-skill's brand.json does)", "input")
506
+ return "#" + s.upper()
507
+
508
+
509
+ def brand_look(path: str) -> Tuple[Dict[str, Any], Optional[str], List[str]]:
510
+ """ffmpeg-skill brand.json -> (options, font file, notes). Only what the file itself states is
511
+ used: ffmpeg-skill fills in defaults for the rest, and those are not the user's choice."""
512
+ bp = Path(path).expanduser()
513
+ if not bp.is_file():
514
+ die(f"brand file not found: {bp}", "input")
515
+ try:
516
+ data = json.loads(bp.read_text(encoding="utf-8"))
517
+ except ValueError as e:
518
+ die(f"{bp} is not valid JSON: {e}", "input")
519
+ if not isinstance(data, dict):
520
+ die(f"{bp} must hold a JSON object", "input")
521
+ opts: Dict[str, Any] = {}
522
+ colours = data.get("colors") or data.get("colours") or {}
523
+ if colours.get("primary"):
524
+ opts["accent"] = _hex_colour(colours["primary"], f"{bp.name} colors.primary")
525
+ if colours.get("text"):
526
+ opts["textColor"] = _hex_colour(colours["text"], f"{bp.name} colors.text")
527
+ # the caption block, with styles.caption winning (ffmpeg-skill's brand_caption_style)
528
+ style = dict(data.get("caption") or {})
529
+ style.update((data.get("styles") or {}).get("caption") or {})
530
+ colour = style.get("color", style.get("colour"))
531
+ if colour:
532
+ opts["textColor"] = _hex_colour(colour, f"{bp.name} caption colour")
533
+ font = style.get("font") or data.get("font")
534
+ if font:
535
+ opts["fontFamily"] = f"'{str(font).strip()}', {DEFAULT_FONT_STACK}"
536
+ font_file = data.get("font_file")
537
+ if font_file:
538
+ ff = Path(font_file).expanduser()
539
+ font_file = str(ff if ff.is_absolute() else (bp.resolve().parent / ff))
540
+ if not Path(font_file).is_file():
541
+ die(f"{bp.name} font_file not found: {font_file}", "input")
542
+ notes = []
543
+ if data.get("logo"):
544
+ notes.append("brand logo: placed on delivery (deliver.py / pipeline.py --brand), not in the composition")
545
+ unused = [k for k in ("size", "position", "animate", "box", "outline") if k in style]
546
+ if unused:
547
+ notes.append("brand caption " + ", ".join(unused) + ": ffmpeg-skill caption settings, not used by the "
548
+ "compositions (captionSize / captionMargin in --options set those)")
549
+ return opts, font_file, notes
550
+
551
+
552
+ def load_look(a: argparse.Namespace) -> Dict[str, Any]:
553
+ """Options for render.py / still.py: the brand file's look, then --options over it."""
554
+ options = load_options(a.options)
555
+ if not getattr(a, "brand", None):
556
+ return options
557
+ b, font_file, notes = brand_look(a.brand)
558
+ for n in notes:
559
+ info(n)
560
+ if font_file and not a.font_file:
561
+ a.font_file = font_file
562
+ return {**b, **options}
563
+
564
+
490
565
  def load_options(path: Optional[str]) -> Dict[str, Any]:
491
566
  if not path:
492
567
  return {}
@@ -10,8 +10,10 @@ Examples:
10
10
  python3 deliver.py titled.mp4 --platform youtube --chapters chapters.txt # + chapter markers
11
11
  """
12
12
  import argparse
13
+ import json
13
14
  import sys
14
15
  from pathlib import Path
16
+ from typing import Optional
15
17
 
16
18
  sys.path.insert(0, str(Path(__file__).resolve().parent))
17
19
  from _captions import parse_chapters
@@ -22,6 +24,21 @@ from _common import (STATE, add_common, apply_common, default_output, die, emit,
22
24
  PLATFORMS = ["youtube", "youtube-shorts", "shorts", "reels", "tiktok", "x", "facebook", "linkedin", "podcast", "audiogram"]
23
25
 
24
26
 
27
+ def brand_logo(brand: Optional[str]) -> Optional[Path]:
28
+ """The brand file's logo, relative to the brand file as ffmpeg-skill reads it."""
29
+ if not brand:
30
+ return None
31
+ bp = Path(brand).expanduser()
32
+ try:
33
+ logo = json.loads(bp.read_text(encoding="utf-8")).get("logo")
34
+ except (OSError, ValueError, AttributeError):
35
+ return None
36
+ if not logo:
37
+ return None
38
+ lp = Path(logo).expanduser()
39
+ return lp if lp.is_absolute() else bp.resolve().parent / lp
40
+
41
+
25
42
  def youtube_description(chapters_file: Path) -> str:
26
43
  """The chapter list as YouTube reads it from a description: `00:00 Title` per line."""
27
44
  chapters = parse_chapters(chapters_file.read_text(encoding="utf-8-sig"), 0)
@@ -42,6 +59,7 @@ def build_parser() -> argparse.ArgumentParser:
42
59
  p.add_argument("-o", "--output", help="deliverable path (default: <name>_<platform>.mp4)")
43
60
  p.add_argument("--check-only", action="store_true", help="run check.py only, write nothing")
44
61
  p.add_argument("--brand", help="ffmpeg-skill brand.json for the template (its logo, safe margins, loudness)")
62
+ p.add_argument("--logo", help="logo image the template places (default: the brand file's logo)")
45
63
  p.add_argument("--chapters", metavar="FILE",
46
64
  help="also write these chapters (`TIME TITLE` per line) into the deliverable with ffmpeg-skill "
47
65
  "metadata.py, plus the YouTube description block next to it (<name>_description.txt)")
@@ -70,9 +88,15 @@ def main() -> None:
70
88
  templated = out.with_name(out.stem + ".nochapters" + out.suffix) if a.chapters else out
71
89
  args = ["--template", a.platform, str(src), "-o", str(templated)]
72
90
  if a.brand:
73
- if not Path(a.brand).expanduser().is_file():
91
+ bp = Path(a.brand).expanduser().resolve()
92
+ if not bp.is_file():
74
93
  die(f"brand file not found: {a.brand}", "input")
75
- args += ["--brand", str(Path(a.brand).expanduser().resolve())]
94
+ args += ["--brand", str(bp)]
95
+ logo = Path(a.logo).expanduser() if a.logo else brand_logo(a.brand)
96
+ if logo:
97
+ if not logo.is_file():
98
+ die(f"logo not found: {logo}", "input")
99
+ args += ["--logo", str(logo.resolve())]
76
100
  if STATE.overwrite or a.chapters:
77
101
  args.append("--overwrite")
78
102
  description = out.with_name(out.stem + "_description.txt")
@@ -32,6 +32,7 @@ def build_parser() -> argparse.ArgumentParser:
32
32
  help="chapters (`TIME TITLE` per line, or `source`): cards in Titled and, with --platform, chapter "
33
33
  "markers in the deliverable")
34
34
  p.add_argument("--options", help="JSON options file passed to the composition")
35
+ p.add_argument("--brand", help="ffmpeg-skill brand.json: the look of the graphics and, on delivery, the logo")
35
36
  p.add_argument("--platform", choices=PLATFORMS, help="deliver with this ffmpeg-skill template and check it")
36
37
  p.add_argument("--out-dir", help="where the timeline, render and deliverable go (default: next to the input)")
37
38
  p.add_argument("--beats", action="store_true", help="measure the beat grid too")
@@ -101,14 +102,14 @@ def main() -> None:
101
102
  aspect = a.aspect or platform_aspect(a.platform)
102
103
  if aspect:
103
104
  r_args += ["--aspect", aspect]
104
- for flag, val in (("--width", a.width), ("--fit", a.fit), ("--font-file", a.font_file)):
105
+ for flag, val in (("--width", a.width), ("--fit", a.fit), ("--font-file", a.font_file), ("--brand", a.brand)):
105
106
  if val is not None:
106
107
  r_args += [flag, str(val)]
107
108
  rendered = step("draw", "render", r_args, steps)
108
109
 
109
110
  delivered = None
110
111
  if a.platform:
111
- de_args = [str(render_out), "--platform", a.platform]
112
+ de_args = [str(render_out), "--platform", a.platform] + (["--brand", a.brand] if a.brand else [])
112
113
  # chapter markers only when the picture keeps the source's clock (cuts would move every chapter)
113
114
  if a.chapters and a.chapters != "source" and a.comp not in ("Jumpcut", "Highlights"):
114
115
  de_args += ["--chapters", a.chapters]
package/scripts/render.py CHANGED
@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional, Tuple
17
17
  sys.path.insert(0, str(Path(__file__).resolve().parent))
18
18
  import _sparse
19
19
  from _common import (BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit, expected_frames,
20
- ffskill, ffskill_cmd, frame_size, info, load_options, load_timeline, prepare_props, refuse_existing,
20
+ ffskill, ffskill_cmd, frame_size, info, load_look, load_timeline, prepare_props, refuse_existing,
21
21
  remotion_bin, require_ffmpeg_skill, require_project, remotion_error, run, shell_join)
22
22
 
23
23
 
@@ -187,7 +187,7 @@ def main() -> None:
187
187
  timeline_path = Path(a.timeline).expanduser()
188
188
  timeline = load_timeline(timeline_path)
189
189
  project = require_project(Path(a.project).expanduser(), need_install=not STATE.dry_run)
190
- options = load_options(a.options)
190
+ options = load_look(a)
191
191
  frames = parse_frames(a.frames)
192
192
  require_ffmpeg_skill()
193
193
 
package/scripts/still.py CHANGED
@@ -14,7 +14,7 @@ from typing import List
14
14
 
15
15
  sys.path.insert(0, str(Path(__file__).resolve().parent))
16
16
  from _common import (BUILTIN_COMPOSITIONS, STATE, add_common, add_frame_args, apply_common, die, emit,
17
- expected_frames, info, load_options, load_timeline, prepare_props, refuse_existing, remotion_bin,
17
+ expected_frames, info, load_look, load_timeline, prepare_props, refuse_existing, remotion_bin,
18
18
  require_project, remotion_error, run, sec_to_frames, shell_join)
19
19
 
20
20
 
@@ -39,7 +39,7 @@ def main() -> None:
39
39
  tl_path = Path(a.timeline).expanduser()
40
40
  timeline = load_timeline(tl_path)
41
41
  project = require_project(Path(a.project).expanduser(), need_install=not STATE.dry_run)
42
- options = load_options(a.options)
42
+ options = load_look(a)
43
43
  fps = float(timeline["source"]["fps"])
44
44
 
45
45
  frames: List[int] = list(a.frame) + [sec_to_frames(t, fps) for t in a.at]