From 20dffb40c5de369207c2003b59c0e756ae19a36a Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 14 Jun 2016 20:50:26 +0200 Subject: [PATCH] replaygain tagging; symlink instead of copy add: replaygain tagging add: option -S parallel cluster change: symlink instead of copy change: short status; remove verbose remove: mp3gainalbum.sh --- albentohandy.sh | 41 ++++++++++++++++++++++++----------------- flactomp3v2.sh | 41 ++++++++++++++++++++++++++++++----------- mp3gainalbum.sh | 19 ------------------- 3 files changed, 54 insertions(+), 47 deletions(-) delete mode 100755 mp3gainalbum.sh diff --git a/albentohandy.sh b/albentohandy.sh index 28e293b..c32eba1 100755 --- a/albentohandy.sh +++ b/albentohandy.sh @@ -1,8 +1,12 @@ #!/bin/bash +# work is a directory do symlinked original and convert work="$(pwd)/handy" +# scriptpath is the path to flactomp3v2.sh script scriptpath="/media/smbdaten1/scripts" +# musicpath is collection directory musicpath="/media/smbdaten1/musik-flac" +parallelopts=":" if [ ! -f albumlist ] then @@ -12,34 +16,37 @@ then exit fi +while getopts "S:" optname +do + case "$optname" in + "S") + parallelopts="$OPTARG" + ;; + *) + parallelopts=":" + ;; + esac +done + echo -echo "Phase 01 von 04: flac's in das Arbeitsverzeichnis $work kopieren" -echo +echo "Phase 01 von 03: flac's in das Arbeitsverzeichnis $work verlinken" if [ ! -d $work ] then mkdir $work fi -anzahl=$(cat albumlist | wc -l) +# make symlinks of original flac's for i in $(cat albumlist) do - z=$(($z+1)) - rsync -av $musicpath/$i $work/ - echo - echo "Phase 01: $((100*$z/$anzahl))% fertig" - echo + cp -rs $musicpath/$i $work/ done -echo "Phase 02 von 04: flac -> mp3" -echo -find $work -name '*.flac' | sort | parallel $scriptpath/flactomp3v2.sh {} -echo -echo "Phase 03 von 04: flac's und cover's loeschen" echo -find $work -name '*.flac' | sort | xargs rm -v -find $work -name 'cover*' | sort | xargs rm -v +echo "Phase 02 von 03: flac -> mp3" +find $work -name '*.flac' | sort | parallel --eta --progress --noswap -S $parallelopts $scriptpath/flactomp3v2.sh {} echo -echo "Phase 04 von 04: replaygain hinzufuegen" +echo "Phase 03 von 03: flac's und cover's loeschen" echo -$scriptpath/mp3gainalbum.sh $work +find $work -name '*.flac' | sort | xargs rm +find $work -name 'cover*' | sort | xargs rm diff --git a/flactomp3v2.sh b/flactomp3v2.sh index 55cf105..b051258 100755 --- a/flactomp3v2.sh +++ b/flactomp3v2.sh @@ -11,21 +11,40 @@ ALBUM=$(metaflac "$a" --show-tag=ALBUM | sed s/.*=//g) GENRE=$(metaflac "$a" --show-tag=GENRE | sed s/.*=//g) TRACKNUMBER=$(metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g) DATE=$(metaflac "$a" --show-tag=DATE | sed s/.*=//g) +RRL=$(metaflac "$a" --show-tag=REPLAYGAIN_REFERENCE_LOUDNESS | sed s/.*=//g) +RTG=$(metaflac "$a" --show-tag=REPLAYGAIN_TRACK_GAIN | sed s/.*=//g) +RTP=$(metaflac "$a" --show-tag=REPLAYGAIN_TRACK_PEAK | sed s/.*=//g) +RAG=$(metaflac "$a" --show-tag=REPLAYGAIN_ALBUM_GAIN | sed s/.*=//g) +RAP=$(metaflac "$a" --show-tag=REPLAYGAIN_ALBUM_PEAK | sed s/.*=//g) # stream flac into the lame encoder -# tag-v2 -flac -s -c -d "$a" | lame --silent -b 192 -m j --id3v2-only --pad-id3v2 --ignore-tag-errors \ ---ta "$ARTIST" --tt "$TITLE" --tl "$ALBUM" --tg "${GENRE:-12}" \ ---tn "${TRACKNUMBER:-0}" --ty "$DATE" - "$OUTF" +flac -s -c -d "$a" | lame --silent -b 192 -m j --noreplaygain - "$OUTF" -if [ -f ${a%/*}/cover.jpeg ] +# ID3v2.3 tagging +if [ -f ${a%/*}/cover.jpg ] then - eyeD3 --to-v2.3 --add-image ${a%/*}/cover.jpeg:FRONT_COVER --no-tagging-time-frame $OUTF > /dev/null 2>&1 + eyeD3 --to-v2.3 \ +-a "$ARTIST" -t "$TITLE" -A "$ALBUM" -G "${GENRE:-12}" \ +-n "${TRACKNUMBER:-0}" -Y "$DATE" \ +--set-user-text-frame="REPLAYGAIN_REFERENCE_LOUDNESS:$RRL" \ +--set-user-text-frame="REPLAYGAIN_TRACK_GAIN:$RTG" \ +--set-user-text-frame="REPLAYGAIN_TRACK_PEAK:$RTP" \ +--set-user-text-frame="REPLAYGAIN_ALBUM_GAIN:$RAG" \ +--set-user-text-frame="REPLAYGAIN_ALBUM_PEAK:$RAP" \ +--add-image ${a%/*}/cover.jpg:FRONT_COVER \ +--no-tagging-time-frame \ +$OUTF > /dev/null 2>&1 else - if [ -f ${a%/*}/cover.jpg ] - then - eyeD3 --to-v2.3 --add-image ${a%/*}/cover.jpg:FRONT_COVER --no-tagging-time-frame $OUTF > /dev/null 2>&1 - fi + eyeD3 --to-v2.3 \ +-a "$ARTIST" -t "$TITLE" -A "$ALBUM" -G "${GENRE:-12}" \ +-n "${TRACKNUMBER:-0}" -Y "$DATE" \ +--set-user-text-frame="REPLAYGAIN_REFERENCE_LOUDNESS:$RRL" \ +--set-user-text-frame="REPLAYGAIN_TRACK_GAIN:$RTG" \ +--set-user-text-frame="REPLAYGAIN_TRACK_PEAK:$RTP" \ +--set-user-text-frame="REPLAYGAIN_ALBUM_GAIN:$RAG" \ +--set-user-text-frame="REPLAYGAIN_ALBUM_PEAK:$RAP" \ +--no-tagging-time-frame \ +$OUTF > /dev/null 2>&1 fi -echo "$a -> $OUTF" +exit 0 diff --git a/mp3gainalbum.sh b/mp3gainalbum.sh deleted file mode 100755 index 1a63cf8..0000000 --- a/mp3gainalbum.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -pfad=$1 - -tmp="" - -suchverz() -{ - for i in $(find $pfad -name '*.mp3' | sort) - do - if [ ! "$tmp" == "${i%/*}" ] - then - tmp=${i%/*} - echo $tmp - fi - done -} - -suchverz | parallel mp3gain -o {}/*.mp3 -- 2.47.3