| 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:
- Output filename (e.g.
bruh.wav)
- Source file path (e.g.
/Users/jonathanburger/Downloads/source.mp3)
- Attribution source URL
Steps
-
Detect peak volume of the source file:
ffmpeg -i <source> -af "volumedetect" -f null - 2>&1 | grep max_volume
-
Calculate gain adjustment: target is -3dB peak. If current max is X dB, apply (-3 - X) dB gain.
-
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
-
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>
-
Verify the output peaks at -3dB:
ffmpeg -i <output> -af "volumedetect" -f null - 2>&1 | grep max_volume
-
Add entry to the soundEffects array in generate.ts:
{
fileName: "<output_filename>",
attribution: "<description> -- <source_url>",
},
Insert before the closing ]; of the soundEffects array.