From 0cdc6434b653049dc1763231f83c680a537d1ccb Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Wed, 23 Dec 2020 20:51:26 +0100 Subject: [PATCH] add: convert flac to opus option --- albentohandy | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/albentohandy b/albentohandy index 62c49ec..a3ec20d 100755 --- a/albentohandy +++ b/albentohandy @@ -9,7 +9,7 @@ NAME SYNOPSIS albentohandy [-3] [-c] [-f] [-h] [-i ] [-m ] [-r] - [-w ] + [-o] [-w ] OPTIONS -3 convert to mp3 @@ -19,6 +19,7 @@ OPTIONS -i input Datei default=albumlist -m kopiert das Arbeitsverzeichnis in das angegeben Zielverzeichnis + -o convert to opus -r löscht das Arbeitsverzeichnis wenn -m angegeben ist -w das Arbeitsverzeichnis angegeben @@ -116,6 +117,26 @@ ConvertFlacToMp3() | parallel --will-cite --ungroup --eta --progress FlacToMp3 {} } +FlacToOpus() +{ + local readonly INPUTFILE="$1" + local readonly OUTPUTFILE="${INPUTFILE[@]/%flac/opus}" + local readonly COVERFILE="${INPUTFILE%/*}/cover.jpg" + + opusenc --picture "3|image/jpeg|||$COVERFILE" --quiet \ + --bitrate 192 "$INPUTFILE" "$OUTPUTFILE" +} + +ConvertFlacToOpus() +{ + local readonly WORKDIR="$1" + + export -f FlacToOpus + find $WORKDIR -name *.flac \ + | sort \ + | parallel --will-cite --ungroup --eta --progress FlacToOpus {} +} + PictureToFlac() { local readonly WORKDIR="$1" @@ -274,7 +295,7 @@ ExistsBasicProgramms() local exists=true local programm="" local readonly PROGRAMMS=("vorbiscomment" "flac" "oggenc" "parallel" \ - "lame" "eyeD3" "metaflac") + "lame" "eyeD3" "metaflac" "opusenc") for programm in $PROGRAMMS; do if [ ! -f /usr/bin/$programm ]; then @@ -295,6 +316,7 @@ SetDefaultVariables() phase=3 flac=false mp3=false + opus=false cover=false removework=false cptodest=false @@ -302,18 +324,20 @@ SetDefaultVariables() ReadArguments() { - while getopts "3cfhi:m:rw:" optname; do + while getopts "3cfhi:m:orw:" optname; do case "$optname" in "3") - mp3=true; - flac=false; + mp3=true + flac=false + opus=false ;; "c") - cover=true; + cover=true ;; "f") - mp3=false; - flac=true; + mp3=false + flac=true + opus=false ;; "h") Usage @@ -327,6 +351,11 @@ ReadArguments() dest="$OPTARG" ((phase++)) ;; + "o") + opus=true + mp3=false + flac=false + ;; "r") removework=true ;; @@ -370,6 +399,10 @@ ConvertProcess() printf "\nPhase %02d of %02d: flac -> flac with cover\n" \ $((curphase++)) $phase PictureToFlac "$WORK" + elif [ $opus == true ]; then + printf "\nPhase %02d of %02d: flac -> opus\n" \ + $((curphase++)) $phase + ConvertFlacToOpus "$WORK" else printf "\nPhase %02d of %02d: flac -> ogg\n" \ $((curphase++)) $phase -- 2.47.3