AGENT SKILL

music-edit-to-length

Cut a music track to a target length on its downbeat grid with scored, click-free joins, writing <out>.wav and a video-time beat grid (<out>_edit.json, schema music-edit/1). Use on "cut the music to 90 seconds", "fit the track to the video", "shorten this song on the beat", "re-cut the music edit".

License 许可
MIT
最近更新
2026-11-12
Stars
★ 348
Forks
56

01 前言 Front Matter

name
music-edit-to-length
description
Cut a music track to a target length on its downbeat grid with scored, click-free joins, writing <out>.wav and a video-time beat grid (<out>_edit.json, schema music-edit/1). Use on "cut the music to 90 seconds", "fit the track to the video", "shorten this song on the beat", "re-cut the music edit".

02 资源文件 2

03 SKILL.md 正文

music-edit-to-length

Input: a music-map/1 from music-analysis (run it first). Output: <out>.wav, <out>_edit.json and, with --preview, <out>.m4a for listening. The edit file feeds beat-sync-video and the picture edit.

Scripts run in the quick-tier venv (.venv-music, see music-analysis step 0); PKG=<this skill dir>/../../...

Procedure

  1. Analyse — music-analysis → track_map.json. Read the sections, classes and drop candidates; confirm the drop by ear.
  2. Identify blocks — mark the sections and genre/energy blocks (e.g. tech-house groove bars 1–32, trance breakdown/build 33–65, groove again 66–105). Joins may only connect material from the same block family.
  3. Score joins —
    .venv-music/bin/python "$PKG/.pi/skills/music-edit-to-length/scripts/score_joins.py" track_map.json \
        --candidates auto --target-duration 90 --anchor-bar 66
    .venv-music/bin/python "$PKG/.pi/skills/music-edit-to-length/scripts/score_joins.py" track_map.json --from-bar 12 --to-bar 17
    
    A join plays through the end of bar A and continues at bar B. Per factor: chroma and timbre similarity of the outgoing bars A−1..A against B's run-up in the source (B−2..B−1 — a match means the music arrives where B expects it), level jump, section_boundary, class_change. score = 0.4·chroma + 0.4·timbre − 0.02·|jump dB| − 0.5·[groove/drop ↔ breakdown/build] + 0.1·[section boundary]. Prefer ≥ 0.75 with no class change. The score is advisory: automatic classes cannot always tell a genre boundary (a trance build and a tech-house groove both have drums and bass) — your block marking in step 2 decides.
  4. Render —
    .venv-music/bin/python "$PKG/.pi/skills/music-edit-to-length/scripts/edit_music.py" track.wav music/track_edit90 \
        1:13 17:25 25:33 66:82 102:197.0 --preview
    
    The map defaults to <audio stem>_map.json next to the audio; pass --map music/track_map.json when it lives elsewhere (e.g. after analyze_music.py --out-dir). Segments are 1-based start_bar:end where end is an exclusive bar, END, or seconds with a decimal point. Joins are 30 ms equal-power crossfades.
  5. Click check — every join reports click_ok; the script warns on stderr when a join's sample step exceeds 1.1× the source at the same bar. Pick another join or keep the crossfade (--no-xfade is diagnostic only).
  6. Preview — the .m4a is written next to the wav.
  7. Listen before lock — ask the user to listen to the .m4a before the picture edit is locked to downbeats_video. Do not sync video to an unapproved edit.
  8. Iterate — keep every rejected version with a _vN suffix (track_edit90_v1.wav + _v1_edit.json) and write a one-line note of the rejection reason next to it (README/AGENTS row), e.g. "v2 rejected: jumps from tech-house groove into the trance build at 0:31".

Splice rules

  • Fixed drop anchor — the drop is the fixed anchor on the video timeline; cut before and after it, never move it.
  • Enter at section boundaries — enter only at a section boundary or at a repeated-block boundary (same 4/8-bar phrase position).
  • No genre boundary — never splice across a genre or energy boundary (for example from a tech-house groove into a trance build), however good the similarity numbers look.
  • Trailing silence is trimmed automatically (≥ 1 s below −50 dBFS → 50 ms + fade).

The edit contract — music-edit/1 (video time)

Field Meaning
schema "music-edit/1"
source, audio, map source audio, edited wav, source map — relative to the edit file
bpm, meter, duration from the map; duration of the edited audio
segments[] {start_bar, end_bar | end_s, music_from, music_to, video_at} source span → video position
joins[] {video_at, source_bar, score, click_ok} one per join
downbeats_video[] the video-time downbeat grid (first entry 0.0)

A source time s inside segment i maps to video_at_i + (s − music_from_i); source times outside every segment are cut out.

Verification

  • click_ok true for every join; the .m4a approved by the user.
  • jq '.duration, (.downbeats_video | length)' <out>_edit.json matches the target.

04 同仓库更多 Skills

BlackBeltTechnology
BlackBeltTechnology/pi-agent-dashboard

youtube-srt

Download YouTube subtitles (SRT + timestamped TXT) for a channel, playlist or video via yt-dlp, no media download; optionally mine them into a categorized catalog (e.g. AI models by function, open weights, local runnability, hardware tier). Use on "download the srt of this video", "transcripts of channel X for the last N months", "catalog the models AI Search talked about", "update docs/models".

★ 348
BlackBeltTechnology
BlackBeltTechnology/pi-agent-dashboard

video-transcription

Transcribe video and audio files to SRT subtitles with speaker diarization using the Soniox (default) or AssemblyAI API. Use when the user wants to transcribe meetings, videos, or audio files. Supports MKV, MP4, MOV, M4A, MP3. Triggers on "/transcribe", "transcribe my meetings", "transcribe videos in ~/Movies", or any request to convert audio/video to text.

★ 348
BlackBeltTechnology
BlackBeltTechnology/pi-agent-dashboard

speaker-id

Name anonymous diarized SRT speakers from a persistent local voiceprint library and repair speaker drift; local, CPU-only, no API key. Triggers "who is speaker 2", "put names on the transcript", "label the meeting SRT", "the diarization split one person into three", "enroll my voice". Backed by the pi-voiceid CLI.

★ 348
BlackBeltTechnology
BlackBeltTechnology/pi-agent-dashboard

veo-showreel-production-kit

Turn a video timeline + voiceover into a reproducible, sliceable Veo 3.1 prompt package with a consistency anchor and AI storyboard sketches.

★ 348
BlackBeltTechnology
BlackBeltTechnology/pi-agent-dashboard

veo-generator

Render a scripted video project into mp4 clips with the Google Veo 3.1 API. Reads a project's shot package (shots/*.md), one clip per camera cut, reusing each shot's prompt and sketch — world anchor only with `--with-reference`, seed unless `--no-seed`. Use on "render the Veo video for <project>", "generate the videos from the shot scripts", "make the clips with Veo".

★ 348
BlackBeltTechnology
BlackBeltTechnology/pi-agent-dashboard

hyperframes-showreel

Turn real screen and site footage into a rhythmic showreel rendered with HyperFrames: sampling, edit script, redacted clips, a generated composition, Veo only as additive FX, music edit + camera punches, delivery render and export QA. Use on "make a showreel from these recordings", "build the HyperFrames video", "assemble the footage edit", "render and QA the showreel".

★ 348