From 29509765a30db2c5982e456a69aa4f93df9b4dfe Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Wed, 4 Feb 2026 22:17:06 +0100 Subject: [PATCH] add audio normalize function --- modules/media-process.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/media-process.nix b/modules/media-process.nix index 19324cb..140b705 100644 --- a/modules/media-process.nix +++ b/modules/media-process.nix @@ -22,6 +22,18 @@ ' _ } + function audio-normalize() { + local target="''${1:--23}" + local dir="''${2:-.}" + find "$dir" \( -name '*.flac' -o -name '*.mp3' -o -name '*.wav' -o -name '*.ogg' -o -name '*.wma' -o -name '*.aiff' \) -type f -print0 | xargs -0 -P4 -n1 sh -c ' + f="$1" + target="$2" + outfile="./normalized/''${f%.*}.m4a" + mkdir -p "$(dirname "$outfile")" + ffmpeg -i "$f" -af loudnorm=I="$target":TP=-1.5:LRA=11 -c:a aac -b:a 128k -map_metadata 0 -c:v copy -movflags +faststart "$outfile" + ' _ {} "$target" + } + function video2av1() { local height="''${1:-720}" local dir="''${2:-.}"