Skip to content

JimLiu/baocut / skills/baocut/built-in-skills/production-scripts

production-scripts

Verified

有命令行环境、旁白按段配、画面按段上时间线的片子(讲解、解说混剪、旁白片、歌词视频……)要跑脚本时用:配音、对齐字时间、把场景代码打成代码包、按段摆上时间线并处理变长变短的波纹、按稿子建字幕、剪实拍与水印叠上去或垫在底下、量画面占比。脚本是一条省事的路,不规定片子的形态;形态和它不合时用 baocut CLI 自己写。只是加一段动效图形或配一句旁白时不用。

FileKindSize
.baocut-meta.jsonconfig2.8 KB
SKILL.mdskill md13.4 KB
references/pipeline.mdmarkdown37.3 KB
scene-kit/geo110.jsscript27.3 KB
scene-kit/scene-kit.jsscript38.3 KB
scripts/align.mjsscript11.6 KB
scripts/assemble.mjsscript26.4 KB
scripts/build.mjsscript18.1 KB
scripts/captions.mjsscript18.6 KB
scripts/clips.example.jsonconfig3.2 KB
scripts/coverage.mjsscript10.0 KB
scripts/envelope.mjsscript2.9 KB
scripts/explainer.example.jsonconfig2.2 KB
scripts/fonts.mjsscript7.0 KB
scripts/frames.mjsscript7.7 KB
scripts/gaps.mjsscript11.3 KB
scripts/host.mjsscript14.8 KB
scripts/legibility.mjsscript5.7 KB
scripts/level.mjsscript9.2 KB
scripts/lib.mjsscript19.3 KB
scripts/overlay.mjsscript34.7 KB
scripts/preview.mjsscript4.6 KB
scripts/quotes.mjsscript7.4 KB
scripts/sources.mjsscript6.2 KB
scripts/srt.mjsscript5.8 KB
scripts/voice.mjsscript7.7 KB

scripts/preview.mjs

View on GitHub
#!/usr/bin/env node
// i18n-ignore-file: 给智能体拷走用的独立脚本,日志与报错写英文
// 写 preview.json,给 video-production 的 examples/bundle-preview.html 用(页面拷到工程根目录,在根目录起静态服务打开)。
//   node tools/preview.mjs [--config <配置>]
// 每段:代码包、旁白音频(audio/<id>.<格式>;gaps.mjs 留过白的用 timing 里的 gapAudio)、对齐好的句子(timing/<id>.json),稿子里这一段的备注行当 note。
// 有 clips.json 时,落在这一段的实拍片段换算成 clips: [{ src, at, dur, label, audio }](at 是相对段首的秒数,
// 取所在句的开头,给了 cue 取 cue 被说到的时刻,gap 片段取旁白里留出的空白;同一段里后一个开始时截断)。src 是 overlay.mjs --preview 剪出的小片段。
// 片段的 pip(画中画框:x、y 中心,w 宽,画布百分比)照抄。片段带 subs 时换算成相对片段开头的 [{ start, end, text, tr, who }],页面画在字幕带上;audio 为数字时是原声音量。
// 最后一个片段超出段尾(旁白时长 + hold)时截到段尾并提示。片段的 in / out 转场照抄成 { kind, dur, easing }(长度不超过片段一半),和后一个片段首尾相接的那一侧去掉,与 overlay.mjs 放上时间线的一致。
// 字幕带的样式取配置的 preview.caption(与字幕样式同一套键),没有时取旁白字幕的 captions.style,都不给就不画。footage.layer 为 under 时写 clipsLayer: "under",页面把实拍铺在透明的代码画面下面。
import fs from 'node:fs';
import path from 'node:path';
import { loadConfig, readJson, writeJson, scriptNotes, clipTimes } from './lib.mjs';

const cfg = loadConfig();
const cl = readJson(cfg.abs(cfg.footage?.clips || 'clips.json'), { clips: [] });
const notes = scriptNotes(cfg);
const rel = p => path.relative(cfg.root, cfg.abs(p)).split(path.sep).join('/');
const missing = [];

const segments = cfg.order.map(id => {
  const tf = cfg.abs(cfg.dirs.timing, `${id}.json`);
  const tm = readJson(tf);
  if (!tm) missing.push(id);
  const mine = cl.clips.filter(c => c.seg === id), t0 = tm && mine.length ? clipTimes(tm, mine) : {};
  const clips = !tm ? [] : mine.map(c => ({
    src: rel(path.join(cfg.dirs.work, 'clips', `${c.id}.mp4`)),
    at: +t0[c.id].toFixed(3),
    dur: +(c.to - c.from).toFixed(3),
    label: c.label ?? cl.label ?? '',
    ...(c.audio ? { audio: true } : {}),
    ...(typeof c.audio === 'number' ? { volume: c.audio } : {}),
    ...(c.pip ? { pip: { x: c.pip.x, y: c.pip.y, w: c.pip.w } } : {}),
    ...(c.in ? { in: { kind: c.in.kind, dur: c.in.dur ?? 0.5, easing: c.in.easing || 'ease-in-out' } } : {}),
    ...(c.out ? { out: { kind: c.out.kind, dur: c.out.dur ?? 0.5, easing: c.out.easing || 'ease-in-out' } } : {}),
    ...(c.subs ? { subs: c.subs.map(x => ({ start: +(x.from - c.from).toFixed(3), end: +(x.to - c.from).toFixed(3), text: x.text, tr: x.tr, ...(x.who ? { who: x.who } : {}) })) } : {}),
  }));
  clips.sort((x, y) => x.at - y.at);
  const end = tm ? tm.dur + (cfg.hold[id] || 0) : Infinity;
  clips.forEach((c, i) => {
    if (clips[i + 1]) c.dur = +Math.min(c.dur, clips[i + 1].at - c.at).toFixed(3);
    else if (c.at + c.dur > end + 0.02) { console.log(`${id}: clip ${path.basename(c.src, '.mp4')} runs ${(c.at + c.dur - end).toFixed(2)}s past the segment end; cut there`); c.dur = +(end - c.at).toFixed(3); }
  });
  clips.forEach((c, i) => {
    const n = clips[i + 1];
    if (n && c.at + c.dur >= n.at - 1e-3) { delete c.out; delete n.in; }
    for (const k of ['in', 'out']) if (c[k]) c[k].dur = +Math.min(c[k].dur, c.dur / 2).toFixed(3);
  });
  for (const c of clips) if (!fs.existsSync(cfg.abs(c.src))) console.log(`${id}: ${c.src} missing; run overlay.mjs --preview`);
  const audio = tm?.gapAudio || path.join(cfg.dirs.audio, `${id}.${cfg.voice.format || 'wav'}`);
  return {
    id,
    bundle: rel(path.join(cfg.dirs.bundles, id)),
    ...(fs.existsSync(cfg.abs(audio)) ? { audio: rel(audio) } : {}),
    ...(tm ? { lines: rel(path.join(cfg.dirs.timing, `${id}.json`)) } : {}),
    note: notes[id] || '',
    ...(clips.length ? { clips } : {}),
  };
});
// footage.layer 为 under 时页面把实拍画在代码画面下面(包要透明:bundle.alpha)
const caption = cfg.preview?.caption ?? cfg.captions?.style;
writeJson(cfg.abs('preview.json'), { ...(caption ? { caption } : {}), ...(cfg.footage?.layer === 'under' ? { clipsLayer: 'under' } : {}), segments });
if (missing.length) console.log(`no timing yet for ${missing.join(', ')}; those play on the page clock`);
console.log(segments.map(s => `${s.id}${s.clips ? ` clips:${s.clips.length}` : ''}`).join('  '));
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall