Skip to content

Diogenesoftoronto/keating / video/keating-surface-tour/.agents/skills/media-use

media-use

Flagged

Agent Media OS, the single skill for every media need in a HyperFrames project. Resolve BGM, SFX, image, icon, brand logo, voice, color grade, or LUT into a frozen local file or paste-ready block + ledger record (one verb, `resolve`); generate via TTS / music / image models when the catalog misses; produce voiceover, transcription, captions, and background removal through one shared audio engine; operate on media (cut / reframe / transform); and reuse assets across projects. Also use for vague feedback that real footage looks dark, flat, boring, should feel retro/camcorder/print/ASCII, needs privacy, or needs a media reveal.

FileKindSize
.gitignoreother17 B
SKILL.mdskill md7.8 KB
audio/assets/sfx/CREDITS.mdmarkdown1.2 KB
audio/assets/sfx/chime.mp3binary26.7 KB
audio/assets/sfx/click-soft.mp3binary11.4 KB
audio/assets/sfx/click.mp3binary11.4 KB
audio/assets/sfx/error.mp3binary50.6 KB
audio/assets/sfx/glitch-1.mp3binary82.4 KB
audio/assets/sfx/glitch-2.mp3binary109.5 KB
audio/assets/sfx/glitch-3.mp3binary96.8 KB
audio/assets/sfx/impact-bass-1.mp3binary66.1 KB
audio/assets/sfx/impact-bass-2.mp3binary81.0 KB
audio/assets/sfx/key-press.mp3binary3.8 KB
audio/assets/sfx/manifest.jsonconfig3.6 KB
audio/assets/sfx/notification.mp3binary76.7 KB
audio/assets/sfx/ping.mp3binary25.8 KB
audio/assets/sfx/pop.mp3binary22.5 KB
audio/assets/sfx/riser.mp3binary313.5 KB
audio/assets/sfx/sparkle.mp3binary56.3 KB
audio/assets/sfx/typing.mp3binary26.2 KB
audio/assets/sfx/whoosh-cinematic.mp3binary173.3 KB
audio/assets/sfx/whoosh-short.mp3binary18.0 KB
audio/assets/sfx/whoosh.mp3binary18.0 KB
audio/references/bgm.mdmarkdown7.8 KB
audio/references/captions/authoring.mdmarkdown8.8 KB
audio/references/captions/motion.mdmarkdown5.5 KB
audio/references/captions/transcript-handling.mdmarkdown5.3 KB
audio/references/remove-background.mdmarkdown8.3 KB
audio/references/requirements.mdmarkdown4.2 KB
audio/references/sfx.mdmarkdown3.4 KB
audio/references/transcribe.mdmarkdown2.7 KB
audio/references/tts-to-captions.mdmarkdown1.2 KB
audio/references/tts.mdmarkdown8.6 KB
audio/scripts/audio.mjsscript12.5 KB
audio/scripts/audio.test.mjsscript1.9 KB
audio/scripts/heygen-tts.mjsexecutablescript4.2 KB
audio/scripts/lib/bgm.mjsscript11.3 KB
audio/scripts/lib/bgm.test.mjsscript1.2 KB
audio/scripts/lib/concurrency.mjsscript527 B
audio/scripts/lib/concurrency.test.mjsscript1.6 KB
audio/scripts/lib/heygen.mjsscript6.9 KB
audio/scripts/lib/heygen.test.mjsscript3.5 KB
audio/scripts/lib/python.mjsscript2.5 KB
audio/scripts/lib/python.test.mjsscript2.6 KB
audio/scripts/lib/sfx.mjsscript5.3 KB
audio/scripts/lib/sfx.test.mjsscript2.8 KB
audio/scripts/lib/tts.mjsscript16.1 KB
audio/scripts/lib/tts.spawn.test.mjsscript5.1 KB
audio/scripts/lib/tts.test.mjsscript6.0 KB
audio/scripts/lyria-recipe.pyscript4.4 KB
audio/scripts/wait-bgm.mjsscript5.4 KB
luts/README.mdmarkdown1.1 KB
luts/index.jsonconfig2.0 KB
references/audio.mdmarkdown1.7 KB
references/grading.mdmarkdown6.6 KB
references/media-treatment-recipes.mdmarkdown35.0 KB
references/media-treatments.mdmarkdown13.6 KB
references/memory.mdmarkdown3.3 KB
references/meta.mdmarkdown6.6 KB
references/operations.mdmarkdown14.1 KB
references/resolve.mdmarkdown8.8 KB
references/setup-providers.mdmarkdown7.1 KB
references/telemetry-dashboard.mdmarkdown4.1 KB
scripts/audio-duck.mjsscript3.9 KB
scripts/dither.mjsscript9.7 KB
scripts/dither.test.mjsscript4.6 KB
scripts/eval.mjsscript14.5 KB
scripts/lib/adopt.mjsscript4.3 KB
scripts/lib/adopt.test.mjsscript2.7 KB
scripts/lib/bgm-provider.mjsscript650 B
scripts/lib/brand-provider.mjsscript1.6 KB
scripts/lib/bundled-sfx-provider.mjsscript3.5 KB
scripts/lib/bundled-sfx-provider.test.mjsscript3.1 KB
scripts/lib/cache.mjsscript4.8 KB
scripts/lib/candidates.mjsscript4.0 KB
scripts/lib/candidates.test.mjsscript5.9 KB
scripts/lib/codex-provider.mjsscript6.5 KB
scripts/lib/codex-provider.test.mjsscript1.3 KB
scripts/lib/coverage.test.mjsscript5.6 KB
scripts/lib/cube-build.mjsscript5.7 KB
scripts/lib/cube-build.test.mjsscript2.7 KB
scripts/lib/cube-validate.mjsscript5.9 KB
scripts/lib/cube-validate.test.mjsscript3.2 KB
scripts/lib/cutlist.mjsscript6.0 KB
scripts/lib/cutlist.test.mjsscript4.0 KB
scripts/lib/duck.mjsscript3.0 KB
scripts/lib/duck.test.mjsscript3.4 KB
scripts/lib/error-diffusion.mjsscript6.5 KB
scripts/lib/error-diffusion.test.mjsscript3.4 KB
scripts/lib/freeze.mjsscript3.0 KB
scripts/lib/freeze.test.mjsscript1.9 KB
scripts/lib/grade-analyzer.mjsscript8.6 KB
scripts/lib/grade-analyzer.test.mjsscript7.7 KB
scripts/lib/heygen-cli.mjsscript7.3 KB
scripts/lib/heygen-cli.test.mjsscript10.0 KB
scripts/lib/heygen-search.mjsscript1.8 KB
scripts/lib/heygen-search.test.mjsscript1.8 KB
scripts/lib/heygen-video-provider.mjsscript3.6 KB
scripts/lib/heygen-video-provider.test.mjsscript12.0 KB
scripts/lib/image-provider.mjsscript1.4 KB
scripts/lib/index-gen.mjsscript1.9 KB
scripts/lib/local-models.mjsscript13.3 KB
scripts/lib/local-models.test.mjsscript5.6 KB
scripts/lib/local-run.mjsscript2.2 KB
scripts/lib/local-run.test.mjsscript1.7 KB
scripts/lib/logo-provider.mjsscript7.0 KB
scripts/lib/logo-provider.test.mjsscript5.7 KB
scripts/lib/ltx-video-provider.mjsscript1.9 KB
scripts/lib/ltx-video-provider.test.mjsscript3.8 KB
scripts/lib/lut-preset-provider.mjsscript8.5 KB
scripts/lib/lut-preset-provider.test.mjsscript6.3 KB
scripts/lib/manifest.mjsscript7.0 KB
scripts/lib/manifest.test.mjsscript11.6 KB
scripts/lib/match.mjsscript1.4 KB
scripts/lib/mflux-provider.mjsscript3.2 KB
scripts/lib/misses.mjsscript1.2 KB
scripts/lib/misses.test.mjsscript2.5 KB
scripts/lib/npx-sync.mjsscript1.3 KB
scripts/lib/npx-sync.test.mjsscript2.0 KB
scripts/lib/parakeet-words.mjsscript1.1 KB
scripts/lib/parakeet-words.test.mjsscript1.4 KB
scripts/lib/prefs-store.mjsscript6.4 KB
scripts/lib/prefs-store.test.mjsscript7.2 KB
scripts/lib/probe.mjsscript1.3 KB
scripts/lib/probe.test.mjsscript1.6 KB
scripts/lib/providers.mjsscript327 B
scripts/lib/recipe-store.mjsscript12.7 KB
scripts/lib/recipe-store.test.mjsscript12.5 KB
scripts/lib/registry.mjsscript9.5 KB
scripts/lib/registry.test.mjsscript9.6 KB
scripts/lib/search.mjsscript906 B
scripts/lib/search.test.mjsscript1.2 KB
scripts/lib/sfx-provider.mjsscript700 B
scripts/lib/specs.mjsscript3.2 KB
scripts/lib/specs.test.mjsscript2.7 KB
scripts/lib/stats.mjsscript3.7 KB
scripts/lib/stats.test.mjsscript5.4 KB
scripts/lib/telemetry.mjsscript8.3 KB
scripts/lib/telemetry.test.mjsscript13.1 KB
scripts/lib/tts-local-provider.mjsscript3.7 KB
scripts/lib/tts-local-provider.test.mjsscript2.6 KB
scripts/lib/usage.mjsscript1.8 KB
scripts/lib/usage.test.mjsscript1.7 KB
scripts/lib/voice-provider.mjsscript1.7 KB
scripts/lib/voice-provider.test.mjsscript1.9 KB
scripts/lib/words.mjsscript764 B
scripts/prefs.mjsscript2.4 KB
scripts/recipe.mjsscript4.0 KB
scripts/resolve.mjsscript43.2 KB
scripts/resolve.test.mjsscript35.8 KB
scripts/transcribe.mjsscript6.5 KB
scripts/transcript-cut.mjsscript7.1 KB

