Skip to content

norahe0304-art/30x-video / cli/skill

30x-web-to-video

Flagged

Use when a user gives a brand URL and wants a premium launch, demo, or marketing video. Zero-manual workflow — Claude runs the V2 orchestrator itself (scrapes brand evidence, auto-installs missing tools, generates the first-cut Remotion project). User only sees the URL and the Studio preview.

FileKindSize
.gitignoreother103 B
AGENTS.mdmarkdown2.5 KB
FUSION-REPORT.mdmarkdown12.3 KB
README.mdmarkdown3.6 KB
SKILL.mdskill md30.7 KB
benchmarks/AGENTS.mdmarkdown773 B
benchmarks/README.mdmarkdown2.8 KB
benchmarks/manifest.jsonconfig5.9 KB
examples/INDEX.mdmarkdown1.8 KB
examples/caylent/MainVideo.tsxother6.0 KB
examples/caylent/scenes-v2/Act1V2.tsxother1.9 KB
examples/caylent/scenes-v2/Act2V2.tsxother2.5 KB
examples/caylent/scenes-v2/Act3V2.tsxother11.3 KB
examples/caylent/scenes-v2/Act4V2.tsxother8.6 KB
examples/caylent/scenes-v2/Act5V2.tsxother1.0 KB
examples/caylent/scenes/Act1.tsxother6.0 KB
examples/caylent/scenes/Act2.tsxother2.5 KB
examples/caylent/scenes/Act3.tsxother7.4 KB
examples/caylent/scenes/Act4.tsxother7.1 KB
examples/caylent/scenes/Act5.tsxother2.2 KB
examples/caylent/theme.tsscript1.2 KB
examples/cofounder/MainVideo.tsxother5.5 KB
examples/cofounder/scenes/AGENTS.mdmarkdown1.4 KB
examples/cofounder/scenes/Act1.tsxother2.3 KB
examples/cofounder/scenes/Act2.tsxother2.4 KB
examples/cofounder/scenes/Act3a.tsxother6.7 KB
examples/cofounder/scenes/Act3b.tsxother8.5 KB
examples/cofounder/scenes/Act3c.tsxother6.8 KB
examples/cofounder/scenes/Act4.tsxother4.4 KB
examples/cofounder/scenes/Act5.tsxother3.3 KB
examples/cofounder/scenes/World.tsxother4.0 KB
examples/cofounder/theme.tsscript1.5 KB
examples/happy-model/MainVideo.tsxother6.8 KB
examples/happy-model/scenes/AGENTS.mdmarkdown1.7 KB
examples/happy-model/scenes/Act1.tsxother7.9 KB
examples/happy-model/scenes/Act2.tsxother10.2 KB
examples/happy-model/scenes/Act3.tsxother15.6 KB
examples/happy-model/scenes/Act4.tsxother16.9 KB
examples/happy-model/scenes/Act5.tsxother9.0 KB
examples/happy-model/scenes/copy.tsscript588 B
examples/happy-model/theme.tsscript1.2 KB
examples/mana/MainVideo.tsxother4.9 KB
examples/mana/scenes/AGENTS.mdmarkdown926 B
examples/mana/scenes/Act1Open.tsxother2.8 KB
examples/mana/scenes/Act2Hero.tsxother3.3 KB
examples/mana/scenes/Act3Flavors.tsxother9.0 KB
examples/mana/scenes/Act4Label.tsxother7.3 KB
examples/mana/scenes/Act5Close.tsxother4.7 KB
examples/mana/scenes/World.tsxother7.2 KB
examples/mana/theme.tsscript2.6 KB
examples/parker/MainVideo.tsxother6.2 KB
examples/parker/scenes/AGENTS.mdmarkdown1.1 KB
examples/parker/scenes/Act1Hook.tsxother3.2 KB
examples/parker/scenes/Act2Meet.tsxother2.3 KB
examples/parker/scenes/Act2Problem.tsxother3.6 KB
examples/parker/scenes/Act3Steps.tsxother4.7 KB
examples/parker/scenes/Act4Proof.tsxother3.2 KB
examples/parker/scenes/Act5Close.tsxother2.6 KB
examples/parker/scenes/PaperWorld.tsxother6.8 KB
examples/parker/theme.tsscript1.6 KB
examples/perplexity-pc/MainVideo.tsxother4.5 KB
examples/perplexity-pc/scenes/Act1.tsxother2.1 KB
examples/perplexity-pc/scenes/Act2.tsxother2.7 KB
examples/perplexity-pc/scenes/Act3.tsxother3.1 KB
examples/perplexity-pc/scenes/Act4.tsxother1.6 KB
examples/perplexity-pc/scenes/Act5.tsxother2.0 KB
examples/perplexity-pc/theme.tsscript2.5 KB
references/AGENTS.mdmarkdown767 B
references/animations.mdmarkdown15.1 KB
references/audio.mdmarkdown8.6 KB
references/components.mdmarkdown9.5 KB
references/lottie.mdmarkdown5.1 KB
references/visual-effects.mdmarkdown5.0 KB
rules/AGENTS.mdmarkdown3.0 KB
rules/archetypes.mdmarkdown6.0 KB
rules/artifact-catalog.mdmarkdown10.8 KB
rules/beat-sync.mdmarkdown5.7 KB
rules/cards.mdmarkdown2.5 KB
rules/cinematic.mdmarkdown6.7 KB
rules/color.mdmarkdown2.2 KB
rules/composition.mdmarkdown13.2 KB
rules/creative-moves.mdmarkdown3.8 KB
rules/data-viz.mdmarkdown1.9 KB
rules/finish-gate.mdmarkdown5.2 KB
rules/layout.mdmarkdown6.6 KB
rules/media-resolve.mdmarkdown7.1 KB
rules/motion.mdmarkdown9.5 KB
rules/narration-sync.mdmarkdown5.5 KB
rules/narrative-templates.mdmarkdown10.4 KB
rules/narrative.mdmarkdown7.3 KB
rules/qc-gates.mdmarkdown11.3 KB
rules/taste.mdmarkdown12.6 KB
rules/transitions.mdmarkdown2.7 KB
rules/typography.mdmarkdown4.1 KB
rules/ui-mockups.mdmarkdown5.6 KB
rules/workflow.mdmarkdown53.2 KB
scaffold/.prettierrcother66 B
scaffold/AGENTS.mdmarkdown1.1 KB
scaffold/eslint.config.mjsscript79 B
scaffold/package-lock.jsonmanifest186.3 KB
scaffold/package.jsonmanifest1.5 KB
scaffold/remotion.config.tsscript219 B
scaffold/src/AGENTS.mdmarkdown831 B
scaffold/src/MainVideo.tsxother41.7 KB
scaffold/src/Root.tsxother2.3 KB
scaffold/src/components/AGENTS.mdmarkdown1.5 KB
scaffold/src/components/Animations.tsxother6.8 KB
scaffold/src/components/Atmosphere.tsxother8.1 KB
scaffold/src/components/Background.tsxother4.5 KB
scaffold/src/components/Captions.tsxother6.4 KB
scaffold/src/components/LogoEntrance.tsxother15.2 KB
scaffold/src/components/MockupTemplates.tsxother19.0 KB
scaffold/src/components/PhoneFrame.tsxother3.6 KB
scaffold/src/components/ShaderFX.tsxother5.3 KB
scaffold/src/components/Transitions.tsxother8.4 KB
scaffold/src/components/UI.tsxother3.0 KB
scaffold/src/components/VisualEffects.tsxother10.7 KB
scaffold/src/generated/AGENTS.mdmarkdown508 B
scaffold/src/generated/beat-map.tsscript1.1 KB
scaffold/src/generated/project-data.tsscript5.2 KB
scaffold/src/index.cssother576 B
scaffold/src/index.tsscript400 B
scaffold/src/lib/AGENTS.mdmarkdown411 B
scaffold/src/lib/fonts.tsscript867 B
scaffold/src/lib/modes.tsscript2.2 KB
scaffold/src/lib/utils.tsscript352 B
scaffold/src/theme.tsscript2.5 KB
scaffold/tsconfig.jsonconfig333 B
scripts/AGENTS.mdmarkdown2.4 KB
scripts/analyze-audiomap.pyscript13.3 KB
scripts/beat-sync.tsscript12.1 KB
scripts/benchmark-suite.tsscript17.8 KB
scripts/critique-scenes.tsscript10.1 KB
scripts/evidence-model.tsscript9.4 KB
scripts/generate-bgm.pyscript10.5 KB
scripts/iterate.tsscript4.0 KB
scripts/project-blueprint.tsscript12.1 KB
scripts/regenerate-scene.tsscript7.4 KB
scripts/render-qa.tsscript9.0 KB
scripts/scene-constitution.tsscript13.4 KB
scripts/timing-audit.tsscript9.5 KB
scripts/url-to-video.tsscript68.6 KB
scripts/visual-audit.tsscript26.5 KB

scripts/beat-sync.ts

View on GitHub
/**
 * [INPUT]: BGM audio file (mp3/wav), aubiotrack preferred / ffmpeg fallback, fps flag
 * [OUTPUT]: public/brand/beat-map.json + src/generated/beat-map.ts (auto-consumed by MainVideo.tsx)
 * [POS]: Standalone CLI — 把音频节拍固化为常量, 让 MainVideo 不再需要人肉贴 BPM;
 *        现为 legacy 脉冲常量载体 — 转场/动效时机的真相源是 analyze-audiomap.py 的
 *        audiomap.json (rules/beat-sync.md); bpm 与 audiomap 偏差 >2% 时以 audiomap 为准
 * [PROTOCOL]: 变更时更新此头部,然后检查 AGENTS.md
 */

// ================================================================
//  BEAT-SYNC V2 — aubiotrack → beat-map → auto-consumed constants
//  Run: npx tsx scripts/beat-sync.ts public/brand/bgm.mp3 [--fps 30]
//
//  Outputs:
//    public/brand/beat-map.json   — reference data for debugging
//    src/generated/beat-map.ts    — typed module imported by MainVideo.tsx
//
//  Shape:
//    {
//      bpm: 116.5,
//      firstBeatSec: 3.037,
//      firstBeatFrame: 91,         // ← consumed by MainVideo
//      beatIntervalSec: 0.515,
//      beatIntervalFrames: 15.45,
//      measureFrames: 61.8,        // ← consumed by MainVideo (4 beats/measure)
//      fps: 30,
//      source: "aubiotrack" | "ffmpeg-onset" | "fallback-default",
//      confidence: "high" | "medium" | "low",
//    }
//
//  NEVER reverts to a hardcoded 120 BPM guess silently. If aubiotrack is
//  missing, the script emits source="fallback-default" and the MainVideo
//  beat pulse will still run but you should install aubiotrack before
//  final render — the 3% tempo error compounds visibly across 40 seconds.
// ================================================================

import { execSync } from "child_process";
import { existsSync, mkdirSync, writeFileSync } from "fs";
import { dirname, join, resolve } from "path";

// ----------------------------------------------------------------
//  Types
// ----------------------------------------------------------------

type Source = "aubiotrack" | "ffmpeg-onset" | "fallback-default";
type Confidence = "high" | "medium" | "low";

interface BeatMap {
  bpm: number;
  firstBeatSec: number;
  firstBeatFrame: number;
  beatIntervalSec: number;
  beatIntervalFrames: number;
  measureFrames: number;
  fps: number;
  source: Source;
  confidence: Confidence;
  generatedAt: string;
}

// ----------------------------------------------------------------
//  CLI
// ----------------------------------------------------------------

function parseArgs(): { audioPath: string; fps: number } {
  const args = process.argv.slice(2);
  let audioPath = "";
  let fps = 30;

  for (let i = 0; i < args.length; i++) {
    if (args[i] === "--fps" && args[i + 1]) {
      fps = Number(args[i + 1]);
      i++;
    } else if (!args[i].startsWith("--")) {
      audioPath = resolve(args[i]);
    }
  }

  if (!audioPath) {
    console.error("Usage: npx tsx scripts/beat-sync.ts <audio-file> [--fps 30]");
    console.error("Example: npx tsx scripts/beat-sync.ts public/brand/bgm.mp3");
    process.exit(2);
  }

  if (!existsSync(audioPath)) {
    console.error(`ERROR: audio file not found: ${audioPath}`);
    process.exit(2);
  }

  return { audioPath, fps };
}

