JimLiu/baocut / skills/baocut/built-in-skills/production-scripts
production-scripts
Verified有命令行环境、旁白按段配、画面按段上时间线的片子(讲解、解说混剪、旁白片、歌词视频……)要跑脚本时用:配音、对齐字时间、把场景代码打成代码包、按段摆上时间线并处理变长变短的波纹、按稿子建字幕、剪实拍与水印叠上去或垫在底下、量画面占比。脚本是一条省事的路,不规定片子的形态;形态和它不合时用 baocut CLI 自己写。只是加一段动效图形或配一句旁白时不用。
| File | Kind | Size |
|---|---|---|
| .baocut-meta.json | config | 2.8 KB |
| SKILL.md | skill md | 13.4 KB |
| references/pipeline.md | markdown | 37.3 KB |
| scene-kit/geo110.js | script | 27.3 KB |
| scene-kit/scene-kit.js | script | 38.3 KB |
| scripts/align.mjs | script | 11.6 KB |
| scripts/assemble.mjs | script | 26.4 KB |
| scripts/build.mjs | script | 18.1 KB |
| scripts/captions.mjs | script | 18.6 KB |
| scripts/clips.example.json | config | 3.2 KB |
| scripts/coverage.mjs | script | 10.0 KB |
| scripts/envelope.mjs | script | 2.9 KB |
| scripts/explainer.example.json | config | 2.2 KB |
| scripts/fonts.mjs | script | 7.0 KB |
| scripts/frames.mjs | script | 7.7 KB |
| scripts/gaps.mjs | script | 11.3 KB |
| scripts/host.mjs | script | 14.8 KB |
| scripts/legibility.mjs | script | 5.7 KB |
| scripts/level.mjs | script | 9.2 KB |
| scripts/lib.mjs | script | 19.3 KB |
| scripts/overlay.mjs | script | 34.7 KB |
| scripts/preview.mjs | script | 4.6 KB |
| scripts/quotes.mjs | script | 7.4 KB |
| scripts/sources.mjs | script | 6.2 KB |
| scripts/srt.mjs | script | 5.8 KB |
| scripts/voice.mjs | script | 7.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(' '));
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 197k | Updated | Claude CodeCodex | Verified | Install |
| 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: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| 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: 194k | Updated | Claude CodeCodex | Verified | Install |