Spaces:
Running
Running
Document voiceover background music ducking template
Browse files
docs/voiceover-music-ducking.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Voiceover + background music ducking
|
| 2 |
+
|
| 3 |
+
The `voiceover_music_ducking` template mixes a video containing narration with a separate background-music file. FFmpeg side-chain compression lowers the music while narration is active, then mixes the narration and ducked music into the output. The source video stream is copied without re-encoding.
|
| 4 |
+
|
| 5 |
+
## Endpoint
|
| 6 |
+
|
| 7 |
+
`POST https://basyx-mediarouter.hf.space/v1/templates/run`
|
| 8 |
+
|
| 9 |
+
## Request example
|
| 10 |
+
|
| 11 |
+
```json
|
| 12 |
+
{
|
| 13 |
+
"template": "voiceover_music_ducking",
|
| 14 |
+
"inputs": [
|
| 15 |
+
{
|
| 16 |
+
"url": "https://example.com/narrated-video.mp4"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"url": "https://example.com/background-music.mp3"
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"parameters": {
|
| 23 |
+
"music_volume": 0.22,
|
| 24 |
+
"voice_volume": 1,
|
| 25 |
+
"threshold": 0.03,
|
| 26 |
+
"ratio": 8,
|
| 27 |
+
"attack": 20,
|
| 28 |
+
"release": 300,
|
| 29 |
+
"audio_bitrate": "192k"
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Use the standard MediaRouter input contract for multiple media inputs; if your client uses a nested `input` object, supply the equivalent two-item input collection supported by the shared resolver.
|
| 35 |
+
|
| 36 |
+
## Parameters
|
| 37 |
+
|
| 38 |
+
| Parameter | Default | Range | Purpose |
|
| 39 |
+
|---|---:|---:|---|
|
| 40 |
+
| `music_volume` | 0.22 | 0–2 | Linear gain applied to the music before ducking |
|
| 41 |
+
| `voice_volume` | 1 | 0–4 | Linear gain applied to narration |
|
| 42 |
+
| `threshold` | 0.03 | 0.001–1 | Side-chain threshold; lower values trigger ducking more readily |
|
| 43 |
+
| `ratio` | 8 | 1–20 | Compression ratio for the music |
|
| 44 |
+
| `attack` | 20 ms | 1–2000 ms | How quickly music is reduced after narration starts |
|
| 45 |
+
| `release` | 300 ms | 10–5000 ms | How quickly music returns after narration pauses |
|
| 46 |
+
| `audio_bitrate` | `192k` | Supported AAC bitrates | Output audio bitrate |
|
| 47 |
+
|
| 48 |
+
The source video must contain an audio stream with the narration, and its duration must be available from probing. This template does not generate narration or music. Listen to the rendered output and adjust music gain and compression settings for the particular mix.
|
| 49 |
+
|
| 50 |
+
## Template discovery
|
| 51 |
+
|
| 52 |
+
- `GET /v1/templates/voiceover_music_ducking`
|
| 53 |
+
- `GET /v1/templates?category=podcast`
|