scripts/transcript-cut.mjs

View on GitHub
#!/usr/bin/env node

import { execFileSync } from "node:child_process";
import { mkdtempSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, extname, join, resolve } from "node:path";
import { parseArgs } from "node:util";
import { compileCutList } from "./lib/cutlist.mjs";
import { track } from "./lib/telemetry.mjs";

const { values: args } = parseArgs({
  options: {
    input: { type: "string" },
    transcript: { type: "string" },
    remove: { type: "string" },
    "remove-words": { type: "string" },
    "remove-fillers": { type: "string" },
    "cut-silence": { type: "string" },
    keep: { type: "string" },
    copy: { type: "boolean", default: false },
    plan: { type: "boolean", default: false },
    out: { type: "string" },
    json: { type: "boolean", default: false },
    help: { type: "boolean", short: "h", default: false },
  },
  strict: true,
});

if (args.help) {
  console.log(`media-use transcript-cut — compile transcript edits into video cuts

Usage:
  node transcript-cut.mjs --input in.mp4 --transcript transcript.json --remove "12-15" --out out.mp4

Options:
  --input             Source video/audio file
  --transcript        JSON word transcript, array or { words: [...] }
  --remove            Time ranges to remove, seconds: a-b,c-d
  --remove-words      Word-index ranges to remove: 12-18,40-41
  --remove-fillers    Comma list of filler words to remove
  --cut-silence       Remove inter-word gaps longer than this many seconds
  --keep              Inverse mode: direct kept ranges, mutually exclusive with removal
  --copy              Use stream copy for faster, keyframe-snapped cuts
  --plan              Print kept segment JSON and exit without ffmpeg
  --out               Output file
  --json              Output JSON status
  --help, -h          Show this help`);
  process.exit(0);
}

