add-sound-effect
$
npx mdskill add remotion-dev/remotion.media/add-sound-effectNormalize and integrate a new sound effect WAV file into the remotion project build.
- Adds custom audio assets to the project structure for media generation.
- Utilizes FFmpeg for audio processing, including normalization and trimming.
- Executes a multi-step pipeline involving volume detection and file manipulation.
- Overwrites or updates the project's source code by modifying generate.ts.
SKILL.md
.github/skills/add-sound-effectView on GitHub ↗
---
name: add-sound-effect
description: Add a new sound effect to the remotion-media project. Converts a source audio file to WAV format normalized to -3dB peak and adds it to generate.ts.
user-invocable: true
---
# Add Sound Effect
Add a new sound effect WAV file to the remotion-media project.
## Required information
Ask the user for:
1. **Output filename** (e.g. `bruh.wav`)
2. **Source file path** (e.g. `/Users/jonathanburger/Downloads/source.mp3`)
3. **Attribution source URL**
## Steps
1. **Detect peak volume** of the source file:
```
ffmpeg -i <source> -af "volumedetect" -f null - 2>&1 | grep max_volume
```
2. **Calculate gain adjustment**: target is -3dB peak. If current max is X dB, apply `(-3 - X)` dB gain.
3. **Convert to WAV** with gain adjustment, 44100 Hz sample rate, PCM 16-bit:
```
ffmpeg -i <source> -af "volume=<adjustment>dB" -c:a pcm_s16le -ar 44100 <project_root>/<output_filename> -y
```
4. **Trim trailing silence** using silence detection:
```
ffmpeg -i <output> -af "silencedetect=noise=-40dB:d=0.1" -f null - 2>&1 | grep silence
```
If there is trailing silence (silence_start near the end), trim the file to just after the last non-silent section (add ~0.15s padding after the last sound):
```
ffmpeg -i <output> -t <trim_point> -c:a pcm_s16le -ar 44100 <output_trimmed> -y && mv <output_trimmed> <output>
```
5. **Verify** the output peaks at -3dB:
```
ffmpeg -i <output> -af "volumedetect" -f null - 2>&1 | grep max_volume
```
6. **Add entry** to the `soundEffects` array in `generate.ts`:
```ts
{
fileName: "<output_filename>",
attribution: "<description> -- <source_url>",
},
```
Insert before the closing `];` of the `soundEffects` array.