read_flac_to_ogg_tags()
{
- local inputfile="$1"
- local outputfile="$2"
- local coverfile="${inputfile%/*}/cover.txt"
+ local input="$1"
+ local output="$2"
+ local coverfile="${input%/*}/cover.txt"
- metaflac --export-tags-to=- "$inputfile" \
- | vorbiscomment --commentfile - --write "$outputfile"
+ metaflac --export-tags-to=- "$input" \
+ | vorbiscomment --commentfile - --write "$output"
- [ -f "$coverfile" ] \
- || return 0
+ [ -f "$coverfile" ] || return 0
echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 "$coverfile")" \
- | vorbiscomment --commentfile - --raw --append "$outputfile"
+ | vorbiscomment --commentfile - --raw --append "$output"
}
encoding_flac_to_ogg()
{
- local inputfile="$1"
- local outputfile="$2"
-
+ local input="$1"
+ local output="$2"
nice --adjustment=10 flac --totally-silent --stdout --decode \
- "$inputfile" \
+ "$input" \
| nice --adjustment=15 oggenc --quiet --quality 6 \
- --output "$outputfile" -
+ --output "$output" -
}
flac_to_vorbis()
{
- local inputfile="$1"
- local outputfile="${inputfile/.flac/.ogg}"
-
- encoding_flac_to_ogg "$inputfile" "$outputfile"
- read_flac_to_ogg_tags "$inputfile" "$outputfile"
+ local input="$1"
+ local output="${input/.flac/.ogg}"
+ encoding_flac_to_ogg "$input" "$output"
+ read_flac_to_ogg_tags "$input" "$output"
}
write_hex_to_file()
{
local number="$1"
- local outputfile="$2"
+ local output="$2"
local hex_number=
hex_number=$(printf "%08x" "$number")
for i in {0..6..2}; do
- printf "%b" "\x${hex_number:$i:2}" >> "$outputfile"
+ printf "%b" "\x${hex_number:$i:2}" >> "$output"
done
}
cover_to_metadata()
{
- local inputfile="$1"
- local outputfile="${inputfile/.jpg/.txt}"
+ local input="$1"
+ local output="${input/.jpg/.txt}"
local filesize=
- filesize=$(wc --bytes "$inputfile")
+ filesize=$(wc --bytes "$input")
filesize=${filesize/ */}
# picture typ (jpg)
- write_hex_to_file "3" "$outputfile"
+ write_hex_to_file "3" "$output"
# mime type (image/jpeg)
- write_hex_to_file "10" "$outputfile"
- printf "%s" "image/jpeg" >> "$outputfile"
+ write_hex_to_file "10" "$output"
+ printf "%s" "image/jpeg" >> "$output"
# description length (zero)
- write_hex_to_file "0" "$outputfile"
+ write_hex_to_file "0" "$output"
# width (zero)
- write_hex_to_file "0" "$outputfile"
+ write_hex_to_file "0" "$output"
# heigth (zero)
- write_hex_to_file "0" "$outputfile"
+ write_hex_to_file "0" "$output"
# color depth (zero)
- write_hex_to_file "0" "$outputfile"
+ write_hex_to_file "0" "$output"
# color count (zero)
- write_hex_to_file "0" "$outputfile"
+ write_hex_to_file "0" "$output"
# file size
- write_hex_to_file "$filesize" "$outputfile"
- cat "$inputfile" >> "$outputfile"
+ write_hex_to_file "$filesize" "$output"
+ cat "$input" >> "$output"
}
convert_flac_to_ogg()
{
local workdir="$1"
-
find "$workdir" -name '*.jpg' \
| sort \
| parallel --will-cite --ungroup \
execute()
{
local workdir="$1"
-
convert_flac_to_ogg "$workdir" || return $?
}