try {
  run();
  await track("media_use_transcript_cut", {
    mode: args.plan ? "plan" : "encode",
    remove_fillers: !!args["remove-fillers"],
    cut_silence: !!args["cut-silence"],
    ranges: !!args.remove,
    keep: !!args.keep,
  });
} catch (err) {
  if (args.json) console.log(JSON.stringify({ ok: false, error: err.message }));
  else console.error(`error: ${err.message}`);
  process.exit(1);
}

function run() {
  if (!args.transcript) throw new Error("--transcript is required");
  const transcript = JSON.parse(readFileSync(resolve(args.transcript), "utf8"));
  const segments = compileCutList(transcript, {
    remove: args.remove,
    removeWords: args["remove-words"],
    removeFillers: args["remove-fillers"],
    cutSilence: args["cut-silence"],
    keep: args.keep,
  });

  if (args.plan) {
    console.log(JSON.stringify(segments));
    return;
  }

  if (!args.input || !args.out)
    throw new Error("--input and --out are required unless --plan is set");
  if (segments.length === 0) throw new Error("cut list has no kept segments");

  const inputPath = resolve(args.input);
  const outPath = resolve(args.out);
  mkdirSync(dirname(outPath), { recursive: true });
  const tmpDir = mkdtempSync(join(tmpdir(), "media-use-cut-"));
  const keptSeconds = sumDurations(segments);
  const totalSeconds = probeDuration(inputPath);

  try {
    const parts = segments.map((segment, index) => {
      const out = join(
        tmpDir,
        `segment-${String(index).padStart(4, "0")}${extname(outPath) || ".mp4"}`,
      );
      cutSegment(inputPath, segment, out, Boolean(args.copy));
      return out;
    });
    const listPath = join(tmpDir, "list.txt");
    writeFileSync(
      listPath,
      parts.map((part) => `file '${escapeConcatPath(part)}'`).join("\n") + "\n",
    );
    // Encode to a sibling temp (same extension so ffmpeg picks the right muxer),
    // then atomic-rename so a SIGKILL mid-encode can't leave a truncated outPath.
    const tmpOut = `${outPath}.part${extname(outPath) || ".mp4"}`;
    execFileSync(
      "ffmpeg",
      ["-y", "-f", "concat", "-safe", "0", "-i", listPath, "-c", "copy", tmpOut],
      {
        stdio: "ignore",
      },
    );
    renameSync(tmpOut, outPath);
  } finally {
    rmSync(tmpDir, { recursive: true, force: true });
  }

  // Stream copy can only cut on keyframes; on sparse-keyframe footage the snap
  // can silently swallow the whole cut. Compare, then surface the drift in BOTH
  // the stderr warning (human) and the --json result (pipelines).
  let copyDrift = null;
  if (args.copy) {
    const outSeconds = probeDuration(outPath);
    if (Math.abs(outSeconds - keptSeconds) > 1) {
      copyDrift = { produced_s: round3(outSeconds), expected_s: round3(keptSeconds) };
      if (!args.json) {
        console.error(
          `warning: --copy keyframe snapping produced ${round3(outSeconds)}s instead of ${round3(keptSeconds)}s kept; drop --copy for frame-accurate cuts`,
        );
      }
    }
  }

  if (args.json) {
    console.log(
      JSON.stringify({
        ok: true,
        input: inputPath,
        out: outPath,
        segments,
        kept_s: round3(keptSeconds),
        total_s: round3(totalSeconds),
        ...(copyDrift && { copy_drift: copyDrift }),
      }),
    );
    return;
  }

  console.log(
    `cut ${inputPath} -> ${outPath} (${segments.length} segments, ${fmt(keptSeconds)}s kept of ${fmt(
      totalSeconds,
    )}s)`,
  );
  console.log(`next: resolve --from ${outPath} --type <type>`);
}

