From: Bastian Dehn Date: Sat, 5 Dec 2020 13:21:28 +0000 (+0100) Subject: add: embedded front cover in ogg file X-Git-Tag: v1.0.0^2~72 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=3a21d3b26cbe11bb10eaf2bc2cf0a274b3aea5ad;p=albentohandy.git add: embedded front cover in ogg file add: metadata_block_picture Spezifikation: https://xiph.org/flac/format.html#metadata_block_picture --- diff --git a/albentohandy b/albentohandy index f44031f..379a9a7 100755 --- a/albentohandy +++ b/albentohandy @@ -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 index 0000000..1f374e4 --- /dev/null +++ b/covertometa @@ -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 diff --git a/flactovorbis b/flactovorbis index ac6b374..aa34de6 100755 --- a/flactovorbis +++ b/flactovorbis @@ -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()