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/envelope.mjs
View on GitHub#!/usr/bin/env node
// i18n-ignore-file: 给智能体拷走用的独立脚本,日志与报错写英文
// 把一段录音量成一排条(RMS 包络),写成场景能直接读的 JS,给 scene-kit 的 K.bars() 画:
// node tools/envelope.mjs <录音> --out shared/speech-wave.js [--var SPEECH_WAVE] [--bars 240] [--from 秒] [--to 秒]
// 输出:window.<var> = { off, dur, bars: [0..1, …] }。off 是这排条从录音的第几秒起(--from,缺省 0),dur 是量的这段的秒数,
// bars 按 95 分位归一(最响的几条夹到 1),
// 开头的爆音不会把其余的压扁。视频里的录音剪掉了开头(报幕、空白)时带 --from 剪掉的秒数,声波才和视频里放的那段对得上;
// 场景拿录音的秒数(例如原声片段的 from / to)标位置时先减去 off。不读配置、不连 Runtime,只要本机有 ffmpeg。
import fs from 'node:fs';
import path from 'node:path';
import { execFileSync } from 'node:child_process';
import { audioWindow, parseArgs } from './lib.mjs';
const { ids, flags } = parseArgs(process.argv, ['out', 'var', 'bars', 'from', 'to']);
const [file] = ids;
if (!file || !flags.out) throw new Error('usage: envelope.mjs <audio> --out <file.js> [--var NAME] [--bars 240] [--from s] [--to s]');
const n = Math.round(+(flags.bars ?? 240));
if (!(n >= 8)) throw new Error(`--bars must be a number of bars (8 or more), got ${flags.bars}`);
const name = flags.var || 'SPEECH_WAVE';
if (!/^[A-Za-z_$][\w$]*$/.test(name)) throw new Error(`--var must be a JavaScript identifier, got ${name}`);
const RATE = 8000;
const from = flags.from != null ? +flags.from : 0;
const { input, filters } = audioWindow(from, flags.to != null ? +flags.to - from : null);
const pcm = execFileSync('ffmpeg', ['-v', 'error', ...input, '-i', file, '-vn', ...(filters.length ? ['-af', filters.join(',')] : []), '-ac', '1', '-ar', String(RATE), '-f', 's16le', '-'], { maxBuffer: 1 << 30 });
const total = pcm.length >> 1;
if (!total) throw new Error(`no audio decoded from ${file}`);
const rms = [];
for (let b = 0; b < n; b++) {
const s = Math.floor((b * total) / n), e = Math.max(s + 1, Math.floor(((b + 1) * total) / n));
let acc = 0;
for (let j = s; j < e; j++) { const v = pcm.readInt16LE(j * 2) / 32768; acc += v * v; }
rms.push(Math.sqrt(acc / (e - s)));
}
const top = [...rms].sort((a, b) => a - b)[Math.min(n - 1, Math.floor(n * 0.95))] || 1;
const bars = rms.map(v => +Math.min(1, v / top).toFixed(3));
const dur = +(total / RATE).toFixed(2), off = flags.from != null ? +flags.from : 0;
fs.mkdirSync(path.dirname(path.resolve(flags.out)), { recursive: true });
fs.writeFileSync(flags.out, `// envelope of ${path.basename(file)} from ${off} s (${dur} s), ${n} RMS bars; drawn with K.bars(), which takes recording seconds and subtracts off itself\nwindow.${name} = ${JSON.stringify({ off, dur, bars })};\n`);
console.log(`${flags.out}: window.${name}, ${n} bars over ${dur} s from ${off} s`);
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 |