Skip to content

TryWorld2026/paper-algorithm / skills/tryworld-paper

tryworld-paper

Verified

Create branded 试界TryWorld AI-knowledge videos in the fixed "Paper Algorithm" (纸上算法) style with HyperFrames. Input is a Chinese voiceover script and optional images; output is a 16:9 horizontal video with Azure YunxiNeural (真·云希) voiceover, word-synced captions, ink/paper animations and unified transitions, an always-visible anti-counterfeit red seal, plus horizontal (4:3) and vertical (3:4) cover images and platform-optimized titles for Bilibili/Douyin/Xiaohongshu. Brand values are theme-driven (themes/paper-algorithm.json by default; custom brand themes supported — see references/theme-guide.md). Use when the user provides an AI 科普/教程/内容解读/知识分享 script and wants a TryWorld/试界 branded video, asks for the 纸上算法/Paper Algorithm style, wants a consistent script-to-video pipeline with covers and titles, or wants this pipeline with their own brand theme.

scripts/verify_output.py

View on GitHub
#!/usr/bin/env python3
"""交付核验硬门禁:verify_output.py --dir <outputs 目录>

逐项检查交付物完整性,任何一项不通过则 exit 1(不交付)。
检查项:主视频存在且有音轨、时长>0 且与字幕时间轴一致、双封面存在且尺寸正确、
titles.txt 非空、发布计划.txt 存在、字幕时间轴存在。
"""
import argparse
import json
import os
import shutil
import subprocess
import sys
from pathlib import Path


def is_within_directory(path: Path, directory: Path) -> bool:
    """Return whether path resolves inside directory, including the directory itself."""
    try:
        path.resolve().relative_to(directory.resolve())
        return True
    except ValueError:
        return False


def find_bin(name: str) -> str | None:
    """Locate ffmpeg/ffprobe: PATH first, then env override, then WinGet locations.

    Kept in sync with tts_yunxi.find_bin so both scripts resolve the same binaries.
    """
    which = shutil.which(name)
    if which:
        return which
    env_dir = os.environ.get("HYPERFRAMES_FFMPEG_DIR") or os.environ.get("FFMPEG_BIN")
    if env_dir:
        candidate = Path(env_dir) / (name + ".exe")
        if candidate.exists():
            return str(candidate)
    localappdata = os.environ.get("LOCALAPPDATA", "")
    winget = Path(localappdata) / "Microsoft" / "WinGet" / "Packages"
    if winget.exists():
        for sub in sorted(winget.glob("Gyan.FFmpeg*/ffmpeg-*/bin")):
            candidate = sub / (name + ".exe")
            if candidate.exists():
                return str(candidate)
    return None


def ffprobe(path: Path, args: list[str]) -> str:
    binary = find_bin("ffprobe")
    if not binary:
        print("error: ffprobe 不可用(请安装 FFmpeg 并加入 PATH,或设置 HYPERFRAMES_FFMPEG_DIR / FFMPEG_BIN),无法执行核验。")
        sys.exit(2)
    try:
        r = subprocess.run(
            [binary, "-v", "error", *args, "-of", "default=noprint_wrappers=1:nokey=1", str(path)],
            capture_output=True, text=True,
        )
    except FileNotFoundError:
        print("error: ffprobe 不可用(请安装 FFmpeg 并加入 PATH,或设置 HYPERFRAMES_FFMPEG_DIR / FFMPEG_BIN),无法执行核验。")
        sys.exit(2)
    return r.stdout.strip() if r.returncode == 0 else ""



def _cover_brightness(path: Path) -> float | None:
    """Read first frame of image and return mean brightness 0-255. None if tools unavailable."""
    try:
        from PIL import Image
        import statistics
        img = Image.open(path).convert("L").resize((64, 64))
        return round(statistics.mean(img.getdata()), 1)
    except ImportError:
        pass
    except Exception:
        pass
    import tempfile
    ffmpeg = find_bin("ffmpeg")
    if not ffmpeg:
        return None
    try:
        with tempfile.NamedTemporaryFile(suffix=".gray", delete=False) as tmp:
            tmp_path = tmp.name
        subprocess.run([ffmpeg, "-y", "-i", str(path), "-vframes", "1",
                        "-f", "rawvideo", "-pix_fmt", "gray", tmp_path],
                       capture_output=True, check=True)
        data = Path(tmp_path).read_bytes()
        Path(tmp_path).unlink(missing_ok=True)
        if not data:
            return None
        sample = data[::16]
        return round(sum(sample) / len(sample), 1)
    except (subprocess.SubprocessError, OSError):
        return None

