Original Audio and BGM Layering
1. Default Policy and Audio Track Facts
Successfully rendered shots are accepted by default; post-production music operations must not reject, re-render, or supplement TTS due to original audio noise, dialogue, lip-sync, loudness, or quality opinions. The original footage is read-only, and the full embedded audio is kept as the program by default, without pretending that dialogue and ambient sound have been separated.
| Source | What can be honestly claimed | Allowed operations |
|---|---|---|
| Ordinary embedded audio track | Complete program | Keep by default, mix in new music on request |
| No embedded audio track | Original track does not exist | Generate silent fill of equal duration for mixing; cannot synthesize dialogue |
| Explicit independent dialogue / ambient / bed | Independent source does exist | Mix according to declared strategy after current bytes, timeline, and trusted signature pass checks |
| Explicit invalid separation | Source not available | Fail and close; prohibited from falling back to embedded program to mask the error |
2. Strategy Parameters and Boundaries
| Strategy | Prerequisite | Result |
|---|---|---|
| keep-all | Retain full original program | Overlay requested music once; do not remove original audio |
| keep-dialogue | Keep original audio by default; process according to definition when real independent tracks exist | Cannot discard original program based on automatic sound source classification |
| replace-bed | Have actually distinguishable, authorized bed and retained tracks | Replace only the declared music layer; cannot guess split tracks from mixed program |
| music-only | Explicit allow_discard_original | Original audio is discarded; must be visible in the report |
Level, ducking, fade-in/fade-out, and music selection are request transformation parameters; by default, quiet windows, human voice activity, audio headroom, audibility, or LUFS are not measured as acceptance gates. Unmeasured metrics are null.
3. Explicit Stem Validation
- Read stem references, project, tenant, and workspace from the trusted service signature; record the actual signature and reference digest.
- Check each track's actual file, non-empty bytes, SHA-256, sample rate, and timeline binding; original footage source must also be consistent.
- If parameters contain null, false, missing fields, unauthorized access, expired signatures, or hash mismatches, stop with the real error; do not default to falling back just because the local original footage exists.
- Only perform separation when explicitly requested; the real model/tool failure cannot be masked by "no separation needed".
4. Music Execution and Process Reference
- Resolve track ID to registered file and license first; use the same resolution result for master and variants, do not treat the ID as a file path.
- Ordinary local recipes default to compose-only; only query external sources when explicitly using online-first / local-first strategies.
- By default, use the selection according to the explicit interval or "full"; auto/climax are explicit analysis requests and cannot implicitly scan original audio to select music.
- When the track is too short, generate limited fill based on the actual clip duration; do not let infinite loop input cause FFmpeg to run forever.
- Derive variants from a clean audio source that has not been mixed with new music; each variant is mixed exactly once; prohibit re-layering the same bed on an already mixed version.
5. SOP
- Trigger: User requests BGM. Read original audio facts, tracks, and stem declarations. Receipt: Source file hash, hasAudio, original audio policy, license. Failure: Stop immediately if source, stems, or authorization do not match.
- Trigger: Source actually available. Execute one actual mix pass with explicit interval, level, and strategy. Receipt: Filter graph, track path, original audio mapping, and tool exit code. Failure: Stop on non-zero tool exit, missing track, or unreadable audio track; do not auto-reduce level and retry or switch supplier.
- Trigger: New file generated. Verify actual audio tracks, canvas, non-empty file, and consistency with source. Receipt: Output SHA-256, audio source, qualityReviewed=false, metrics=null. Failure: Stop delivery if missing components or byte changes.
6. Failure Modes (Cause → Resolution)
| Symptom | Detector / Cause | Resolution |
|---|---|---|
| Explicit stems ignored | Input fields dropped by truthy check | Preserve field existence; explicitly fail on invalid shapes; prohibit default substitution |
| Existing music bed layered twice | Variant uses already mixed master as source | Rebuild the local layer from clean program; do not regenerate the original shot |
| Library ID master available but variant fails | Resolution result not passed through | Pass actual registered path and license; stop on real missing items rather than swapping tracks |
| FFmpeg hangs | Unbounded stream_loop or EOF waiting | Use finite target duration, leave failure on timeout; do not retry indefinitely |
| Original audio accidentally discarded | Policy inconsistent with mapping or authorization | Explicitly fail and indicate the original audio policy; prohibit forging keep-all |
| User thinks music is too loud | User feedback, not a default quality gate | Rework audio layer with new explicit level; record new version |
7. Evidence and Sources
Record the real original footage hash, stem signatures, track ID/path, license/TASL, actual mixing parameters, output hash, and original audio policy. Master, variants, and reworks share the same source facts; if independent analyze/structure/verify is explicitly called, the receipt shall separately indicate diagnostics and not impersonate the default full-clip quality acceptance.