Skip to content

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

video-production

Verified

从零做一条完整成片时用:推广短片、知识讲解、故事短片、发布片、资讯快评、数据故事、排版动效、歌曲 MV 与歌词视频,或用户选了场景模板、作品示例说「做一条视频」。简报定下后,先写风格与角色设定、分镜与声音规划,再出参考图,逐镜用素材、生成图片或代码画面做出来,配旁白、混音、导出验收。只转录、加字幕、翻译、配音或剪已有视频时不用。

FileKindSize
.baocut-meta.jsonconfig2.2 KB
SKILL.mdskill md30.1 KB
examples/bundle-preview.htmlother17.7 KB
examples/post-fx.jsscript7.5 KB
references/code-scenes.mdmarkdown31.5 KB
references/shot-plan.mdmarkdown5.0 KB
references/sound-design.mdmarkdown4.2 KB
references/visuals.mdmarkdown19.5 KB

examples/bundle-preview.html

View on GitHub
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bundle preview</title>
<!--
  bundle-preview.html — 烘焙前给用户看代码画面:每段的代码包放进 iframe,跟着那段旁白的音频逐帧画,
  叠上字幕带与当前那句旁白,旁边放参考图。不导入、不烘焙,改了代码包刷新页面就能再看。

  用法:拷到工作目录(代码包、音频与时间文件都在它下面),写一份 preview.json,在这个目录起一个静态服务
  (例如 python3 -m http.server 8000),打开 /bundle-preview.html?config=preview.json。

  preview.json:
  {
    "caption": { "y": 75, "verticalAlign": "center", "fontSize": 30, "width": 80 },  // 与字幕样式同一套键;不给就不画字幕带
    "segments": [
      { "id": "s01", "bundle": "bundles/s01", "audio": "audio/s01.wav", "lines": "timing/s01.json", "ref": "ref/fig1.png", "note": "原文配图 1",
        "clips": [{ "src": "clips/s01-launch.mp4", "at": 6.6, "dur": 4.2, "label": "Footage: <source>" }] }
    ]
  }
  bundle 是代码包目录(入口 index.html);audio、lines、ref、note、clips 都可省。lines 是 [{ text, start, end }],
  或 { lines: [...] },秒数相对这一段的开头。没有 audio 时按页面时钟播放,时长取根元素的 data-duration。
  clips 是和代码画面一起播的实拍片段:at 是相对这一段开头的秒数,在 [at, at + dur) 里铺满盖在代码画面上面、跟着旁白走;
  顶层给 "clipsLayer": "under" 时反过来,实拍铺在最下面当底,透明的代码包(data-alpha 不是 false,只画卡片与标注)叠在它上面;
  label 显示在右上角;pip 为 { x, y, w } 时不铺满,放成画中画(x、y 框中心,w 框宽,画布百分比;高按片段的宽高比),label 在框的右上角;默认静音,audio 为 true 时出声,volume 是音量(0–1)。subs 是片段里的双语字幕
  [{ start, end, text, tr, who }](秒数相对片段开头;text 成片语言,tr 原话,who 说话人),播到时画在字幕带上。
  in / out 是片段一侧的转场 { kind, dur, easing }(kind 取 dissolve / wipe / slide / zoom / iris,dur 秒数),
  画法与视频格式一致,渐入渐出时露出下面的代码画面,原声音量跟着一起淡。勾上 chain 时一段的旁白播完自动接下一段。
  音频与片段先整个读成 blob 再播,python3 -m http.server 这类不支持 Range 的静态服务也能拖动。
  baocut/1(window.__baocutCompositions)与 hyperframes/1(window.__timelines)都认。
-->
<style>
  :root { color-scheme: dark; --bg: #111; --panel: #1d1d1d; --line: #333; --text: #eee; --dim: #999; --hi: #f2c14e; --err: #ff6b5b; }
  * { box-sizing: border-box; }
  body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, sans-serif; }
  header { display: flex; gap: 6px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
  button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; }
  button.on { background: var(--hi); color: #111; border-color: var(--hi); }
  main { display: grid; grid-template-columns: auto minmax(260px, 1fr); gap: 16px; padding: 16px; align-items: start; }
  .stage { position: relative; background: #000; overflow: hidden; }
  .stage iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; pointer-events: none; background: transparent; }
  .clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; pointer-events: none; }
  /* clipsLayer 为 under:实拍在最下面当底,透明的代码画面叠在上面;标签、字幕带仍在最上。
     iframe 的 color-scheme 要和包里的文档一致(包默认 light),不一致时浏览器会给 iframe 垫一层不透明的白底,透明的包就露不出实拍 */
  .stage.under iframe { z-index: 1; color-scheme: light; }
  .stage.under #clips { position: absolute; inset: 0; z-index: 0; }
  .stage.under .clipTag, .stage.under .band, .stage.under .cap { z-index: 2; }
  .clipTag { position: absolute; right: 2%; top: 3%; padding: .2em .6em; border-radius: .3em; background: rgba(0,0,0,.55); color: #ddd; font-size: 1.6vh; display: none; pointer-events: none; }
  .band { position: absolute; left: 0; right: 0; outline: 1px dashed rgba(242, 193, 78, .7); pointer-events: none; }
  .cap { position: absolute; text-align: center; color: #fff; font-weight: 700; text-shadow: 0 0 4px #000, 0 1px 3px #000; pointer-events: none; }
  .cap .who { color: #bbb; font-size: .7em; margin-right: .5em; }
  .cap .tr { font-size: .55em; font-weight: 400; }
  .ctrl { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
  .ctrl input[type=range] { flex: 1; }
  .tm { font-variant-numeric: tabular-nums; color: var(--dim); min-width: 90px; text-align: right; }
  .side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .side img { width: 100%; display: block; background: #fff; }
  ol { margin: 0; padding-left: 24px; }
  li { padding: 2px 6px; border-radius: 4px; cursor: pointer; color: var(--dim); }
  li.now { color: var(--text); background: var(--panel); }
  .dim { color: var(--dim); }
  .err { color: var(--err); white-space: pre-wrap; }
  @media (max-width: 760px) { main { grid-template-columns: 1fr; } }
</style>
</head>
<body>
<header id="tabs"></header>
<main>
  <div>
    <div class="stage" id="stage"><iframe id="fr"></iframe><div id="clips"></div><div class="clipTag" id="clipTag"></div><div class="band" id="band"></div><div class="cap" id="cap"></div></div>
    <div class="ctrl"><button id="play">▶</button><input type="range" id="seek" min="0" max="1000" value="0"><span class="tm" id="tm"></span></div>
    <div class="ctrl dim"><label><input type="checkbox" id="capOn" checked> caption band</label><label><input type="checkbox" id="chain" checked> chain</label><label><input type="checkbox" id="clipOn" checked> footage clips</label><span>Space play/pause · ← → 2 s · click a line to jump</span></div>
  </div>
  <div class="side"><div id="ref"></div><ol id="lines"></ol><div class="err" id="err"></div></div>
</main>
<audio id="au" preload="auto"></audio>
<script>
  const $ = id => document.getElementById(id);
  const q = new URLSearchParams(location.search);
  const au = $('au'), fr = $('fr');
  let CFG = null, seg = null, view = null, lines = [], dur = 0, clock = null, last = -1, token = 0, clips = [];

  const fresh = url => url + (url.includes('?') ? '&' : '?') + 'v=' + Date.now();
  const getJson = async url => (await fetch(fresh(url))).json();
  // 当前时刻:有音频跟音频走,没有就跟页面时钟走
  const now = () => (seg && seg.audio ? au.currentTime : clock ? Math.min(dur, clock.at + (performance.now() - clock.t0) / 1000) : view ? view.paused : 0);
  const playing = () => (seg && seg.audio ? !au.paused : !!clock);
  function seekTo(t) {
    t = Math.max(0, Math.min(dur, t));
    if (seg.audio) au.currentTime = t; else if (clock) clock = { at: t, t0: performance.now() }; else view.paused = t;
  }
  function toggle() {
    if (seg.audio) return au.paused ? au.play() : au.pause();
    if (clock) { view.paused = now(); clock = null; } else clock = { at: view.paused >= dur ? 0 : view.paused, t0: performance.now() };
  }

  function layout() {
    if (!view) return;
    const { w, h } = view, maxH = Math.max(320, innerHeight - 140), maxW = Math.max(320, innerWidth * 0.62);
    const s = Math.min(maxH / h, maxW / w);
    Object.assign($('stage').style, { width: w * s + 'px', height: h * s + 'px' });
    Object.assign(fr.style, { width: w + 'px', height: h + 'px', transform: `scale(${s})` });
    const c = CFG.caption;
    $('band').style.display = $('cap').style.display = c && $('capOn').checked ? '' : 'none';
    if (!c) return;
    // 和字幕样式同一套键:y 是锚线(画面高度的百分比),fontSize 按 540 短边计,width 是最大行宽
    const px = (c.fontSize ?? 30) * (Math.min(w, h) / 540) * s, bandH = px * 1.3 * 2;
    const anchor = (c.y ?? 86) / 100 * h * s, va = c.verticalAlign || 'center';
    const top = va === 'top' ? anchor : va === 'bottom' ? anchor - bandH : anchor - bandH / 2;
    const width = (c.width ?? 80) / 100 * w * s, left = (c.x ?? 50) / 100 * w * s - width / 2;
    Object.assign($('band').style, { top: top + 'px', height: bandH + 'px' });
    Object.assign($('cap').style, { top: top + 'px', left: left + 'px', width: width + 'px', fontSize: px + 'px', lineHeight: 1.3 });
  }

  async function load(s) {
    const my = ++token;
    seg = s; view = null; last = -1; clock = null; au.pause(); $('err').textContent = '';
    document.querySelectorAll('#tabs button').forEach(b => b.classList.toggle('on', b.dataset.id === s.id));
    q.set('id', s.id); history.replaceState(null, '', '?' + q);
    $('ref').innerHTML = s.ref ? `<img src="${fresh(s.ref)}" alt=""><div class="dim">${s.note || ''}</div>` : `<div class="dim">${s.note || ''}</div>`;
    lines = [];
    if (s.lines) { const j = await getJson(s.lines); lines = Array.isArray(j) ? j : j.lines || []; }
    $('lines').innerHTML = lines.map((l, i) => `<li data-i="${i}">${l.text}</li>`).join('');
    if (au.src.startsWith('blob:')) URL.revokeObjectURL(au.src);
    au.removeAttribute('src');
    // 整段读成 blob 再播:简单的静态服务不支持 Range 请求,直接给地址拖不动进度
    if (s.audio) au.src = URL.createObjectURL(await (await fetch(fresh(s.audio))).blob());
    for (const c of clips) URL.revokeObjectURL(c.el.src);
    $('clips').innerHTML = ''; clips = [];
    for (const c of s.clips || []) {
      const el = document.createElement('video');
      Object.assign(el, { className: 'clip', muted: !c.audio, volume: c.volume ?? 1, playsInline: true, preload: 'auto' });
      el.src = URL.createObjectURL(await (await fetch(fresh(c.src))).blob());
      $('clips').appendChild(el); clips.push({ ...c, el });
    }
    if (my !== token) return;
    // 入口加了时间戳,入口引用的脚本仍可能取到浏览器缓存的旧版:先按入口里的地址强制重取一遍,iframe 再加载时拿到的就是新的
    const entry = s.bundle.replace(/\/?$/, '/') + 'index.html', doc = new DOMParser().parseFromString(await (await fetch(fresh(entry))).text(), 'text/html');
    const refs = [...doc.querySelectorAll('script[src], link[rel=stylesheet][href]')].map(el => new URL(el.getAttribute('src') || el.getAttribute('href'), new URL(entry, location.href)).href);
    await Promise.all(refs.map(u => fetch(u, { cache: 'reload' }).catch(() => {})));
    if (my !== token) return;
    await new Promise(ok => { fr.onload = ok; fr.src = fresh(entry); });
    try {
      const w = fr.contentWindow, root = w.document.querySelector('[data-composition-id]');
      if (!root) throw new Error('no element with data-composition-id');
      const id = root.getAttribute('data-composition-id'), W = +root.dataset.width, H = +root.dataset.height, fps = +root.dataset.fps || 30;
      dur = +root.dataset.duration || 0;
      let render;
      for (let k = 0; k < 100 && !render; k++) {
        const c = w.__baocutCompositions && w.__baocutCompositions[id], tl = w.__timelines && w.__timelines[id];
        if (c) {
          await w.document.fonts.ready;
          if (c.initialize) await c.initialize({ compositionId: id, target: root, width: W, height: H, pixelRatio: 1, fps: { num: fps, den: 1 }, intrinsicFps: { num: fps, den: 1 }, durationFrames: Math.round(dur * fps), seed: id, parameters: {}, fonts: { ready: () => w.document.fonts.ready }, assets: { resolve: async a => { throw new Error('asset ' + a + ' is not available in preview'); } } });
          render = t => c.renderAt({ ticks: Math.round(t * 1e6), timescale: 1e6 }, {});
        } else if (tl) { if (tl.pause) tl.pause(); render = t => tl.seek(t); }
        else await new Promise(ok => setTimeout(ok, 100));
      }
      if (!render) throw new Error(`neither __baocutCompositions["${id}"] nor __timelines["${id}"] was registered`);
      if (my !== token) return;
      view = { w: W, h: H, render, paused: 0 };
      layout();
    } catch (e) { $('err').textContent = s.id + ': ' + e.message; }
  }

  function tick() {
    requestAnimationFrame(tick);
    if (!view) return;
    const t = now();
    if (clock && t >= dur) { view.paused = dur; clock = null; next(); }
    $('play').textContent = playing() ? '❚❚' : '▶';
    syncClips(t);
    if (t === last) return;
    last = t;
    try { view.render(t); } catch (e) { $('err').textContent = `${seg.id} @${t.toFixed(2)}s: ${e.message}`; }
    $('tm').textContent = `${t.toFixed(1)} / ${dur.toFixed(1)}`;
    $('seek').value = dur ? Math.round(t / dur * 1000) : 0;
    const k = lines.findIndex(l => t >= l.start - 0.05 && t < l.end + 0.3);
    document.querySelectorAll('#lines li').forEach((li, i) => li.classList.toggle('now', i === k));
    const sub = clipSub(t);
    if (sub) $('cap').innerHTML = `${sub.who ? `<span class="who">${esc(sub.who)}</span>` : ''}${esc(sub.text)}<div class="tr">${esc(sub.tr || '')}</div>`;
    else $('cap').textContent = k >= 0 ? lines[k].text : '';
  }
  const esc = s => String(s).replace(/[&<>]/g, ch => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' })[ch]);
  // 正在放的片段里,这一刻的双语字幕
  function clipSub(t) {
    if (!$('clipOn').checked) return null;
    for (const c of clips) if (c.subs && t >= c.at && t < c.at + c.dur) return c.subs.find(x => t - c.at >= x.start && t - c.at < x.end) || null;
    return null;
  }

  // 单侧转场,与视频格式的画法一致:e 是缓动后的进度,渐出时从片段末尾倒着算;缺的那一侧露出下面的代码画面
  const EASE = { linear: p => p, 'ease-in': p => p * p, 'ease-out': p => 1 - (1 - p) * (1 - p), 'ease-in-out': p => p * p * (3 - 2 * p) };
  function look(c, u) {
    const tr = c.in && u < c.in.dur ? c.in : c.out && u > c.dur - c.out.dur ? c.out : null;
    const st = { opacity: '', transform: '', clipPath: '' };
    if (!tr) return [st, 1];
    const p = tr === c.in ? u / tr.dur : (c.dur - u) / tr.dur, e = (EASE[tr.easing] || EASE['ease-in-out'])(Math.max(0, Math.min(1, p)));
    if (tr.kind === 'dissolve') st.opacity = e;
    else if (tr.kind === 'wipe') st.clipPath = `inset(0 ${(1 - e) * 100}% 0 0)`;
    else if (tr.kind === 'slide') { st.transform = `translateX(${(e - 1) * 100}%)`; st.opacity = e; }
    else if (tr.kind === 'zoom') { st.transform = `scale(${0.75 + 0.25 * e})`; st.opacity = e; }
    else if (tr.kind === 'iris') st.clipPath = `circle(${e * 50 * Math.SQRT2}% at 50% 50%)`;
    return [st, e];
  }
  // 实拍片段:落在 [at, at + dur) 里就铺满盖在代码画面上,跟着旁白走
  function syncClips(t) {
    let tag = '', tagE = 1, tagAt = { right: '', top: '' };
    for (const c of clips) {
      const on = $('clipOn').checked && t >= c.at && t < c.at + c.dur;
      c.el.style.display = on ? 'block' : 'none';
      if (!on) { if (!c.el.paused) c.el.pause(); continue; }
      const [st, e] = look(c, t - c.at);
      Object.assign(c.el.style, st, pipBox(c));
      if (c.audio) c.el.volume = Math.max(0, Math.min(1, (c.volume ?? 1) * e));
      tag = c.label || ''; tagE = e; tagAt = c.pip ? { right: 100 - c.pip.x - c.pip.w / 2 + 1 + '%', top: parseFloat(c.el.style.top) + 1.5 + '%' } : { right: '', top: '' };
      if (Math.abs(c.el.currentTime - (t - c.at)) > 0.25) c.el.currentTime = t - c.at;
      if (playing() && c.el.paused) c.el.play().catch(() => {}); else if (!playing() && !c.el.paused) c.el.pause();
    }
    $('clipTag').textContent = tag; $('clipTag').style.display = tag ? 'block' : 'none'; $('clipTag').style.opacity = tagE;
    Object.assign($('clipTag').style, tagAt);
  }
  // 画中画的框:x、y 是框中心、w 是框宽(画布的百分比),高按片段自己的宽高比,和视频格式的 pip 一样
  function pipBox(c) {
    if (!c.pip || !view) return { left: '', top: '', width: '', height: '' };
    const ar = c.el.videoWidth ? c.el.videoHeight / c.el.videoWidth : 9 / 16, h = c.pip.w * (view.w / view.h) * ar;
    return { left: c.pip.x - c.pip.w / 2 + '%', top: c.pip.y - h / 2 + '%', width: c.pip.w + '%', height: h + '%' };
  }
  // 连播:一段播完接下一段
  async function next() {
    const i = CFG.segments.indexOf(seg);
    if (!$('chain').checked || i < 0 || i + 1 >= CFG.segments.length) return;
    await load(CFG.segments[i + 1]);
    if (seg.audio) au.play(); else clock = { at: 0, t0: performance.now() };
  }
  au.addEventListener('ended', next);

  $('play').onclick = () => seg && toggle();
  $('seek').oninput = () => seg && seekTo($('seek').value / 1000 * dur);
  $('capOn').onchange = layout;
  $('lines').onclick = e => { const li = e.target.closest('li'); if (li) seekTo(lines[+li.dataset.i].start); };
  $('tabs').onclick = e => { const b = e.target.closest('button'); if (b) load(CFG.segments.find(s => s.id === b.dataset.id)); };
  addEventListener('resize', layout);
  addEventListener('keydown', e => {
    if (!seg) return;
    if (e.code === 'Space') { e.preventDefault(); toggle(); }
    if (e.code === 'ArrowLeft') seekTo(now() - 2);
    if (e.code === 'ArrowRight') seekTo(now() + 2);
  });
  // 自动核对用:跳到某一秒,等这一帧画好
  window.previewSeek = t => new Promise(ok => { seekTo(t); setTimeout(ok, 250); });

  (async () => {
    try {
      CFG = await getJson(q.get('config') || 'preview.json');
      $('stage').classList.toggle('under', CFG.clipsLayer === 'under');
      $('tabs').innerHTML = CFG.segments.map(s => `<button data-id="${s.id}">${s.id}</button>`).join('');
      tick();
      await load(CFG.segments.find(s => s.id === q.get('id')) || CFG.segments[0]);
    } catch (e) { $('err').textContent = 'config: ' + e.message; }
  })();
</script>
</body>
</html>
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: 198kUpdated 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