function hasCommand(cmd: string): boolean {
  try {
    execSync(`command -v ${cmd}`, { stdio: "ignore" });
    return true;
  } catch {
    return false;
  }
}

// ----------------------------------------------------------------
//  aubiotrack (preferred)
// ----------------------------------------------------------------

function detectViaAubiotrack(audioPath: string): { beats: number[] } | null {
  if (!hasCommand("aubiotrack")) {
    console.warn("⚠ aubiotrack not found on PATH — falling back to ffmpeg onset detection.");
    console.warn("  Install: brew install aubio");
    return null;
  }
  try {
    const raw = execSync(`aubiotrack -i "${audioPath}"`, {
      encoding: "utf-8",
      maxBuffer: 10 * 1024 * 1024,
    });
    const beats = raw
      .split("\n")
      .map((line) => parseFloat(line.trim()))
      .filter((v) => Number.isFinite(v) && v > 0);
    if (beats.length < 4) {
      console.warn(`⚠ aubiotrack returned only ${beats.length} beats — likely a non-rhythmic track`);
      return null;
    }
    return { beats };
  } catch (err) {
    console.warn(`⚠ aubiotrack failed: ${(err as Error).message}`);
    return null;
  }
}

// ----------------------------------------------------------------
//  ffmpeg onset fallback (worse, but better than default)
// ----------------------------------------------------------------

function detectViaFfmpeg(audioPath: string): { beats: number[] } | null {
  if (!hasCommand("ffmpeg")) return null;
  try {
    // Extract mono waveform amplitude envelope at 8kHz → 1px/sample
    const raw = execSync(
      `ffmpeg -i "${audioPath}" -af "aresample=8000,aformat=channel_layouts=mono,showwavespic=s=2000x1:colors=white" -frames:v 1 -f rawvideo -pix_fmt gray - 2>/dev/null | od -An -tu1 -w1 -v`,
      { encoding: "utf-8", maxBuffer: 10 * 1024 * 1024 },
    );
    const values = raw
      .split("\n")
      .map((v) => parseInt(v.trim(), 10))
      .filter((v) => !isNaN(v));
    if (values.length < 100) return null;

    const durationSec = getAudioDuration(audioPath);
    const samplesPerSec = values.length / durationSec;
    const window = 20;
    const beats: number[] = [];
    for (let i = window; i < values.length - window; i++) {
      const cur = values[i];
      let prev = 0;
      let next = 0;
      for (let k = 1; k <= window; k++) {
        prev += values[i - k];
        next += values[i + k];
      }
      prev /= window;
      next /= window;
      if (cur > prev * 1.3 && cur > next * 1.1 && cur > 100) {
        const t = i / samplesPerSec;
        if (beats.length === 0 || t - beats[beats.length - 1] > 0.3) beats.push(t);
      }
    }
    return beats.length >= 4 ? { beats } : null;
  } catch {
    return null;
  }
}

function getAudioDuration(audioPath: string): number {
  const out = execSync(
    `ffprobe -v quiet -show_entries format=duration -of csv=p=0 "${audioPath}"`,
    { encoding: "utf-8" },
  ).trim();
  return parseFloat(out);
}

// ----------------------------------------------------------------
//  Beat → interval distillation
// ----------------------------------------------------------------

function distill(beats: number[]): { firstBeatSec: number; beatIntervalSec: number } {
  const firstBeatSec = beats[0];
  // Compute diffs and histogram-bucket to nearest 0.01s
  const diffs: number[] = [];
  for (let i = 1; i < beats.length; i++) {
    const d = beats[i] - beats[i - 1];
    if (d >= 0.25 && d <= 1.2) diffs.push(d); // 50-240 BPM range
  }
  if (diffs.length === 0) return { firstBeatSec, beatIntervalSec: 0.5 };

  const buckets = new Map<number, number>();
  for (const d of diffs) {
    const q = Math.round(d / 0.01) * 0.01;
    buckets.set(q, (buckets.get(q) || 0) + 1);
  }
  let bestInterval = 0.5;
  let bestCount = 0;
  for (const [interval, count] of buckets) {
    if (count > bestCount) {
      bestCount = count;
      bestInterval = interval;
    }
  }
  return { firstBeatSec, beatIntervalSec: bestInterval };
}

// ----------------------------------------------------------------
//  Assembly
// ----------------------------------------------------------------

function assemble(
  firstBeatSec: number,
  beatIntervalSec: number,
  fps: number,
  source: Source,
  confidence: Confidence,
): BeatMap {
  const bpm = Math.round((60 / beatIntervalSec) * 10) / 10;
  const beatIntervalFrames = beatIntervalSec * fps;
  const measureFrames = beatIntervalFrames * 4;
  const firstBeatFrame = Math.round(firstBeatSec * fps);
  return {
    bpm,
    firstBeatSec: Math.round(firstBeatSec * 1000) / 1000,
    firstBeatFrame,
    beatIntervalSec: Math.round(beatIntervalSec * 1000) / 1000,
    beatIntervalFrames: Math.round(beatIntervalFrames * 100) / 100,
    measureFrames: Math.round(measureFrames * 100) / 100,
    fps,
    source,
    confidence,
    generatedAt: new Date().toISOString(),
  };
}

function fallbackDefault(fps: number): BeatMap {
  // 120 BPM, first beat at frame 0 — SAME as "no beat sync at all"
  // Flagged low-confidence so visual-audit can WARN
  return assemble(0, 0.5, fps, "fallback-default", "low");
}

// ----------------------------------------------------------------
//  File writers
// ----------------------------------------------------------------

function writeJson(beatMap: BeatMap): string {
  const outDir = join(process.cwd(), "public", "brand");
  if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
  const outPath = join(outDir, "beat-map.json");
  writeFileSync(outPath, JSON.stringify(beatMap, null, 2));
  return outPath;
}

function writeTs(beatMap: BeatMap): string {
  const outDir = join(process.cwd(), "src", "generated");
  if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
  const outPath = join(outDir, "beat-map.ts");
  const body = `/**
 * [INPUT]: scripts/beat-sync.ts (aubiotrack → beat-map.json → this file)
 * [OUTPUT]: beatMap constant consumed by MainVideo.tsx for downbeat-only pulse sync
 * [POS]: 音乐节拍常量, 自动生成, 禁止手工编辑
 * [PROTOCOL]: 由 beat-sync 脚本重写,不要手动修改
 *
 * Regenerate:
 *   npx tsx scripts/beat-sync.ts public/brand/bgm.mp3
 *
 * source: ${beatMap.source}
 * confidence: ${beatMap.confidence}
 * generated: ${beatMap.generatedAt}
 */
export interface BeatMap {
  bpm: number;
  firstBeatSec: number;
  firstBeatFrame: number;
  beatIntervalSec: number;
  beatIntervalFrames: number;
  measureFrames: number;
  fps: number;
  source: "aubiotrack" | "ffmpeg-onset" | "fallback-default";
  confidence: "high" | "medium" | "low";
  generatedAt: string;
}

export const beatMap: BeatMap = ${JSON.stringify(beatMap, null, 2)};
`;
  writeFileSync(outPath, body);
  return outPath;
}

// ----------------------------------------------------------------
//  Main
// ----------------------------------------------------------------

function main(): void {
  const { audioPath, fps } = parseArgs();
  console.log(`BEAT-SYNC V2`);
  console.log(`  audio: ${audioPath}`);
  console.log(`  fps:   ${fps}`);
  console.log("");

  let beatMap: BeatMap;

  const fromAubio = detectViaAubiotrack(audioPath);
  if (fromAubio) {
    const { firstBeatSec, beatIntervalSec } = distill(fromAubio.beats);
    beatMap = assemble(firstBeatSec, beatIntervalSec, fps, "aubiotrack", "high");
    console.log(`✓ aubiotrack: ${fromAubio.beats.length} beats detected`);
  } else {
    const fromFfmpeg = detectViaFfmpeg(audioPath);
    if (fromFfmpeg) {
      const { firstBeatSec, beatIntervalSec } = distill(fromFfmpeg.beats);
      beatMap = assemble(firstBeatSec, beatIntervalSec, fps, "ffmpeg-onset", "medium");
      console.log(`✓ ffmpeg onset: ${fromFfmpeg.beats.length} onsets detected (install aubio for higher accuracy)`);
    } else {
      beatMap = fallbackDefault(fps);
      console.warn("✗ no beat detection available — wrote fallback (120 BPM, first beat = 0)");
      console.warn("  → INSTALL aubiotrack before final render: brew install aubio");
    }
  }

  const jsonPath = writeJson(beatMap);
  const tsPath = writeTs(beatMap);

  console.log("");
  console.log(`BPM:             ${beatMap.bpm}`);
  console.log(`First beat:      ${beatMap.firstBeatSec}s (frame ${beatMap.firstBeatFrame})`);
  console.log(`Beat interval:   ${beatMap.beatIntervalSec}s (${beatMap.beatIntervalFrames}f)`);
  console.log(`Measure frames:  ${beatMap.measureFrames}f (${(beatMap.measureFrames / fps).toFixed(2)}s, 4 beats)`);
  console.log(`Source:          ${beatMap.source} (${beatMap.confidence} confidence)`);
  console.log("");
  console.log(`Wrote: ${jsonPath}`);
  console.log(`Wrote: ${tsPath}`);
  console.log("");
  console.log(`MainVideo.tsx already imports from src/generated/beat-map.ts — no manual copy needed.`);

  if (beatMap.confidence === "low") {
    console.warn("");
    console.warn("⚠ LOW CONFIDENCE: beat pulse will drift against real music.");
    console.warn("  Visual-audit will WARN until you install aubiotrack and re-run.");
  }
}

main();

// Silence unused warning — dirname is not needed here but we keep the import for consistency with other scripts.
void dirname;
planning-and-task-breakdownaddyosmani/agent-skillsBreaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
screenpipethedotmack/claude-memSearch screen and audio history recorded by Screenpipe and optionally save selected context into claude-mem. Use when the user asks to recall desktop activity, a meeting, or something seen in another app through Screenpipe.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
contact-widgetnexu-io/open-designSelf-contained floating chat widget with welcome screen, social links, meeting button, and message input. Single HTML file, zero dependencies.Stars: 108kUpdated Claude CodeCodexVerifiedInstall
meeting-notesnexu-io/open-designMeeting notes page — title bar with attendees, agenda checklist, decisions block, action items table with owners + dates, and a "next meeting" footer. Use when the brief mentions "meeting notes", "minutes", "1:1 notes", "all-hands recap", or "会议纪要".Stars: 108kUpdated Claude CodeCodexVerifiedInstall