]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add: embedded front cover in ogg file
authorBastian Dehn <hhaalo@arcor.de>
Sat, 5 Dec 2020 13:21:28 +0000 (14:21 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 5 Dec 2020 13:21:28 +0000 (14:21 +0100)
add: metadata_block_picture

Spezifikation:
https://xiph.org/flac/format.html#metadata_block_picture

albentohandy
covertometa [new file with mode: 0755]
flactovorbis

index f44031ffe850978e661ba906efd517b39d53257f..379a9a7eff3010abf1ef6bd9a918c9d6846a59bf 100755 (executable)
@@ -58,6 +58,18 @@ ConvertFlacToOgg()
                --sshlogin $parallelopts $scriptdir/flactovorbis {}
 }
 
+ConvertCoverToMeta()
+{
+       local readonly workdir="$1"
+       local readonly parallelopts="$2"
+       local readonly scriptdir="$3"
+
+       find $workdir -name '*.jpg' \
+               | sort \
+               | parallel --will-cite --ungroup \
+               --sshlogin $parallelopts $scriptdir/covertometa {}
+}
+
 CleanupFlac()
 {
        local readonly workdir="$1"
@@ -65,6 +77,13 @@ CleanupFlac()
        find $workdir -name '*.flac' -exec rm {} \;
 }
 
+CleanupCover()
+{
+       local readonly wordir="$1"
+
+       find $workdir -name 'cover.txt' -exec rm {} \;
+}
+
 CleanupWorkDir()
 {
        local readonly workdir="$1"
@@ -220,11 +239,13 @@ ConvertProcess()
        MakeSymlinksToWork "$WORK" "$MUSICPATH" "$albumlist"
 
        printf "\nPhase %02d of %02d: flac -> ogg\n" $((curphase++)) $phase
+       ConvertCoverToMeta "$WORK" "$parallelopts" "$SCRIPTPATH"
        ConvertFlacToOgg "$WORK" "$parallelopts" "$SCRIPTPATH"
 
        printf "\nPhase %02d of %02d: " $((curphase++)) $phase
        printf "remove flac's\n\n"
        CleanupFlac "$WORK"
+       CleanupCover "$WORK"
 }
 
 AdvancedFeatures()
diff --git a/covertometa b/covertometa
new file mode 100755 (executable)
index 0000000..1f374e4
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+main()
+{
+       local readonly INPUTFILE="$1"
+       local readonly OUTPUTFILE="${INPUTFILE/%.jpg/.txt}"
+
+       # Picture Typ
+       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
+       # Description
+       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       # Width
+       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       # Heigth
+       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       # Color depth
+       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       # Color Count
+       printf "0: %.8x" 0 | xxd -r -g0 >> $OUTPUTFILE
+       # File Size
+       printf "0: %.8x" $(wc -c "$INPUTFILE" \
+               | cut --delimiter=' ' --fields=1) \
+               | xxd -r -g0 >> $OUTPUTFILE
+       cat $INPUTFILE >> $OUTPUTFILE
+}
+
+main $*
+exit 0
index ac6b374429f1dc3686ab27ef835d115a8f8b8694..aa34de6d782d259ae3cdb7087a55d3c73799f5d2 100755 (executable)
@@ -4,9 +4,14 @@ ReadFlacToOggTags()
 {
        local readonly INPUTFILE="$1"
        local readonly OUTPUFILE="$2"
+       local readonly COVERFILE="${INPUTFILE%/*}/cover.txt"
 
        metaflac --export-tags-to=- $INPUTFILE \
                | vorbiscomment --commentfile - --write $OUTPUTFILE
+       if [ -f $COVERFILE ]; then
+               echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 $COVERFILE)" \
+               | vorbiscomment --commentfile - --raw --append $OUTPUTFILE
+       fi
 }
 
 EncodingFlacToOgg()