diff --git a/about/index.html b/about/index.html index 9a913b8..6cea0ca 100644 --- a/about/index.html +++ b/about/index.html @@ -6,7 +6,7 @@ name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> - +

Failed loading TinaCMS assets

Your TinaCMS configuration may be misconfigured, and we could not load the assets for this page.

Please visit this doc for help.

'; + } + + + +
+ + \ No newline at end of file diff --git a/books/index.html b/books/index.html index f9aa6a4..639530d 100644 --- a/books/index.html +++ b/books/index.html @@ -6,7 +6,7 @@ name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> - + + + + + + FFmpeg audio cleanup - joshua.seigler.net + + + + + + + + + + + + + +
+ +

FFmpeg audio cleanup

+
+ Joshua SeiglerJune 26, 2025 + + technical + ffmpeg + +
+
+ +
+ +
+

+ I recently needed to process 20+ phone audio recordings. The audio is + mp3 recordings in stereo, made in an environment with echoes and noise + from fans/heaters. +

+

+ Although I could do it easily with + Tenacity + I didn’t want to use a manual process, since it would take days. So I + tried using FFmpeg filters and Bash scripting. +

+

+ I found an FFmpeg filter called + compand + which lets you map an input decibel range to an output decibel range. I + also used the + anlmdn + filter to reduce noise, and the + highpass + filter to help with clarity. +

+

I ran into a couple gotchas.

+
    +
  1. + mpv does something special for audio playback that + prevents audio from clipping. vlc plays the file as it + is. +
  2. +
  3. + Because the compressor has an attack and decay (which is necessary for + things to sound good) it can cause clipping if the volume rises + sharply. Applying a delay parameter with half the + duration of the attack length fixed this. +
  4. +
+

Here is the script:

+
#!/bin/bash
+if [ "$#" == "0" ]; then
+  echo "Error: no arguments provided."
+  echo "Usage: $0 file1 file2 file3 ..."
+  echo "   or: $0 *.ext"
+  exit 1
+fi
+
+trap "exit" INT
+
+while [ "$#" != "0" ]; do
+  base="${1%%.*}"
+  ext="${1##*.}"
+  outfile="./normalized--$base.$ext"
+  if [ ! -f "$outfile" ]; then
+    echo "Processing $1"
+    ffmpeg -i "$1" -v warning -ac 1 -af "compand=attacks=0.3:decays=0.3:delay=0.15:points=-80/-300|-45/-25|-27/-15|0/-12|20/-12,anlmdn=s=10,highpass=f=500" -threads 4 "$outfile"
+  else
+    echo "Skipping $1, already processed."
+  fi
+  shift
+done
+
+

+ If this is useful to you please leave a comment or send an email, I + would love to hear about it. +

+
+ +
+ +
+ + +
+ + diff --git a/posts/finally-a-coherent-worldview/index.html b/posts/finally-a-coherent-worldview/index.html index a6859d8..03dd160 100644 --- a/posts/finally-a-coherent-worldview/index.html +++ b/posts/finally-a-coherent-worldview/index.html @@ -6,7 +6,7 @@ name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> - + + + + + + Posts tagged #ffmpeg - joshua.seigler.net + + + + + + + + + + + + +
+ +

Posts tagged #ffmpeg

+
+ +
+
+
+
+ + +
+ + +
+ + diff --git a/tags/how-to/index.html b/tags/how-to/index.html index 75fca0e..f12af19 100644 --- a/tags/how-to/index.html +++ b/tags/how-to/index.html @@ -6,7 +6,7 @@ name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> - +