From 0d56c61781f9fe021e0f7a57e49dd4d5a60e2b9f Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 4 Jun 2022 20:55:44 +0200 Subject: [PATCH] change: fix and parallel flac replay gain apply --- albentohandy | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/albentohandy b/albentohandy index cedc7b8..c27aff8 100755 --- a/albentohandy +++ b/albentohandy @@ -142,18 +142,35 @@ ConvertFlacToOpus() | parallel --will-cite --ungroup --eta --progress FlacToOpus {} } +ReEncodeFlac() +{ + local readonly INPUTFILE="$1" + + metaflac --export-tags-to=- $INPUTFILE \ + | sed '/REPLAYGAIN/d' > $INPUTFILE-meta + + nice --adjustment=10 flac --totally-silent --stdout --decode \ + $replaygainapply $INPUTFILE \ + | flac --silent --output-name=$INPUTFILE-tmp - + + metaflac --import-tags-from=$INPUTFILE-meta $INPUTFILE-tmp + + rm $INPUTFILE-meta + mv $INPUTFILE-tmp $INPUTFILE +} + FlacApplyReplayGain() { local readonly WORKDIR="$1" if [ -n "$replaygainapply" ]; then - for i in $(find $WORKDIR -name '*.flac' | sort); do - nice --adjustment=10 flac --totally-silent \ - $replaygainapply --output-name=$i-tmp $i - metaflac --remove-replay-gain $i-tmp - mv $i-tmp $i - done + declare -xf ReEncodeFlac + find $WORKDIR -name *.flac \ + | sort \ + | parallel --will-cite --ungroup --eta --progress \ + ReEncodeFlac {} fi + } PictureToFlac() -- 2.47.3