def main() -> int:
    ap = argparse.ArgumentParser(description="交付核验硬门禁")
    ap.add_argument("--dir", type=Path, default=Path("outputs"), help="outputs 目录")
    ap.add_argument("--video", type=Path, default=None, help="主视频路径(outputs 中有多个 mp4 时用于指定)")
    args = ap.parse_args()
    out = args.dir
    failures: list[str] = []

    def check(ok: bool, label: str, detail: str = "") -> None:
        mark = "PASS" if ok else "FAIL"
        print(f"[{mark}] {label}" + (f"  ({detail})" if detail else ""))
        if not ok:
            failures.append(label)

    # 1. 主视频唯一、有视频流与音轨
    videos = sorted(out.glob("*.mp4"))
    dur_f = 0.0
    video = args.video if args.video else (videos[0] if len(videos) == 1 else None)
    if video is None:
        if len(videos) > 1:
            check(False, "outputs 中恰好一个主视频 mp4",
                  f"发现 {len(videos)} 个:{'、'.join(v.name for v in videos)};删除多余文件,或用 --video 指定主视频")
        else:
            check(False, "主视频 *.mp4 存在")
    else:
        if not is_within_directory(video, out):
            check(False, "主视频位于 outputs 目录内", str(video))
        elif not video.is_file():
            check(False, "主视频存在(--video 指定的文件不存在)", str(video))
        else:
            streams = ffprobe(video, ["-show_entries", "stream=codec_type"])
            has_video = "video" in streams
            has_audio = "audio" in streams
            check(has_video, "主视频含视频流")
            check(has_audio, "主视频含音轨", "配音缺失即静音成片,禁止交付")
            dur = ffprobe(video, ["-show_entries", "format=duration"])
            try:
                dur_f = float(dur)
            except ValueError:
                dur_f = 0.0
            check(dur_f > 1, "主视频时长 > 1s", f"{dur_f:.1f}s")

    # 2. 字幕时间轴与主视频时长一致(±1s)
    tl_candidates = [out / "字幕时间轴_sentences.json", out / "sentences.json"]
    tl = next((f for f in tl_candidates if f.exists()), tl_candidates[0])
    if tl.exists() and video:
        try:
            total = json.loads(tl.read_text(encoding="utf-8")).get("totalDuration", 0)
            check(abs(total - dur_f) <= 1.0, "时间轴与主视频时长对齐", f"{total:.1f}s vs {dur_f:.1f}s")
        except (ValueError, json.JSONDecodeError):
            failures.append("时间轴 JSON 无法解析")
            print("[FAIL] 时间轴 JSON 无法解析")
    else:
        check(tl.exists(), "字幕时间轴_sentences.json 存在")

    # 3. 双封面存在且尺寸正确(兼容文档约定 cover_* 与中文交付命名)
    cover_specs = [
        (("封面_横版4x3.png", "cover_4x3.png"), (1920, 1440), "横版封面"),
        (("封面_竖版3x4.png", "cover_3x4.png"), (1080, 1440), "竖版封面"),
    ]
    for names, size, label in cover_specs:
        f = next((out / name for name in names if (out / name).exists()), out / names[0])
        name = f.name
        if not f.exists():
            check(False, f"{name} 存在")
            continue
        dim = ffprobe(f, ["-select_streams", "v:0", "-show_entries", "stream=width,height"])
        nums = [int(x) for x in dim.split() if x.strip().isdigit()]
        ok = len(nums) >= 2 and (nums[0], nums[1]) == size
        check(ok, f"{name} 尺寸 {size[0]}x{size[1]}", "x".join(str(n) for n in nums[:2]))
        # 黑帧检测:封面第一帧不应全黑(gsap.from 竞态的兜底防线)
        brightness = _cover_brightness(f)
        if brightness is not None:
            check(brightness > 8.0, f"{name} 非全黑(均值亮度 {brightness:.1f})",
                  "封面可能被截到透明帧(gsap.from 竞态);重新渲染封面" if brightness <= 8.0 else "")

    # 4. 标题与发布计划
    titles = out / "titles.txt"
    check(titles.exists() and titles.stat().st_size > 50, "titles.txt 存在且非空(3-5 个标题)")
    check((out / "发布计划.txt").exists(), "发布计划.txt 存在")

    print()
    if failures:
        print(f"核验未通过:{len(failures)} 项失败 → {', '.join(failures)}")
        print("不满足交付条件,禁止交付。")
        return 1
    print("核验全部通过,允许交付。")
    return 0


if __name__ == "__main__":
    sys.exit(main())
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 319kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall