[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DBSAHAD05CNX876H29Y5EH":3,"skill-same:01M6DBSAHAD05CNX876H29Y5EH":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":25,"linkOnly":26,"markdownContent":27,"markdownBody":28,"frontMatter":29,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M6DBSAHAD05CNX876H29Y5EH","reframe-video-cutting",null,"Use when selecting and cutting moments from a long talk, podcast, interview, stream, or vlog into shorts with scene-aware, sentence-safe boundaries.","Prekzursil\u002Fagent-skills-toolchain","Prekzursil","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F54636077?v=4","01M6DACZ1PCQHD99SCR1YXG28B","Andrei Mihai Visalon","01M6DACZ670WZF535V3WYYSS4Z",0,"MIT","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freframe-video-cutting\u002FSKILL.md",[],[19,20,21,22,23,24],"Video","reframe video cutting","safe","interview","use","podcast","2026-11-10 10:12:30",false,"---\nname: reframe-video-cutting\ndescription: \"Use when selecting and cutting moments from a long talk, podcast, interview, stream, or vlog into shorts with scene-aware, sentence-safe boundaries.\"\n---\n\n# Video Cutting \u002F Clip Selection (the short-maker's heart)\n\nCut a long talking-head\u002Fpodcast\u002Finterview video into a ranked set of short vertical-ready clips, and **select which moments are worth shipping**. This is the SELECT + BOUNDARY-SNAP + CUT half of a short-maker. The 9:16 reframe, captions, zoom, and brand overlay are downstream (see the `reframe` skill); watermark removal is a different skill (`video-watermark-removal`).\n\nThe canonical, battle-tested implementation is `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002F` (`select.py`, `boundary.py`, `scene_transnet.py`, `shortmaker.py`). This skill distills that REAL pipeline + the virality\u002Fhighlight-detection upgrades, with sources cited and confidence graded.\n\n## When to use \u002F when NOT\n- USE for: choosing the best N moments from a transcribed long video, snapping cut points cleanly, carving frame-accurate clips. Works for any spoken-word source (talk, podcast, interview, stream, lecture, vlog).\n- DO NOT use for: visual reframing\u002Fcropping to 9:16, caption burn-in, watermark\u002Flogo removal, or pure b-roll\u002Fmusic videos with no speech (use the visual-only `candidates_from_curve` peak-pick path instead of the LLM path).\n\n## The real pipeline (Reframe \u002F media_studio)\n```\ntranscript (+word timings)  ->  SELECT (features\u002Fselect.py)        prompt + transcript -> ranked Candidates w\u002F virality factors\n                            ->  BOUNDARY-SNAP (features\u002Fboundary.py) snap start\u002Fend to sentence-end \u002F silence \u002F scene-cut, never mid-word\n   -- the two above = shortmaker.select() --\n                            ->  CUT (ffmpeg, frame-accurate)        carve [sourceStart, end) out of the source\n                            ->  (REFRAME \u002F CAPTION \u002F EXPORT)        downstream, other skills\n```\nScene cuts come from `features\u002Fscene_transnet.py` (TransNetV2) merged with PySceneDetect, fed into BOUNDARY-SNAP as one of the three snap-target sources.\n\n## 1. SELECT — LLM-on-transcript, two-pass rubric (PRIMARY)\n`select.select(transcript, prompt, controls, provider) -> list[Candidate]` (`features\u002Fselect.py`). This is the frozen recipe — do not soften it:\n\n- **Provider call:** chat with **reasoning ON** (never inject `\u002Fno_think`), `temperature=0.4`, `max_tokens=6000` (generous so the `\u003Cthink>` block + JSON aren't truncated). Default model = Qwen3-4B GGUF via a local llama.cpp OpenAI `\u002Fv1` server.\n- **Two-pass system prompt** (`build_system_prompt`):\n  - Pass 1 (THINK): state the talk's single **THESIS** in one sentence; list its **6-8 most quotable \u002F counterintuitive \u002F emotional lines**, weighting `(Applause)` markers; for each, find the **COMPLETE thought** (setup + payoff), never a 3-second fragment.\n  - Pass 2 (THEN): pick `count` clips (default 5), **each a self-contained complete thought**, opening on a hook, ending on a satisfying\u002Fcuriosity beat; the single most-quotable line of the whole talk MUST be in one of them.\n- **Transcript rendering:** `[mm:ss] text` lines, one per segment (`render_lines`), so the model can cite timestamps.\n- **JSON schema** (`_schema_line`): `{\"clips\":[{rank,start,end,duration_sec,hook,why,score(0-100),factors{...},factorNotes{...}}]}`. Strip `\u003Cthink>...\u003C\u002Fthink>` BEFORE parsing (`strip_think`); pull the outer `{...}` (`extract_clips`).\n- **Fail LOUD, not silent:** a non-empty reply with no parseable `{\"clips\":[...]}` raises `SelectionParseError` (job ERROR) — never a silent `[]` the UI shows as \"0 clips, success\". A genuinely empty reply or `{\"clips\":[]}` returns `[]`.\n- **Duration clamp** (`to_candidates`): `durationSec = end-start`, hard-clamped into the active envelope by extending\u002Ftrimming the END (preserve the hook\u002F`sourceStart`); never run past `durationSec` of the source.\n- **`sourceStart`** = clip start in the ORIGINAL video; captions later subtract it to re-base cues to local t=0.\n\n### Duration modes (envelope is the single source of truth, shared with boundary.py)\n- `standard`: **20-60 s** (default).\n- `midform`: **16-180 s** (real OpusClip teardown shows clips run 16-160 s, not 60-capped — ship the top moment at BOTH a long and a punchy length).\n- Unknown mode fails **closed** to `standard` (`resolve_duration_mode`). SELECT and BOUNDARY-SNAP MUST agree on the envelope or a mid-form clip gets re-clamped to 60 s at the snap stage (this was a real BLOCKER bug — thread `durationMode` into `snap_from_lists`).\n\n### Map-reduce for long transcripts\n> `len(lines) > 240` triggers it. Chunk into 200-line slices, shortlist 6 candidates\u002Fchunk (per-chunk `SelectionParseError` is tolerated → skip that chunk), then ONE global re-rank over the union shortlist (`build_rerank_user_prompt`). Reduce parse failure falls back to the validated map shortlist (degrade, don't error — we already have real candidates).\n\n### Clip-selection strategy — current (virality factors + percentile)\n- Each clip is scored on **four 0-100 virality factors** + a one-line note each (`FACTOR_NAMES`): `hookStrength` (first-3-seconds arrest), `emotionalFlow` (builds without dead spots), `perceivedValue` (viewer walks away with something), `shareability` (would someone send it to a friend).\n- A missing\u002Funparseable factor **degrades to the clip's legacy `score`** (not 0) so a parse hiccup doesn't crater its rank.\n- `viralityPct` = batch **percentile** of the raw factor-average, computed AFTER trim-to-count (rank within the clips the user actually receives, not the pre-trim pool). Singleton batch carries the raw average, not a 50 sentinel.\n- **Overlap ladder** (off by default): for each of the top-N moments meaningfully longer than `punchyShortSec` (default 30 s), emit an extra OVERLAPPING candidate sharing the same start (the hook) trimmed short — ship the moment at both lengths. Runs AFTER trim so shorts never push a real moment out of `count`.\n\n## 2. BOUNDARY-SNAP — deterministic, never mid-word (`features\u002Fboundary.py`)\nThe LLM returns rough clips; snap each `start`\u002F`end` to the nearest VALID boundary. Three snap-target sources:\n1. **Sentence end** — a word whose text (trailing quotes\u002Fbrackets trimmed) ends in `. ! ? …`; the target is that word's `end` time (`sentence_ends_from_words`).\n2. **Audio silence** — midpoint of each detected silent gap.\n3. **Scene cut** — detected scene-change timestamps.\n\nRules (all enforced):\n- Snap to the **nearest** valid target within the duration window; ties break toward the **smaller** timestamp (determinism).\n- **Never cut mid-word** (`_cuts_mid_word`: reject a target strictly inside any word span; exactly on a word start\u002Fend is fine).\n- Two-pass: snap start-first then end-first, keep the pair with least summed distance — so a clip whose start OR end already sits on a boundary still snaps.\n- **Idempotent**: re-snapping an already-snapped clip returns the same geometry.\n- A candidate with **no valid boundary** that keeps it in range is **dropped with a reason** (`SnapResult.reason`), surfaced per-clip to the UI — never silently mangled.\n\n### Detection commands (behind injectable seams)\n- **Silence** (`build_silencedetect_argv` \u002F `parse_silencedetect`):\n  ```\n  ffmpeg -hide_banner -nostdin -i IN -af silencedetect=noise=-30dB:d=0.5 -f null -\n  ```\n  `silencedetect` writes `silence_start:`\u002F`silence_end:` to **stderr**; the snap target is each gap's **midpoint**. A probe failure returns `()` (degrade to other targets), never crashes the pipeline.\n- **Scene cuts (CPU fallback)** — PySceneDetect `ContentDetector(threshold=27.0)`; each scene's start time in seconds. Lazy-imported inside the function so importing the module never drags in `scenedetect`.\n\n## 3. Scene detection — TransNetV2 + PySceneDetect merge (`features\u002Fscene_transnet.py`)\n- **TransNetV2** (`soCzech\u002FTransNetV2`, MIT) predicts a per-frame shot-change probability; a **rising edge** over `threshold=0.5` is a cut (a multi-frame dissolve ramp yields ONE cut at its leading edge, `predictions_to_cuts`). Its win over the histogram-diff `ContentDetector`: it catches **dissolves \u002F soft transitions** PySceneDetect misses. Frames are decoded to a **48x27 RGB** stack (tiny VRAM).\n- **Merge** (`merge_with_pyscenedetect`, `eps=0.25 s`): a cut in EITHER source survives; two cuts within eps collapse to one (earlier timestamp). The CPU fallback never stops working.\n- **Degrade contract:** `present=False` only when NO cut source exists at all (model missing + offline AND no provider). An empty-but-`present=True` track means \"this clip genuinely has no scene changes.\"\n- ⚠️ **Upstream-dead trap:** `soCzech\u002FTransNetV2` HF repo now 404s (verified 2026-06-28) so its commit can't be pinned; Reframe leaves the asset **intentionally unregistered** rather than pin a dead\u002Funverified repo. Live mirrors exist — `Sn4kehead\u002FTransNetV2`, `MiaoshouAI\u002Ftransnetv2-pytorch-weights` (both host `transnetv2-pytorch-weights.pth`) — but their snapshot LAYOUT differs from the original loader, so a blind re-point risks a SILENT scene-detection break. Confirm a mirror is loader-compatible before pinning `hf_repo=\u003Cmirror>` + a full 40-hex commit. (Source: `scene_transnet.register_scene_transnet_assets` docstring.) Confidence: HIGH that upstream is dead; MEDIUM on mirror compatibility.\n\n## 4. CUT — frame-accurate ffmpeg carve (`shortmaker._lazy_cut`)\n```\nffmpeg -hide_banner -nostdin -y -i IN -ss \u003Cstart> -to \u003Cend> -c:v libx264 -c:a aac -progress pipe:1 -nostats OUT\n```\n**The load-bearing detail:** `-ss`\u002F`-to` go **AFTER** `-i` → frame-accurate (decode-then-trim). `-ss` BEFORE `-i` is fast (keyframe seek) but inaccurate — clips start on the wrong frame and audio desyncs. Persist `sourceStart` on every clip record (§3). argv LIST, never a shell string (paths with spaces stay safe).\n\n## Clip-selection upgrades — the virality \u002F highlight stack (fold-in)\nReframe wraps the frozen LLM path with optional multimodal scoring (`select.select_unified`, `features\u002Fscorer.py`, `ranker.py`, `diversity.py`, `quality_gate.py`, `smolvlm2.py`). Each step graceful-degrades.\n\n1. **Signal fusion** (`scorer.fuse_score`, `DEFAULT_FUSE_ALPHA=0.5`): blend the LLM score with present-weighted audio\u002Fvisual signals. **Degrade by re-normalization (ONE code path):** a track with `present=False` is dropped from the weighted mean AND its weight; no fabricated zeros. Audio interest from PANNS **CNN14** (`panns-cnn14`).\n2. **Learned re-rank** (Tier-0, always): `ranker.rank` — a trained `LGBMRanker` (lightgbm) when present, else a deterministic factor-average fallback (zero downloads). A feedback flywheel trains it from user labels.\n3. **Diversity \u002F dedup** (Tier-0, always): `diversity.dedupe_candidates`, **MMR** default (`dpp` opt-in) over WU4 embeddings, else a zero-model signal-vector matrix. Stops five near-identical clips of the same moment.\n4. **Quality gate** (Tier-1, optional): `quality_gate.apply_quality_gate` — **DOVER-Mobile** VQA (`teowu\u002FDOVER`, ~60 MB, revision `841d2f90f8ed5e30e7d60213fd6b4354fd56b06c`) multiplicatively DEMOTES shaky\u002Fblurry\u002Fover-compressed clips. No-op when the model is absent.\n5. **Tier-2 VLM re-rank** (opt-in, off by default): `smolvlm2` reorders the top-K with **SmolVLM2-2.2B-Instruct** (`HuggingFaceTB\u002FSmolVLM2-2.2B-Instruct`, Apache-2.0 = commercial OK), loaded BF16 to fit sub-6 GB.\n\n### External highlight-detection heads (the upgrade beyond Reframe's current stack)\n- **LLM-on-transcript rubric is the right PRIMARY for talking-head content** — it's the universal OSS pattern, matches this stack, and is academically validated (arXiv **2512.21402**). Confidence: **HIGH**.\n- **Dedicated moment\u002Fhighlight-detection models** (the Lighthouse toolkit: **Moment-DETR \u002F QD-DETR \u002F CG-DETR \u002F UVCOM \u002F TR-DETR** heads, QVHighlights-trained) give a real virality lift mainly on **visual \u002F sports \u002F action** content, less so on talking-heads where the transcript carries the signal. Confidence: **MEDIUM**. Note: some Lighthouse checkpoints live on GitHub rather than HF (verify the source before pinning). Confidence on the GitHub-hosted checkpoints: MEDIUM.\n- Treat visual HD models as a SECONDARY signal fused at step 1, not a replacement for the transcript rubric on spoken-word sources.\n\n## ffmpeg seek \u002F concat gotchas (these actually bite)\n- **Decode-then-trim vs fast-seek** (above): `-ss`\u002F`-to` AFTER `-i` for accuracy; before `-i` for speed-but-imprecise. For the CUT stage, always accurate.\n- **concat DEMUXER needs identical params.** `ffmpeg -f concat -safe 0 -i list.txt -c copy out.mp4` stream-copies ONLY if every segment shares codec, resolution, pixel format, AND timebase. Mismatched timebase → A\u002FV drift or `Non-monotonous DTS` warnings. If segments differ, **re-encode** (drop `-c copy`) or normalize each segment first. Add `-fflags +genpts` \u002F `-avoid_negative_ts make_zero` when DTS goes non-monotonic.\n- **concat PROTOCOL (`concat:a|b`) is NOT the demuxer** — it only works for a handful of raw container formats (MPEG-TS), not arbitrary MP4. Use the demuxer (`-f concat`) or `filter_complex concat` for MP4.\n- **Audio drift on cut clips:** re-encoding audio to `aac` (as the CUT does) re-bases timestamps cleanly; `-c:a copy` on a non-keyframe-aligned cut can leave a leading silence\u002Fdesync. The Reframe filler-removal\u002Fsilence-trim paths use `filter_complex` segment concat (frame-accurate) precisely to avoid this.\n- **NO HGT-style date traps here** — clip selection is content-driven, not time\u002Fcalendar-gated; there is no equivalent of the Battle Cats date-drift footgun. The closest analog is the duration-envelope mismatch between SELECT and BOUNDARY-SNAP (fix: share `durationMode`).\n\n## GPU \u002F memory notes (6 GB budget)\n- **Qwen3-4B GGUF (selection LLM)** fits 6 GB at a sane quant; this is the workhorse. Confidence: HIGH.\n- **TransNetV2** runs on a 48x27 frame stream — trivial VRAM. **DOVER-Mobile** ~60 MB. **DETR-family highlight heads** fit alongside the LLM GGUF. 6 GB co-residency is fine for {LLM + DETR heads}. Confidence: HIGH.\n- **Running a CLIP \u002F BLIP-2 feature extractor CONCURRENTLY with the LLM risks OOM on 6 GB** — run visual feature extraction as a **separate offline stage** (extract embeddings to disk first, then load the LLM). Confidence: MEDIUM for the concurrent case.\n- **SmolVLM2-2.2B** is opt-in BF16, loaded ALONE (top-K re-rank only) to stay sub-6 GB — never co-resident with the selection LLM.\n- ProPainter-style temporal models are NOT part of this pipeline (that's watermark removal).\n\n## Pitfalls (carried from the as-built code + lessons)\n1. **Never return silent `[]` on a parse failure** — raise `SelectionParseError` so the job ends LOUD. A silent empty renders as \"0 clips success\" and hides the real failure.\n2. **SELECT and BOUNDARY-SNAP must share the duration envelope.** A mid-form (16-180 s) clip selected with `durationMode=midform` gets re-clamped to 20-60 s and dropped at snap if the mode isn't threaded into `snap_from_lists`. (Real BLOCKER fix in `shortmaker._lazy_snap`.)\n3. **Don't snap a cut into the middle of a word** — always run `_cuts_mid_word`; a cut exactly on a word start\u002Fend is OK.\n4. **TransNetV2 upstream is dead (404)** — don't blind-pin a mirror; verify loader-compatible snapshot layout first or you get a silent scene-detection break.\n5. **Compute the percentile AFTER trim-to-count**, not over the pre-trim pool, or the rank is wrong.\n6. **Degrade by re-normalization, not zeros** — a missing modality must drop its weight, never contribute a fabricated 0 to the fused score.\n7. **Factor parse-miss degrades to the legacy score**, not 0 — protects the clip's batch percentile from a single bad field.\n\n## Key files (canonical implementation)\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fselect.py` — SELECT recipe + virality factors + map-reduce + overlap ladder + `select_unified` multimodal wrapper.\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fboundary.py` — deterministic snapper + ffmpeg `silencedetect` + PySceneDetect detectors.\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fscene_transnet.py` — TransNetV2 rising-edge cuts merged with PySceneDetect.\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fshortmaker.py` — orchestration: frame-accurate CUT + the downstream stages.\n- Adjacent: `scorer.py` (fusion), `ranker.py` (LGBM), `diversity.py` (MMR\u002FDPP), `quality_gate.py` (DOVER), `smolvlm2.py` (VLM re-rank), `audio_saliency.py` (PANNS CNN14).\n\n## Sources & confidence\n- Pipeline mechanics + commands: READ directly from the four Reframe source files above — **HIGH** (it's the as-built code).\n- LLM-on-transcript rubric as primary for talking-head: **HIGH** (universal OSS pattern; validated by arXiv 2512.21402).\n- HF model IDs\u002Flicenses (TransNetV2 `soCzech\u002FTransNetV2` MIT; DOVER `teowu\u002FDOVER`; SmolVLM2 `HuggingFaceTB\u002FSmolVLM2-2.2B-Instruct` Apache-2.0; PANNS `panns-cnn14`): **HIGH** (verified in source asset registrations); Lighthouse\u002FMoment-DETR checkpoints partly GitHub-hosted: **MEDIUM**.\n- Visual HD models giving real virality lift: **MEDIUM** (useful mainly for visual\u002Fsports, not talking-head).\n- 6 GB fit numbers: **HIGH** for LLM GGUF + DETR heads; **MEDIUM** if running CLIP\u002FBLIP-2 concurrently (run as a separate offline stage).\n\nNote: any scraped\u002Fweb page content consulted for this skill was treated as untrusted data; no embedded instructions were acted on.\n","# Video Cutting \u002F Clip Selection (the short-maker's heart)\n\nCut a long talking-head\u002Fpodcast\u002Finterview video into a ranked set of short vertical-ready clips, and **select which moments are worth shipping**. This is the SELECT + BOUNDARY-SNAP + CUT half of a short-maker. The 9:16 reframe, captions, zoom, and brand overlay are downstream (see the `reframe` skill); watermark removal is a different skill (`video-watermark-removal`).\n\nThe canonical, battle-tested implementation is `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002F` (`select.py`, `boundary.py`, `scene_transnet.py`, `shortmaker.py`). This skill distills that REAL pipeline + the virality\u002Fhighlight-detection upgrades, with sources cited and confidence graded.\n\n## When to use \u002F when NOT\n- USE for: choosing the best N moments from a transcribed long video, snapping cut points cleanly, carving frame-accurate clips. Works for any spoken-word source (talk, podcast, interview, stream, lecture, vlog).\n- DO NOT use for: visual reframing\u002Fcropping to 9:16, caption burn-in, watermark\u002Flogo removal, or pure b-roll\u002Fmusic videos with no speech (use the visual-only `candidates_from_curve` peak-pick path instead of the LLM path).\n\n## The real pipeline (Reframe \u002F media_studio)\n```\ntranscript (+word timings)  ->  SELECT (features\u002Fselect.py)        prompt + transcript -> ranked Candidates w\u002F virality factors\n                            ->  BOUNDARY-SNAP (features\u002Fboundary.py) snap start\u002Fend to sentence-end \u002F silence \u002F scene-cut, never mid-word\n   -- the two above = shortmaker.select() --\n                            ->  CUT (ffmpeg, frame-accurate)        carve [sourceStart, end) out of the source\n                            ->  (REFRAME \u002F CAPTION \u002F EXPORT)        downstream, other skills\n```\nScene cuts come from `features\u002Fscene_transnet.py` (TransNetV2) merged with PySceneDetect, fed into BOUNDARY-SNAP as one of the three snap-target sources.\n\n## 1. SELECT — LLM-on-transcript, two-pass rubric (PRIMARY)\n`select.select(transcript, prompt, controls, provider) -> list[Candidate]` (`features\u002Fselect.py`). This is the frozen recipe — do not soften it:\n\n- **Provider call:** chat with **reasoning ON** (never inject `\u002Fno_think`), `temperature=0.4`, `max_tokens=6000` (generous so the `\u003Cthink>` block + JSON aren't truncated). Default model = Qwen3-4B GGUF via a local llama.cpp OpenAI `\u002Fv1` server.\n- **Two-pass system prompt** (`build_system_prompt`):\n  - Pass 1 (THINK): state the talk's single **THESIS** in one sentence; list its **6-8 most quotable \u002F counterintuitive \u002F emotional lines**, weighting `(Applause)` markers; for each, find the **COMPLETE thought** (setup + payoff), never a 3-second fragment.\n  - Pass 2 (THEN): pick `count` clips (default 5), **each a self-contained complete thought**, opening on a hook, ending on a satisfying\u002Fcuriosity beat; the single most-quotable line of the whole talk MUST be in one of them.\n- **Transcript rendering:** `[mm:ss] text` lines, one per segment (`render_lines`), so the model can cite timestamps.\n- **JSON schema** (`_schema_line`): `{\"clips\":[{rank,start,end,duration_sec,hook,why,score(0-100),factors{...},factorNotes{...}}]}`. Strip `\u003Cthink>...\u003C\u002Fthink>` BEFORE parsing (`strip_think`); pull the outer `{...}` (`extract_clips`).\n- **Fail LOUD, not silent:** a non-empty reply with no parseable `{\"clips\":[...]}` raises `SelectionParseError` (job ERROR) — never a silent `[]` the UI shows as \"0 clips, success\". A genuinely empty reply or `{\"clips\":[]}` returns `[]`.\n- **Duration clamp** (`to_candidates`): `durationSec = end-start`, hard-clamped into the active envelope by extending\u002Ftrimming the END (preserve the hook\u002F`sourceStart`); never run past `durationSec` of the source.\n- **`sourceStart`** = clip start in the ORIGINAL video; captions later subtract it to re-base cues to local t=0.\n\n### Duration modes (envelope is the single source of truth, shared with boundary.py)\n- `standard`: **20-60 s** (default).\n- `midform`: **16-180 s** (real OpusClip teardown shows clips run 16-160 s, not 60-capped — ship the top moment at BOTH a long and a punchy length).\n- Unknown mode fails **closed** to `standard` (`resolve_duration_mode`). SELECT and BOUNDARY-SNAP MUST agree on the envelope or a mid-form clip gets re-clamped to 60 s at the snap stage (this was a real BLOCKER bug — thread `durationMode` into `snap_from_lists`).\n\n### Map-reduce for long transcripts\n> `len(lines) > 240` triggers it. Chunk into 200-line slices, shortlist 6 candidates\u002Fchunk (per-chunk `SelectionParseError` is tolerated → skip that chunk), then ONE global re-rank over the union shortlist (`build_rerank_user_prompt`). Reduce parse failure falls back to the validated map shortlist (degrade, don't error — we already have real candidates).\n\n### Clip-selection strategy — current (virality factors + percentile)\n- Each clip is scored on **four 0-100 virality factors** + a one-line note each (`FACTOR_NAMES`): `hookStrength` (first-3-seconds arrest), `emotionalFlow` (builds without dead spots), `perceivedValue` (viewer walks away with something), `shareability` (would someone send it to a friend).\n- A missing\u002Funparseable factor **degrades to the clip's legacy `score`** (not 0) so a parse hiccup doesn't crater its rank.\n- `viralityPct` = batch **percentile** of the raw factor-average, computed AFTER trim-to-count (rank within the clips the user actually receives, not the pre-trim pool). Singleton batch carries the raw average, not a 50 sentinel.\n- **Overlap ladder** (off by default): for each of the top-N moments meaningfully longer than `punchyShortSec` (default 30 s), emit an extra OVERLAPPING candidate sharing the same start (the hook) trimmed short — ship the moment at both lengths. Runs AFTER trim so shorts never push a real moment out of `count`.\n\n## 2. BOUNDARY-SNAP — deterministic, never mid-word (`features\u002Fboundary.py`)\nThe LLM returns rough clips; snap each `start`\u002F`end` to the nearest VALID boundary. Three snap-target sources:\n1. **Sentence end** — a word whose text (trailing quotes\u002Fbrackets trimmed) ends in `. ! ? …`; the target is that word's `end` time (`sentence_ends_from_words`).\n2. **Audio silence** — midpoint of each detected silent gap.\n3. **Scene cut** — detected scene-change timestamps.\n\nRules (all enforced):\n- Snap to the **nearest** valid target within the duration window; ties break toward the **smaller** timestamp (determinism).\n- **Never cut mid-word** (`_cuts_mid_word`: reject a target strictly inside any word span; exactly on a word start\u002Fend is fine).\n- Two-pass: snap start-first then end-first, keep the pair with least summed distance — so a clip whose start OR end already sits on a boundary still snaps.\n- **Idempotent**: re-snapping an already-snapped clip returns the same geometry.\n- A candidate with **no valid boundary** that keeps it in range is **dropped with a reason** (`SnapResult.reason`), surfaced per-clip to the UI — never silently mangled.\n\n### Detection commands (behind injectable seams)\n- **Silence** (`build_silencedetect_argv` \u002F `parse_silencedetect`):\n  ```\n  ffmpeg -hide_banner -nostdin -i IN -af silencedetect=noise=-30dB:d=0.5 -f null -\n  ```\n  `silencedetect` writes `silence_start:`\u002F`silence_end:` to **stderr**; the snap target is each gap's **midpoint**. A probe failure returns `()` (degrade to other targets), never crashes the pipeline.\n- **Scene cuts (CPU fallback)** — PySceneDetect `ContentDetector(threshold=27.0)`; each scene's start time in seconds. Lazy-imported inside the function so importing the module never drags in `scenedetect`.\n\n## 3. Scene detection — TransNetV2 + PySceneDetect merge (`features\u002Fscene_transnet.py`)\n- **TransNetV2** (`soCzech\u002FTransNetV2`, MIT) predicts a per-frame shot-change probability; a **rising edge** over `threshold=0.5` is a cut (a multi-frame dissolve ramp yields ONE cut at its leading edge, `predictions_to_cuts`). Its win over the histogram-diff `ContentDetector`: it catches **dissolves \u002F soft transitions** PySceneDetect misses. Frames are decoded to a **48x27 RGB** stack (tiny VRAM).\n- **Merge** (`merge_with_pyscenedetect`, `eps=0.25 s`): a cut in EITHER source survives; two cuts within eps collapse to one (earlier timestamp). The CPU fallback never stops working.\n- **Degrade contract:** `present=False` only when NO cut source exists at all (model missing + offline AND no provider). An empty-but-`present=True` track means \"this clip genuinely has no scene changes.\"\n- ⚠️ **Upstream-dead trap:** `soCzech\u002FTransNetV2` HF repo now 404s (verified 2026-06-28) so its commit can't be pinned; Reframe leaves the asset **intentionally unregistered** rather than pin a dead\u002Funverified repo. Live mirrors exist — `Sn4kehead\u002FTransNetV2`, `MiaoshouAI\u002Ftransnetv2-pytorch-weights` (both host `transnetv2-pytorch-weights.pth`) — but their snapshot LAYOUT differs from the original loader, so a blind re-point risks a SILENT scene-detection break. Confirm a mirror is loader-compatible before pinning `hf_repo=\u003Cmirror>` + a full 40-hex commit. (Source: `scene_transnet.register_scene_transnet_assets` docstring.) Confidence: HIGH that upstream is dead; MEDIUM on mirror compatibility.\n\n## 4. CUT — frame-accurate ffmpeg carve (`shortmaker._lazy_cut`)\n```\nffmpeg -hide_banner -nostdin -y -i IN -ss \u003Cstart> -to \u003Cend> -c:v libx264 -c:a aac -progress pipe:1 -nostats OUT\n```\n**The load-bearing detail:** `-ss`\u002F`-to` go **AFTER** `-i` → frame-accurate (decode-then-trim). `-ss` BEFORE `-i` is fast (keyframe seek) but inaccurate — clips start on the wrong frame and audio desyncs. Persist `sourceStart` on every clip record (§3). argv LIST, never a shell string (paths with spaces stay safe).\n\n## Clip-selection upgrades — the virality \u002F highlight stack (fold-in)\nReframe wraps the frozen LLM path with optional multimodal scoring (`select.select_unified`, `features\u002Fscorer.py`, `ranker.py`, `diversity.py`, `quality_gate.py`, `smolvlm2.py`). Each step graceful-degrades.\n\n1. **Signal fusion** (`scorer.fuse_score`, `DEFAULT_FUSE_ALPHA=0.5`): blend the LLM score with present-weighted audio\u002Fvisual signals. **Degrade by re-normalization (ONE code path):** a track with `present=False` is dropped from the weighted mean AND its weight; no fabricated zeros. Audio interest from PANNS **CNN14** (`panns-cnn14`).\n2. **Learned re-rank** (Tier-0, always): `ranker.rank` — a trained `LGBMRanker` (lightgbm) when present, else a deterministic factor-average fallback (zero downloads). A feedback flywheel trains it from user labels.\n3. **Diversity \u002F dedup** (Tier-0, always): `diversity.dedupe_candidates`, **MMR** default (`dpp` opt-in) over WU4 embeddings, else a zero-model signal-vector matrix. Stops five near-identical clips of the same moment.\n4. **Quality gate** (Tier-1, optional): `quality_gate.apply_quality_gate` — **DOVER-Mobile** VQA (`teowu\u002FDOVER`, ~60 MB, revision `841d2f90f8ed5e30e7d60213fd6b4354fd56b06c`) multiplicatively DEMOTES shaky\u002Fblurry\u002Fover-compressed clips. No-op when the model is absent.\n5. **Tier-2 VLM re-rank** (opt-in, off by default): `smolvlm2` reorders the top-K with **SmolVLM2-2.2B-Instruct** (`HuggingFaceTB\u002FSmolVLM2-2.2B-Instruct`, Apache-2.0 = commercial OK), loaded BF16 to fit sub-6 GB.\n\n### External highlight-detection heads (the upgrade beyond Reframe's current stack)\n- **LLM-on-transcript rubric is the right PRIMARY for talking-head content** — it's the universal OSS pattern, matches this stack, and is academically validated (arXiv **2512.21402**). Confidence: **HIGH**.\n- **Dedicated moment\u002Fhighlight-detection models** (the Lighthouse toolkit: **Moment-DETR \u002F QD-DETR \u002F CG-DETR \u002F UVCOM \u002F TR-DETR** heads, QVHighlights-trained) give a real virality lift mainly on **visual \u002F sports \u002F action** content, less so on talking-heads where the transcript carries the signal. Confidence: **MEDIUM**. Note: some Lighthouse checkpoints live on GitHub rather than HF (verify the source before pinning). Confidence on the GitHub-hosted checkpoints: MEDIUM.\n- Treat visual HD models as a SECONDARY signal fused at step 1, not a replacement for the transcript rubric on spoken-word sources.\n\n## ffmpeg seek \u002F concat gotchas (these actually bite)\n- **Decode-then-trim vs fast-seek** (above): `-ss`\u002F`-to` AFTER `-i` for accuracy; before `-i` for speed-but-imprecise. For the CUT stage, always accurate.\n- **concat DEMUXER needs identical params.** `ffmpeg -f concat -safe 0 -i list.txt -c copy out.mp4` stream-copies ONLY if every segment shares codec, resolution, pixel format, AND timebase. Mismatched timebase → A\u002FV drift or `Non-monotonous DTS` warnings. If segments differ, **re-encode** (drop `-c copy`) or normalize each segment first. Add `-fflags +genpts` \u002F `-avoid_negative_ts make_zero` when DTS goes non-monotonic.\n- **concat PROTOCOL (`concat:a|b`) is NOT the demuxer** — it only works for a handful of raw container formats (MPEG-TS), not arbitrary MP4. Use the demuxer (`-f concat`) or `filter_complex concat` for MP4.\n- **Audio drift on cut clips:** re-encoding audio to `aac` (as the CUT does) re-bases timestamps cleanly; `-c:a copy` on a non-keyframe-aligned cut can leave a leading silence\u002Fdesync. The Reframe filler-removal\u002Fsilence-trim paths use `filter_complex` segment concat (frame-accurate) precisely to avoid this.\n- **NO HGT-style date traps here** — clip selection is content-driven, not time\u002Fcalendar-gated; there is no equivalent of the Battle Cats date-drift footgun. The closest analog is the duration-envelope mismatch between SELECT and BOUNDARY-SNAP (fix: share `durationMode`).\n\n## GPU \u002F memory notes (6 GB budget)\n- **Qwen3-4B GGUF (selection LLM)** fits 6 GB at a sane quant; this is the workhorse. Confidence: HIGH.\n- **TransNetV2** runs on a 48x27 frame stream — trivial VRAM. **DOVER-Mobile** ~60 MB. **DETR-family highlight heads** fit alongside the LLM GGUF. 6 GB co-residency is fine for {LLM + DETR heads}. Confidence: HIGH.\n- **Running a CLIP \u002F BLIP-2 feature extractor CONCURRENTLY with the LLM risks OOM on 6 GB** — run visual feature extraction as a **separate offline stage** (extract embeddings to disk first, then load the LLM). Confidence: MEDIUM for the concurrent case.\n- **SmolVLM2-2.2B** is opt-in BF16, loaded ALONE (top-K re-rank only) to stay sub-6 GB — never co-resident with the selection LLM.\n- ProPainter-style temporal models are NOT part of this pipeline (that's watermark removal).\n\n## Pitfalls (carried from the as-built code + lessons)\n1. **Never return silent `[]` on a parse failure** — raise `SelectionParseError` so the job ends LOUD. A silent empty renders as \"0 clips success\" and hides the real failure.\n2. **SELECT and BOUNDARY-SNAP must share the duration envelope.** A mid-form (16-180 s) clip selected with `durationMode=midform` gets re-clamped to 20-60 s and dropped at snap if the mode isn't threaded into `snap_from_lists`. (Real BLOCKER fix in `shortmaker._lazy_snap`.)\n3. **Don't snap a cut into the middle of a word** — always run `_cuts_mid_word`; a cut exactly on a word start\u002Fend is OK.\n4. **TransNetV2 upstream is dead (404)** — don't blind-pin a mirror; verify loader-compatible snapshot layout first or you get a silent scene-detection break.\n5. **Compute the percentile AFTER trim-to-count**, not over the pre-trim pool, or the rank is wrong.\n6. **Degrade by re-normalization, not zeros** — a missing modality must drop its weight, never contribute a fabricated 0 to the fused score.\n7. **Factor parse-miss degrades to the legacy score**, not 0 — protects the clip's batch percentile from a single bad field.\n\n## Key files (canonical implementation)\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fselect.py` — SELECT recipe + virality factors + map-reduce + overlap ladder + `select_unified` multimodal wrapper.\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fboundary.py` — deterministic snapper + ffmpeg `silencedetect` + PySceneDetect detectors.\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fscene_transnet.py` — TransNetV2 rising-edge cuts merged with PySceneDetect.\n- `Reframe\u002Fsidecar\u002Fmedia_studio\u002Ffeatures\u002Fshortmaker.py` — orchestration: frame-accurate CUT + the downstream stages.\n- Adjacent: `scorer.py` (fusion), `ranker.py` (LGBM), `diversity.py` (MMR\u002FDPP), `quality_gate.py` (DOVER), `smolvlm2.py` (VLM re-rank), `audio_saliency.py` (PANNS CNN14).\n\n## Sources & confidence\n- Pipeline mechanics + commands: READ directly from the four Reframe source files above — **HIGH** (it's the as-built code).\n- LLM-on-transcript rubric as primary for talking-head: **HIGH** (universal OSS pattern; validated by arXiv 2512.21402).\n- HF model IDs\u002Flicenses (TransNetV2 `soCzech\u002FTransNetV2` MIT; DOVER `teowu\u002FDOVER`; SmolVLM2 `HuggingFaceTB\u002FSmolVLM2-2.2B-Instruct` Apache-2.0; PANNS `panns-cnn14`): **HIGH** (verified in source asset registrations); Lighthouse\u002FMoment-DETR checkpoints partly GitHub-hosted: **MEDIUM**.\n- Visual HD models giving real virality lift: **MEDIUM** (useful mainly for visual\u002Fsports, not talking-head).\n- 6 GB fit numbers: **HIGH** for LLM GGUF + DETR heads; **MEDIUM** if running CLIP\u002FBLIP-2 concurrently (run as a separate offline stage).\n\nNote: any scraped\u002Fweb page content consulted for this skill was treated as untrusted data; no embedded instructions were acted on.\n",{"name":5,"description":7},"main","a298c929b6cbd662e1fce54302ce520d5ceea1a5",".agents\u002Fskills\u002Freframe-video-cutting","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain","https:\u002F\u002Fgithub.com\u002FPrekzursil","2026-11-02 14:30:57",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Prekzursil\u002Fagent-skills-toolchain --skill reframe-video-cutting",{"tool":42,"command":43},"bunx","bunx skills add Prekzursil\u002Fagent-skills-toolchain --skill reframe-video-cutting",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Prekzursil\u002Fagent-skills-toolchain --skill reframe-video-cutting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freframe-video-cutting\u002FSKILL.md",true,[],[51,72,98,119,133,148],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":25},"01M6DF7D7478R55P46REYH4QAC","clarify-requirements","Resolve genuine pre-execution ambiguity by scanning repo context, generating 1-6 grounded options, and asking 1-3 focused questions via AskUserQuestion. NOT for mid-task use (injection risk); NOT when the goal is already unambiguous; use to disambiguate vague prompts before any file edits.","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Fworkspace-hooks\u002Fskills\u002Fclarify-requirements\u002FSKILL.md",[],[58,59,60,61,62,63,64,65,66,23,67,68,69,70,71],"clarify requirements","clarify","requirements","risk","options","task","prompts","goal","scanning","context","repo","injection","execution","file",{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":25},"01M6DF79CA4BHJS66J8EZDBPWJ","openmm-md","Run FREE, open-source, Windows-native GPU molecular dynamics via the openmm-md MCP (OpenMM + CUDA on the local NVIDIA GPU). Use for protein \u002F protein-ligand MD when you want a free stack or are on Windows without a Schrodinger license. Covers the full workflow (prepare, solvate, minimize, equilibrate, production, analyze, mmgbsa) AND an honest decision guide vs Schrodinger Desmond, including how to run Desmond legitimately on Linux or a cloud GPU with a real license. This is a deliberately LESSER free alternative and does NOT replace the schrodinger MCP tools. Do NOT use it to pick a free tool when a validated FEP+, WaterMap, IFD-MD, or Prime MM-GBSA result is actually required.","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Fmcp\u002Fopenmm-md-mcp\u002Fskill\u002Fopenmm-md\u002FSKILL.md",[],[79,80,81,82,83,84,85,86,87,88,89,90,91,92,23,93,94,95,96,97],"openmm md","how","decision","pick","linux","analyze","tool","stack","open","NVIDIA","gpu","license","workflow","windows","free","molecular dynamics","local","do","MCP",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":25},"01M6DF76C1MG85VEWP8VZCBNMN","visual-review","Take screenshots of web pages and UI using Playwright for visual review and iteration","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fvisual-review\u002FSKILL.md",[],[105,106,107,108,109,110,111,112,113,114,80,115,116,117,118],"review","visual","visual review","pages","web","false","iteration","take","check","slides","ui","screenshot","playwright","screenshots",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":25},"01M6DF73AQVCBZKEN0YXEX9FXP","status","Diagnostic status report — shows metaswarm installation state, project setup, and potential issues","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fstatus\u002FSKILL.md",[],[121,126,127,128,129,130,131,132],"setup","report","project","installation","project setup","issues","state",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":25},"01M6DF6X6C2XB0P6GX76P7TTYV","start","Use when starting work on any task, when the user mentions metaswarm, or when the user wants to begin tracked development work","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fstart\u002FSKILL.md",[],[135,140,63,141,142,143,23,144,145,146,147],"start issue","issue","ready","work on issue","user","work","work on","development",{"skillNo":149,"name":126,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":25},"01M6DF6QMJ9AJKFKHHKRT005PQ","Interactive project setup — detects your project, configures metaswarm, writes project-local files","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fsetup\u002FSKILL.md",[],[126,128,95,154,130,155],"files","interactive"]