]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add encode vorbis
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 17:40:28 +0000 (19:40 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 17:44:18 +0000 (19:44 +0200)
src/lib/vorbis.sh

index 4a99d5dfb51f351a4eda92f42cb9f5deebe58b31..99446a867eb6e5cce5527b8373e3d8f775a1f7aa 100644 (file)
@@ -68,6 +68,38 @@ vorbis_cover_to_metadata()
        } > "$covermetadata"
 }
 
+vorbis_encode_flac()
+{
+       local flac="$1"
+       local ogg=${flac/.flac/.ogg}
+       local path="${flac%/*}"
+       local covermetadata="$path/cover.txt"
+       QUALITY=${QUALITY:-"6"}
+
+       nice --adjustment=10 flac \
+               --totally-silent \
+               --stdout \
+               --decode \
+               "$flac" \
+               | nice --adjustment=15 oggenc \
+               --quiet \
+               --serial 1 \
+               --quality "$QUALITY" \
+               --output "$ogg" -
+       metaflac --export-tags-to=- \
+               "$flac" \
+               | vorbiscomment \
+               --commentfile - \
+               --write \
+               "$ogg"
+       echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 "$covermetadata")" \
+               | vorbiscomment \
+               --commentfile - \
+               --raw \
+               --append \
+               "$ogg"
+}
+
 vorbis_encode()
 {
        local work_path="$1"
@@ -75,6 +107,13 @@ vorbis_encode()
                | sort \
                | parallel --will-cite --ungroup \
                vorbis_cover_to_metadata {}
+       find "$work_path" -name '*.flac' \
+               | sort \
+               | parallel --will-cite --ungroup --eta --progress \
+               vorbis_encode_flac "{}"
 }
 
-vorbis_check_programs || return $?
\ No newline at end of file
+vorbis_check_programs || return $?
+export -f vorbis_write_number_to_byte
+export -f vorbis_cover_to_metadata
+export -f vorbis_encode_flac
\ No newline at end of file