CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

gamussa/reels-producer-skill

Write talking-head scripts and produce Instagram reels and YouTube shorts

1.07x
Quality

96%

Does it follow best practices?

Impact

98%

1.07x

Average score across 8 eval scenarios

SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

match_sheet.pyskills/reel-builder/scripts/

#!/usr/bin/env python3
"""Our frames above, reference frames below — judge a look against a target.

compare_grades.py compares grades on OUR frames. This is for the other
question: does our reel look like the reference the user pointed at? Row 1 is
our stills, row 2 the reference stills, every image scaled to one height and
padded to one width, so a verifier reads them side by side instead of from
memory. The procedure around it is references/look-match.md.

Reference frames are study material for the look only. Never put them in a
deliverable, a repo, or a published sheet.

Exit codes: 0 = sheet written, 1 = bad arguments or missing input, 2 = ffmpeg
missing or failed.

Usage:
  match_sheet.py --ours work/x_100.png work/x_400.png --ref ref/a.jpg ref/b.jpg \\
      --out work/match_v1.png [--height 640]
"""

import argparse
import subprocess
import sys
from pathlib import Path

DEFAULT_HEIGHT = 640
GAP = 8  # px between images in a row
ROW_GAP = 16  # px between the two rows
BG = "white"


def build_graph(n_ours, n_ref, height):
    """ffmpeg filter_complex for two rows; inputs are ours first, then ref."""
    parts, rows = [], []
    index = 0
    for label, n in (("ours", n_ours), ("ref", n_ref)):
        if not n:
            continue
        cells = []
        for j in range(n):
            # pad right by GAP on all but the last cell so cells never touch
            pad = f",pad=iw+{GAP}:ih:0:0:color={BG}" if j < n - 1 else ""
            parts.append(
                f"[{index}:v]scale=-2:{height}:flags=lanczos,format=rgb24{pad}[{label}{j}]"
            )
            cells.append(f"[{label}{j}]")
            index += 1
        if n == 1:
            parts.append(f"{cells[0]}null[{label}]")
        else:
            parts.append(f"{''.join(cells)}hstack=inputs={n}[{label}]")
        rows.append(label)
    if len(rows) == 1:
        return ";".join(parts), f"[{rows[0]}]"
    # gap under the top row; xstack sizes the canvas to the wider row and fills the rest
    parts.append(f"[ours]pad=iw:ih+{ROW_GAP}:0:0:color={BG}[top]")
    parts.append(f"[top][ref]xstack=inputs=2:layout=0_0|0_h0:fill={BG}[sheet]")
    return ";".join(parts), "[sheet]"


def main():
    ap = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
    )
    ap.add_argument("--ours", nargs="+", required=True, help="our stills")
    ap.add_argument("--ref", nargs="+", required=True, help="reference stills")
    ap.add_argument("--out", required=True)
    ap.add_argument("--height", type=int, default=DEFAULT_HEIGHT)
    a = ap.parse_args()

    missing = [p for p in a.ours + a.ref if not Path(p).is_file()]
    if missing:
        sys.exit(
            f"match_sheet: not found: {', '.join(missing)} — grab stills first "
            "(ffmpeg -ss <t> -i video -frames:v 1 still.png)"
        )
    graph, out_label = build_graph(len(a.ours), len(a.ref), a.height)
    cmd = ["ffmpeg", "-y", "-v", "error"]
    for p in a.ours + a.ref:
        cmd += ["-i", p]
    Path(a.out).parent.mkdir(parents=True, exist_ok=True)
    cmd += ["-filter_complex", graph, "-map", out_label, "-frames:v", "1", a.out]
    try:
        r = subprocess.run(cmd, capture_output=True, text=True)
    except FileNotFoundError:
        print("match_sheet: ffmpeg not found — install it (brew install ffmpeg)", file=sys.stderr)
        sys.exit(2)
    if r.returncode != 0:
        print(f"match_sheet: ffmpeg failed:\n{r.stderr[-600:]}", file=sys.stderr)
        sys.exit(2)
    print(a.out)


if __name__ == "__main__":
    main()

skills

tile.json