Scoring and Key-Setting (What Music, What Key, What Tempo)
Applicable Scenarios
- Adding a musical bed that matches the tone of a finished video (commercials/voice-overs/documentaries/dramas/promotions)
- When you need a "consistent musical style" rather than "randomly changing tracks per segment"
- When you need to decide "whether the video should even have music"
1. The Four Key Questions (Answer Before Acting)
1.0. Read the Prompt First (New 2026-09-23, Overrides the Four Questions)
The input source for scoring is the original prompt submitted for rendering (render_scripts.md / prompt_package / one-sentence brief). First run:
bgmread.brief --prompt-text "City neon at night, the protagonist running in the rain, a twist revealed at the end, fast-cut high energy"
It translates the prompt into a scoring brief; the answers to the four questions are often already there:
| Brief Field | Source | Usage |
|---|---|---|
recipeId / genreTags | 32-subject keyword table (bilingual, e.g., 美食/food, 科技/AI/tech, 口播/讲解/talking head, 婚礼/wedding, 体育/sports); includes counter-examples (e.g., "sports meet" in humanities/voice-over text does not trigger sports) | Lock in the recipe |
energyLevel + bpmScale | Emotion words (燃/fast-cut → high energy; 治愈/soothing → low energy; 克制/sophisticated → low energy) | Tune BPM and intensity |
instrumentation.avoid | Forbidden words (no drums → remove kick/hat; keep ambient sound → use keep-all) | Filter candidates, determine layers |
climax.position/atSec | Climax clues (twist at end → 85% mark; golden three seconds → 8% mark; mid-section burst → 50% mark) | Basis for segment alignment |
musicLevelDeltaDb | "Music should be quiet / prominent" | Fine-tune scoring level (±3dB) |
noMusic | "No background music" | Directly determine no music needed (do-no-harm) |
If a subject cannot be matched, the brief honestly reports low confidence, selecting a recipe based on explicit requests and track metadata; does not analyze the source video's sound/dialogue/energy quality to decide acceptance. Defaults to compose-only sourcing locally; only connects to the internet for other sourcing policies upon explicit request.
- Subject: 32 categories—16 existing (product commercials/voice-over interviews/food/tech/travel/night scenes/beauty/parenting/automobiles/real estate/promotions/documentaries/luxury brands/drama/suspense/comedy) + T-15 new (weddings/sports/esports/fashion/maternal/infant/home/new energy/finance/city dusk/festivals/science education/life vlogs/emotional stories/brand manifestos/pets/fitness)—determines the style family. These subjects are used to request the brief and music candidate metadata; they do not form a source video quality score; selects one actual plan per request, no trial renders of quality candidates.
- Scene and Subject: Studio white background, indoor half-body, close-up of a dish, screen demo, street shot B-roll... determines instrumentation thickness (the finer the subject, the thinner the instrumentation).
- Emotional Goal: Clean and trustworthy / Trustworthy and friendly / Tempting and warm / Calm and precise / Open and airy / Dramatic and modern / Transparent and trustworthy / Bright with warmth / Strong and precise / Bright and airy / Intense and urgent / Genuine and restrained / Restrained and textural / Emotional progression / Unsettling tension / Light and bright—determines mode (major/minor/Dorian/Phrygian) and intensity.
- Platform: Douyin/Xiaohongshu/Video Account/Bilibili/YouTube—determines whether high frequencies need to be brighter and low frequencies more contained (for phone speakers).
If the four questions cannot be answered, first take the closest recipe from the bgmread.recipes cheat sheet, then explain "why this one, and which ones were ruled out."
2. Recipe Library Usage
bgmread.recipes --list # Current bundled recipes (32)
bgmread.recipes --genre food --mood tempting-warm # Targeted search
bgmread.recipes --id food # Get a single recipe (includes forbidden items and notes)
Recipe fields and meanings:
| Field | Meaning | Usage |
|---|---|---|
key / mode | Key / Mode | Determines "bright/dark": major = bright, aeolian = introspective, dorian = calm, phrygian = unsettling |
bpm | Recipe base tempo | Only a baseline; actual tempo also depends on edit rhythm (see Section 3) |
chords | Chord progression | 4-chord loop; I/IV = bright, vi/iv = introspective |
instrumentation | Instrumentation | pad (foundation) / bass (low-frequency movement) / pluck (drive) / kick·hat (rhythm) / bell (accent) |
musicLevelDb | Average BGM level in the final video | Voice-over -26, commercial -22, promotion -19 (higher value = more "front stage") |
duckingDb | Ducking depth when speech occurs | Voice-over/documentary 13–14, commercial/promotion 10–12 |
avoid | Creative forbidden items | Filters music options during selection; already-processed videos are not automatically re-done |
3. Tempo Decision: Recipe BPM or Cut-Point Back-Calculation
If the beat doesn't match, 90% of the time it's the wrong tempo. Two rules:
- Edit Rhythm Priority: Adjacent cut-point distance ÷ one beat = whole number of beats, back-calculate BPM (
bpm_strategy=cut-driven); if the relative difference from the recipe BPM is ≤25%, use the back-calculated value; otherwise, use the recipe BPM and explain the conflict. - One project, one tempo: Don't use "128 for the intro, 96 for the main body"—it sounds like two different videos spliced together.
Explicit cut-point grid reference: nearest beat point error ≤80ms can be used for clear diagnostic downbeat marking; this is not a default source-shot quality gate. The response records the adopted BPM and the requested grid; if beat-matching compliance is not tested, it cannot be marked as passed, and no automatic remixing is performed.
3.2. Section Selection: Picking "the Most Suitable Part" from a Track (Including Climax)
External tracks are often 2–3 minutes long, while videos are only 15–60 seconds—"which part to cut" is as important as "which track to use."
bgmread.structure --in track.wav # Analyze structure: intro/verse/build/drop/breakdown/outro + BPM + climax candidates
bgmwrite.mix ... --section auto # Auto-select section (default behavior)
bgmwrite.mix ... --section climax # Explicitly request climax section
bgmwrite.mix ... --section calm # Explicitly request calm section
bgmwrite.mix ... --section-start 62 --section-end 78 # Manual specification (seconds)
Section selection only analyzes the requested music: auto/climax/calm use the track's rule-based structure; explicit start/end follow the provided seconds; does not calculate source video dialogue peaks, non-dialogue energy, lip movements, or "safe windows." best defaults to full track/composition single mix; section response retains mode/chosen/reason.
Three rules:
- Explicit start/end must be within limits: start ≥ 0, end > start, and end does not exceed track duration; invalid parameters cause a clear failure.
- Structure identification is a rule-based segmentation using music energy quantiles, direction, and attack density; it is not a score or deep learning semantic proof.
- Untested video climax, dialogue percentage, and quality margin remain null/not reviewed; do not fabricate "climax aligned"; no automatic secondary processing based on diagnostics.
4. Structure (The Video Length Equals the Track Length)
| Section | Percentage | Instrumentation | Function |
|---|---|---|---|
| Intro | ~15% | Only pad + bass | Don't overshadow the first sentence |
| Body | ~73% | Add pluck, kick/hat if necessary | Provide propulsion |
| Outro | ~12% | Drop back to pad | Natural end, no hard cut |
No "song chopping": If an external track is shorter than the video, loop to fill (using actual local loop concatenation and timeline filters); don't cut a melody short to match the duration.
5. Creative Forbidden Items (Reference for Selection; User Feedback Forms New Requests)
- Emotion opposite to the image (e.g., wedding video with a suspense score, memorial scene with a promotion rhythm);
- Mixing multiple scoring languages in one project (inconsistent key/instrumentation);
- Percussion hitting voice-over punctuation (voice-over videos default to no kick/hat);
- When users explicitly care about dialogue clipping/noise floor, record feedback separately; do not default to measuring source audio quality, auto-separating, or reverting upstream;
- Adding embellishments around key information points (like punchlines/reveals/prices) that steal attention (leave white space where needed).
6. Allowed Conclusion: No Music
bgmwrite.best only gives no_bgm_needed when the brief explicitly requests "no background music/keep original sound," preserving the real-source SHA256; cannot automatically decide against music based on existing music, speech activity ≥90%, noise floor, or no safe window. When ambient sound is content, you can explicitly request no added music in the request; without such a request, execute the selected plan once.
Default retains the full original program; only if separate tracks are dropped does it go the original program path; explicit independent tracks must be real and valid; cannot claim source audio as separated dialogue. Audio source/license/tenant/current byte failure remains clear; no silent track swap or downgrade.
Output Contract
The selection explanation must answer four questions: What subject, what scene/subject, what emotional goal, what platform, and include: recipe ID, key/mode, BPM and basis (recipe/cut-point back-calculation), instrumentation list, scoring level, ducking depth.
Parameter Boundaries and Single Execution
- BPM/level/ducking/fade in/out are handled within the actual interface's valid ranges; request targets are not measured quality values.
- Only music material is analyzed to calculate section selection and requested gain; source dialogue/ambient/loudness/lip-sync quality is not measured.
- Source video is read-only; original program audio is default; music-only must explicitly drop permission, replace-bed must have independent dialogue source.
- best selects one plan per request and music metadata; score=null; no quality candidate voting across source video or final video.
- Actual FFmpeg/source access/permission failures cause a clear failure; no auto 3dB retry or silent replacement of original audio.
Failure Modes (Symptom → Cause → Resolution)
| Symptom | Detector/Cause | Resolution | Example |
|---|---|---|---|
| Requested recipe or track doesn't exist | Current track library ID/file | Name the missing item, stop; don't swap for an unknown track | — |
| Track permission/signature mismatch | Real source authorization and current SHA256 | Authorization fails; don't bypass by changing source via internet | — |
| User says subject or emotion doesn't match | Request brief and adopted recipe | Form a clear request for a new recipe; no automatic quality retry | FC-BGM-001 |
| User says music too loud/not prominent enough | User feedback and requested level | Clearly adjust level/ducking; new local request; don't default to measuring margin and declare failure | — |
| User requests beat-matching but rhythm doesn't match | Explicit cut_points and adopted BPM | Adjust request speed or state the selection basis; old video remains unchanged | — |
| Section selection out of bounds / cannot be read | Explicit start/end and track specs | Return request/tool error; don't fabricate climax position | — |
| Local synthesis/mixing fails | FFmpeg stderr, output path | Save real failure; no output means incomplete | — |
| Original audio muted / existing music / high noise floor | Original program actual stream | Default accept; cannot auto-decide not to score or append ASR/TTS | — |
Knowledge Base Reference
Knowledge base: library/bgm-kb/ — SCORE-002 Subject-style fit decision tree (basis for Four Key Questions and recipe selection), SCORE-003 Beat-matching and music structure (basis for tempo decision and section alignment), SCORE-006 Explicit no-music request (no music is user intent, not automatic source-quality veto), SCORE-008 Common accident case library (entry point for reviewing mis-scoring accidents). Access entry: library/bgm-kb/_INDEX.md