gooseworks-ai/goose-skills / skills/video/stitch-videos-ffmpeg
stitch-videos-ffmpeg
VerifiedStitch video segments with ffmpeg concat, xfade, overlay, audio mux, and export settings, and trim a source into named clips at exact windows (trim_clips.py). Ships montage.py, a free montage assembler (python3 + ffmpeg, no keys). It takes a JSON EDL of clips and stills, normalizes them and hard-cuts them in order, burns captions from an SRT, a cue list or word timings, and lays a VO over a music bed that ducks under it, mastered to -14 LUFS.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 13.4 KB |
| scripts/composite.pyexecutable | script | 4.8 KB |
| scripts/composite_final.pyexecutable | script | 3.5 KB |
| scripts/composite_final.shexecutable | script | 295 B |
| scripts/montage.pyexecutable | script | 49.3 KB |
| scripts/normalize_clip.shexecutable | script | 668 B |
| scripts/trim_clips.pyexecutable | script | 7.1 KB |
| scripts/voiceless/composite.py | script | 4.5 KB |
| skill.meta.json | config | 190 B |
| tests/expected-output.md | markdown | 300 B |
| tests/human-test.md | markdown | 853 B |
| tests/sample-input.md | markdown | 568 B |
| tests/smoke-test.md | markdown | 642 B |
| tests/test_stitch_montage.py | script | 18.1 KB |
| tests/test_trim_clips.py | script | 2.2 KB |
scripts/voiceless/composite.py
View on GitHub"""Composite the final voiceless transformation reel from edit_plan.json."""
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
PLAN = json.loads((Path(__file__).resolve().parent / "edit_plan.json").read_text())
CLIPS = ROOT / "clips"
EDITS = ROOT / "edits"
EDITS.mkdir(exist_ok=True)
DELIVERABLE = ROOT / "deliverable"
DELIVERABLE.mkdir(exist_ok=True)
W, H, FPS = 720, 1280, 30
# 1) Trim each scene clip to its in/out and re-encode at consistent fps/codec.
trimmed = []
for i, s in enumerate(PLAN["scenes"]):
src = CLIPS / s["clip"]
out = EDITS / f"trim_{i:02d}_{s['clip']}"
dur = round(s["clip_out"] - s["clip_in"], 3)
cmd = [
"ffmpeg", "-y", "-loglevel", "error",
"-ss", f"{s['clip_in']:.3f}", "-i", str(src),
"-t", f"{dur:.3f}",
"-vf", f"scale={W}:{H}:flags=lanczos,fps={FPS},setsar=1",
"-an",
"-c:v", "libx264", "-preset", "veryfast", "-crf", "18",
"-pix_fmt", "yuv420p",
str(out),
]
subprocess.run(cmd, check=True)
trimmed.append(out)
# 2) Concat list
concat_txt = EDITS / "concat.txt"
concat_txt.write_text("\n".join(f"file '{p}'" for p in trimmed) + "\n")
concat_mp4 = EDITS / "concat.mp4"
subprocess.run([
"ffmpeg", "-y", "-loglevel", "error",
"-f", "concat", "-safe", "0", "-i", str(concat_txt),
"-c:v", "libx264", "-preset", "veryfast", "-crf", "18",
"-pix_fmt", "yuv420p",
str(concat_mp4),
], check=True)
# 3) Build overlay filter graph: captions + loading dots
filters = []
inputs = ["-i", str(concat_mp4)]
input_idx = 1 # 0 is concat video
# captions
for cap in PLAN["captions"]:
inputs += ["-i", str(EDITS / cap["png"])]
# loading dots: 5 PNGs, each shown for frame_period_s seconds
dots_dir = ROOT / PLAN["loading_dots"]["frames_dir"]
dots_files = sorted(dots_dir.glob("dots_*.png"))
for d in dots_files:
inputs += ["-i", str(d)]
# audio
inputs += ["-i", str(ROOT / PLAN["audio"]["file"])]
audio_input_idx = 1 + len(PLAN["captions"]) + len(dots_files)
# Filter chain: [0:v] -> overlay caption_before -> overlay caption_after -> overlay each dot frame
chain = "[0:v]"
for i, cap in enumerate(PLAN["captions"]):
src = f"[{1+i}:v]"
label_in = chain
label_out = f"[v_cap{i}]"
chain_part = (
f"{label_in}{src}overlay=x={cap['x']}:y={cap['y']}:"
f"enable='between(t,{cap['start_s']:.3f},{cap['end_s']:.3f})'{label_out}"
)
filters.append(chain_part)
chain = label_out
# loading dots: 5 frames cycling at frame_period_s, looping until end_s
ld = PLAN["loading_dots"]
period = ld["frame_period_s"]
n_frames = len(dots_files)
total_dot_window = ld["end_s"] - ld["start_s"]
# Cycle: each frame shown for period seconds, looping
n_cycles = int(total_dot_window / (period * n_frames)) + 1
dot_input_start = 1 + len(PLAN["captions"])
for c in range(n_cycles):
for f_i in range(n_frames):
t0 = ld["start_s"] + (c * n_frames + f_i) * period
t1 = t0 + period
if t0 >= ld["end_s"]:
break
if t1 > ld["end_s"]:
t1 = ld["end_s"]
src = f"[{dot_input_start + f_i}:v]"
label_in = chain
label_out = f"[v_d{c}_{f_i}]"
filters.append(
f"{label_in}{src}overlay=x={ld['x']}:y={ld['y']}:"
f"enable='between(t,{t0:.3f},{t1:.3f})'{label_out}"
)
chain = label_out
# Light film grain pass on the final video chain (UGC iPhone feel)
grain_in = chain
grain_out = "[v_grain]"
filters.append(f"{grain_in}noise=alls=4:allf=t,eq=saturation=1.05:contrast=1.04{grain_out}")
chain = grain_out
# audio: -7dB volume pad + fades
af_in = PLAN["audio"]["fade_in_s"]
af_out = PLAN["audio"]["fade_out_s"]
total = PLAN["total_duration_s"]
filters.append(
f"[{audio_input_idx}:a]atrim=0:{total},asetpts=PTS-STARTPTS,"
f"volume=-7dB,"
f"afade=t=in:st=0:d={af_in},afade=t=out:st={total - af_out:.3f}:d={af_out}[aout]"
)
filter_complex = ";".join(filters)
out_path = DELIVERABLE / "voiceless-music-story-recreation.mp4"
cmd = (
["ffmpeg", "-y", "-loglevel", "error"]
+ inputs
+ [
"-filter_complex", filter_complex,
"-map", chain, "-map", "[aout]",
"-t", f"{total:.3f}",
"-c:v", "libx264", "-preset", "slow", "-crf", "22",
"-tune", "grain",
"-pix_fmt", "yuv420p",
"-c:a", "aac", "-b:a", "160k",
"-movflags", "+faststart",
str(out_path),
]
)
print(" ".join(cmd[:6]), "...filter graph:", filter_complex[:200], "...")
subprocess.run(cmd, check=True)
print(f"DONE -> {out_path}")
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |