]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
change flac to ogg convert
authorBastian Dehn <hhaalo@arcor.de>
Sun, 13 Jul 2025 19:15:51 +0000 (21:15 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 13 Jul 2025 19:15:51 +0000 (21:15 +0200)
albentohandy

index 699eadce273070f0e807c352b497399c54096649..48c5ea43c9cc97196246983a527afc3a441ffae9 100755 (executable)
@@ -205,95 +205,97 @@ PictureToFlac()
 #### END FLAC REENCODE ####
 #### BEGIN VORBIS ####
 
-ReadFlacToOggTags()
+read_flac_to_ogg_tags()
 {
-       local readonly INPUTFILE="$1"
-       local readonly OUTPUFILE="$2"
-       local readonly COVERFILE="${INPUTFILE%/*}/cover.txt"
+       local inputfile="$1"
+       local outputfile="$2"
+       local coverfile="${inputfile%/*}/cover.txt"
 
        if [ -z "$replaygainapply" ]; then
-               metaflac --export-tags-to=- $INPUTFILE \
-                       | vorbiscomment --commentfile - --write $OUTPUTFILE
+               metaflac --export-tags-to=- $inputfile \
+                       | vorbiscomment --commentfile - --write $outputfile
        else
-               metaflac --export-tags-to=- $INPUTFILE \
+               metaflac --export-tags-to=- $inputfile \
                        | sed '/REPLAYGAIN/d' \
-                       | vorbiscomment --commentfile - --write $OUTPUTFILE
+                       | vorbiscomment --commentfile - --write $outputfile
        fi
 
-       if [ -f $COVERFILE ]; then
-               echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 $COVERFILE)" \
-               | vorbiscomment --commentfile - --raw --append $OUTPUTFILE
+       if [ -f $coverfile ]; then
+               echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 $coverfile)" \
+               | vorbiscomment --commentfile - --raw --append $outputfile
        fi
 }
 
-EncodingFlacToOgg()
+encoding_flac_to_ogg()
 {
-       local readonly INPUTFILE="$1"
-       local readonly OUTPUTFILE="$2"
+       local inputfile="$1"
+       local outputfile="$2"
 
        nice --adjustment=10 flac --totally-silent --stdout --decode \
-               $replaygainapply "$INPUTFILE" \
+               $replaygainapply "$inputfile" \
                | nice --adjustment=15 oggenc --quiet --quality 6 \
-               --output "$OUTPUTFILE" -
+               --output "$outputfile" -
 }
 
-FlacToVorbis()
+flac_to_vorbis()
 {
-       local readonly INPUTFILE="$1"
-       local readonly OUTPUTFILE="${INPUTFILE[@]/%flac/ogg}"
+       local inputfile="$1"
+       local outputfile="${inputfile/.flac/.ogg}"
 
-       EncodingFlacToOgg "$INPUTFILE" "$OUTPUTFILE"
-       ReadFlacToOggTags "$INPUTFILE" "$OUTPUTFILE"
+       encoding_flac_to_ogg "$inputfile" "$outputfile"
+       read_flac_to_ogg_tags "$inputfile" "$outputfile"
 }
 
-ConvertFlacToOgg()
+convert_flac_to_ogg()
 {
-       local readonly WORKDIR="$1"
+       local workdir="$1"
 
-       declare -xf FlacToVorbis
-       declare -xf ReadFlacToOggTags
-       declare -xf EncodingFlacToOgg
-       find $WORKDIR -name '*.flac' \
+       export -f flac_to_vorbis
+       export -f encoding_flac_to_ogg
+       export -f read_flac_to_ogg_tags
+       find $workdir -name '*.flac' \
                | sort \
                | parallel --will-cite --ungroup --eta --progress \
-               FlacToVorbis {}
-}
-
-ConvertCoverToMeta()
-{
-       local readonly WORKDIR="$1"
-
-       for i in $(find $WORKDIR -name '*.jpg' | sort); do
-               CoverToMeta $i
-       done
+               flac_to_vorbis "{}"
 }
 
-CoverToMeta()
+cover_to_metadata()
 {
-       local readonly INPUTFILE="$1"
-       local readonly OUTPUTFILE="${INPUTFILE/%.jpg/.txt}"
+       local inputfile="$1"
+       local outputfile="${inputfile/.jpg/.txt}"
 
        # Picture Typ
-       printf "0: %.8x" 3 | xxd -r -g0 > $OUTPUTFILE
+       printf "0: %.8x" 3 | xxd -r -g0 > $outputfile
        # Mime type
        printf "0: %.8x" $(printf "image/jpeg" | wc -c) \
-               | xxd -r -g0 >> $OUTPUTFILE
-       printf "image/jpeg" >> $OUTPUTFILE
+               | xxd -r -g0 >> $outputfile
+       printf "image/jpeg" >> $outputfile
        # Description
-       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       printf "0: %.8x" 0 | xxd -r -g0 >> $outputfile
        # Width
-       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       printf "0: %.8x" 0 | xxd -r -g0 >> $outputfile
        # Heigth
-       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       printf "0: %.8x" 0 | xxd -r -g0 >> $outputfile
        # Color depth
-       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       printf "0: %.8x" 0 | xxd -r -g0 >> $outputfile
        # Color Count
-       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       printf "0: %.8x" 0 | xxd -r -g0 >> $outputfile
        # File Size
-       printf "0: %.8x" $(wc -c "$INPUTFILE" \
+       printf "0: %.8x" $(wc -c "$inputfile" \
                | cut --delimiter=' ' --fields=1) \
-               | xxd -r -g0 >> $OUTPUTFILE
-       cat $INPUTFILE >> $OUTPUTFILE
+               | xxd -r -g0 >> $outputfile
+       cat $inputfile >> $outputfile
+}
+
+convert_cover_to_metadata()
+{
+       local workdir="$1"
+       local covers=$(find $workdir -name '*.jpg' | sort)
+
+       local cover=
+       for cover in $covers; do
+               cover_to_metadata "$cover"
+       done
 }
 
 #### END VORBIS ####
@@ -424,6 +426,16 @@ convert_process()
        make_symlinks_to_work "albumlist" "$workdir" $MUSICPATH \
                || return $?
 
+       case "$format" in
+       "mp3") ;;
+       "flac") ;;
+       "opus") ;;
+       *)
+               convert_cover_to_metadata "$workdir"
+               convert_flac_to_ogg "$workdir"
+               ;;
+       esac
+
        # WIP
        return