function cutSegment(inputPath, segment, outPath, copy) {
  const argv = [
    "-y",
    "-nostdin",
    "-ss",
    fmt(segment.start),
    "-i",
    inputPath,
    "-to",
    fmt(segment.end - segment.start),
  ];
  if (copy) {
    argv.push("-c", "copy", "-avoid_negative_ts", "make_zero");
  } else {
    argv.push(...encodeArgsFor(extname(outPath).toLowerCase()));
  }
  argv.push(outPath);
  execFileSync("ffmpeg", argv, { stdio: "ignore" });
}

// Codec set per output container. Audio-only outputs must not get the
// video-centric aac/x264 set (aac inside .wav breaks timing entirely).
function encodeArgsFor(ext) {
  if (ext === ".wav") return ["-c:a", "pcm_s16le"];
  if (ext === ".mp3") return ["-c:a", "libmp3lame", "-q:a", "2"];
  if (ext === ".m4a" || ext === ".aac") return ["-c:a", "aac"];
  if (ext === ".flac") return ["-c:a", "flac"];
  return [
    "-c:v",
    "libx264",
    "-preset",
    "veryfast",
    "-crf",
    "18",
    "-c:a",
    "aac",
    "-movflags",
    "+faststart",
  ];
}

function probeDuration(filePath) {
  const raw = execFileSync(
    "ffprobe",
    [
      "-v",
      "error",
      "-show_entries",
      "format=duration",
      "-of",
      "default=noprint_wrappers=1:nokey=1",
      "--",
      filePath,
    ],
    { encoding: "utf8" },
  );
  const duration = Number(raw.trim());
  if (!Number.isFinite(duration) || duration <= 0)
    throw new Error(`could not probe duration: ${filePath}`);
  return duration;
}

function escapeConcatPath(filePath) {
  return filePath.replace(/'/g, "'\\''");
}

function sumDurations(segments) {
  return segments.reduce((sum, segment) => sum + (segment.end - segment.start), 0);
}

function fmt(n) {
  return round3(n)
    .toFixed(3)
    .replace(/\.?0+$/, "");
}

function round3(n) {
  return Math.round(Number(n) * 1000) / 1000;
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall