From 472f6bd9b4d2d7c1465888e66192c04a868bb7f6 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Wed, 20 Nov 2024 03:10:02 -0500 Subject: [PATCH] global/zsh: add censor-audio function --- users/modules/global/shells/zsh.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/users/modules/global/shells/zsh.nix b/users/modules/global/shells/zsh.nix index 83209f5..df61ca2 100644 --- a/users/modules/global/shells/zsh.nix +++ b/users/modules/global/shells/zsh.nix @@ -83,6 +83,28 @@ git clone "$location" "$dir" "$@" \builtin cd "$dir" } + + censor-audio() { + file="$1" + shift 1 + + if [ 2 -gt $# ]; then + echo "Not enough arguments" + exit 1 + fi + + filters="" + + while [[ "$1" =~ ^"[0-9]+\.?[0-9]*-[0-9]+\.?[0-9]*"$ ]]; do + if [ $filters != "" ]; then + filters+=", " + fi + filters+="volume=enable='between(t,''${1/-/,})':volume=0" + shift 1 + done + + ffmpeg -i "$file" -vcodec copy -af "$filters" "$@" + } ''; dotDir = ".config/zsh";