]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
change: fix and parallel flac replay gain apply
authorBastian Dehn <hhaalo@arcor.de>
Sat, 4 Jun 2022 18:55:44 +0000 (20:55 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 4 Jun 2022 18:55:44 +0000 (20:55 +0200)
albentohandy

index cedc7b8e16b698fa52fdc41a559c6da34182c7f3..c27aff826941001e9ee44544470cf2044a32be6a 100755 (executable)
@@ -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()