Urgent.News

What's breaking now, across thousands of outlets.

Tech

Normalizing Thousands of Short Meme Clips with ffmpeg: Loudness, Silence Trimming and Small Files for a Browser Soundboard

If you've ever tapped through a soundboard, you know the problem even if you've never named it. One button is a polite little "ding". The next is an air horn that makes you rip your earbuds out. A third seems broken, until it starts playing almost half a second late because the file begins with dead air. None of that is a frontend bug. You can preload, pool Audio elements and tune the Web Audio…

The article discusses the challenge of normalizing short, silences-laden meme clips for a browser soundboard. Such clips often start with dead air, making playback laggy, regardless of how well the frontend is optimized. The author suggests fixing this issue during the asset pipeline, before the clips reach the browser.

The normalization process involves several steps. First, leading and trailing silence is removed using the silenceremove filter in ffmpeg. The threshold should not be set too high, as it may remove important audio elements. A tiny tail can be added if the clip has reverb to make the ending sound smoother.

Next, loudness normalization is applied using the loudnorm filter in ffmpeg. This filter implements EBU R128 loudness normalization, targeting perceived loudness in LUFS. The process is run in two passes. The first pass measures the input audio's loudness, integrated loudness, true peak, and other parameters. The second pass uses these measurements to set a consistent gain value, ensuring all clips have the same perceived loudness.

The challenge is that integrated loudness measurements can be unreliable for very short clips. In such cases, simple peak normalization is used instead. The peak normalization raises the peak volume to a target level, usually -2 dB, ensuring all clips are in the same neighborhood of loudness.

Finally, the clips are encoded into MP3 format using ffmpeg. The encoding process downmixes to mono and uses a modest bitrate of 96k. MP3 is chosen for its universal playback compatibility. The script also removes any embedded metadata, such as album art or artist names, to ensure a clean playback experience.

The article provides a Node.js script to automate the normalization and encoding process for a whole folder of clips. It measures the duration of each clip, picks the appropriate normalization path, and runs several files in parallel to optimize performance.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The DNS Drift That Wasn't DHCP: How Proxmox Cloud-Init Silently Injects Search Domains

Originally published at woitzik.dev Disclosure: This post contains Amazon affiliate links (marked with *). If you buy through them, I earn a small commission at no extra cost to you.

  • Proxmox cloud-init silently injects 'home.lan' search domain
  • External pod queries experienced 341ms average DNS delay
  • Issue resolved by unsetting default search domain in cloud-init

Firefox on macOS: TouchID, Apple Silicon, and Platform-Specific Features

Firefox on macOS has some specific integrations worth knowing about, plus a few rough edges compared to Safari. TouchID for Passwords Firefox on macOS supports TouchID for the built-in password…

  • Firefox on macOS offers TouchID for Passwords autofill feature
  • Firefox supports Retina displays natively with 2.0 Device Pixel Ratio
  • Firefox runs natively on Apple Silicon with better performance

More from Friday 16 October →