[ -f "$BASHLIBS/voribs.sh" ] \
|| errlog "library vorbis.sh not found" \
|| return $?
+ [ -f "$BASHLIBS/mp3.sh" ] \
+ || errlog "library mp3.sh not found" \
+ || return $?
source "$BASHLIBS/voribs.sh"
+ source "$BASHLIBS/mp3.sh"
}
-#### BEGIN MP3 ####
-
-read_flac_to_mp3_tags()
-{
- local inputfile="$1"
- local outputfile="$2"
- local inputfiledir=${inputfile%/*}
-
- # get the tags from flac file
- local readonly ARTIST=$(metaflac "$inputfile" \
- --show-tag=ARTIST | sed s/.*=//g)
- local readonly TITLE=$(metaflac "$inputfile" \
- --show-tag=TITLE | sed s/.*=//g)
- local readonly ALBUM=$(metaflac "$inputfile" \
- --show-tag=ALBUM | sed s/.*=//g)
- local readonly GENRE=$(metaflac "$inputfile" \
- --show-tag=GENRE | sed s/.*=//g)
- local readonly TRACKNUMBER=$(metaflac "$inputfile" \
- --show-tag=TRACKNUMBER | sed s/.*=//g)
- local readonly DATE=$(metaflac "$inputfile" \
- --show-tag=DATE | sed s/.*=//g)
- local readonly RRL=$(metaflac "$inputfile" \
- --show-tag=REPLAYGAIN_REFERENCE_LOUDNESS | tr '=' ':')
- local readonly RTG=$(metaflac "$inputfile" \
- --show-tag=REPLAYGAIN_TRACK_GAIN | tr '=' ':')
- local readonly RTP=$(metaflac "$inputfile" \
- --show-tag=REPLAYGAIN_TRACK_PEAK | tr '=' ':')
- local readonly RAG=$(metaflac "$inputfile" \
- --show-tag=REPLAYGAIN_ALBUM_GAIN | tr '=' ':')
- local readonly RAP=$(metaflac "$inputfile" \
- --show-tag=REPLAYGAIN_ALBUM_PEAK | tr '=' ':')
-
- # --------------------------------------------------
-
- # ID3v2.3 tagging with cover and without cover
- eyeD3 --v2 \
- --to-v2.3 \
- --artist="$ARTIST" \
- --title="$TITLE" \
- --album="$ALBUM" \
- --genre="${GENRE:-12}" \
- --track="${TRACKNUMBER:-0}" \
- --recording-date="$DATE" \
- --user-text-frame="$RRL" \
- --user-text-frame="$RTG" \
- --user-text-frame="$RTP" \
- --user-text-frame="$RAG" \
- --user-text-frame="$RAP" \
- --add-image="$inputfiledir/cover.jpg":FRONT_COVER \
- "$outputfile" > /dev/null 2>&1
-}
-
-encoding_flac_to_mp3()
-{
- local readonly inputfile="$1"
- local readonly outputfile="$2"
-
- nice --adjustment=10 flac --totally-silent --stdout --decode \
- "$inputfile" \
- | nice --adjustment=15 lame --silent \
- -b 192 \
- --noreplaygain \
- - "$outputfile"
-}
-
-flac_to_mp3()
-{
- local inputfile="$1"
- local outputfile="${inputfile/.flac/.mp3}"
-
- encoding_flac_to_mp3 "$inputfile" "$outputfile"
- read_flac_to_mp3_tags "$inputfile" "$outputfile"
-}
-
-convert_flac_to_mp3()
-{
- local workdir="$1"
-
- export -f flac_to_mp3
- export -f encoding_flac_to_mp3
- export -f read_flac_to_mp3_tags
- find $workdir -name '*.flac' \
- | sort \
- | parallel --will-cite \
- --ungroup \
- --eta \
- --progress \
- flac_to_mp3 {}
-}
-
-#### END MP3 ####
#### BEGIN OPUS ####
flac_to_opus()
--- /dev/null
+read_flac_to_mp3_tags()
+{
+ local inputfile="$1"
+ local outputfile="$2"
+ local inputfiledir=${inputfile%/*}
+
+ # get the tags from flac file
+ local readonly ARTIST=$(metaflac "$inputfile" \
+ --show-tag=ARTIST | sed s/.*=//g)
+ local readonly TITLE=$(metaflac "$inputfile" \
+ --show-tag=TITLE | sed s/.*=//g)
+ local readonly ALBUM=$(metaflac "$inputfile" \
+ --show-tag=ALBUM | sed s/.*=//g)
+ local readonly GENRE=$(metaflac "$inputfile" \
+ --show-tag=GENRE | sed s/.*=//g)
+ local readonly TRACKNUMBER=$(metaflac "$inputfile" \
+ --show-tag=TRACKNUMBER | sed s/.*=//g)
+ local readonly DATE=$(metaflac "$inputfile" \
+ --show-tag=DATE | sed s/.*=//g)
+ local readonly RRL=$(metaflac "$inputfile" \
+ --show-tag=REPLAYGAIN_REFERENCE_LOUDNESS | tr '=' ':')
+ local readonly RTG=$(metaflac "$inputfile" \
+ --show-tag=REPLAYGAIN_TRACK_GAIN | tr '=' ':')
+ local readonly RTP=$(metaflac "$inputfile" \
+ --show-tag=REPLAYGAIN_TRACK_PEAK | tr '=' ':')
+ local readonly RAG=$(metaflac "$inputfile" \
+ --show-tag=REPLAYGAIN_ALBUM_GAIN | tr '=' ':')
+ local readonly RAP=$(metaflac "$inputfile" \
+ --show-tag=REPLAYGAIN_ALBUM_PEAK | tr '=' ':')
+
+ # --------------------------------------------------
+
+ # ID3v2.3 tagging with cover and without cover
+ eyeD3 --v2 \
+ --to-v2.3 \
+ --artist="$ARTIST" \
+ --title="$TITLE" \
+ --album="$ALBUM" \
+ --genre="${GENRE:-12}" \
+ --track="${TRACKNUMBER:-0}" \
+ --recording-date="$DATE" \
+ --user-text-frame="$RRL" \
+ --user-text-frame="$RTG" \
+ --user-text-frame="$RTP" \
+ --user-text-frame="$RAG" \
+ --user-text-frame="$RAP" \
+ --add-image="$inputfiledir/cover.jpg":FRONT_COVER \
+ "$outputfile" > /dev/null 2>&1
+}
+
+encoding_flac_to_mp3()
+{
+ local readonly inputfile="$1"
+ local readonly outputfile="$2"
+
+ nice --adjustment=10 flac --totally-silent --stdout --decode \
+ "$inputfile" \
+ | nice --adjustment=15 lame --silent \
+ -b 192 \
+ --noreplaygain \
+ - "$outputfile"
+}
+
+flac_to_mp3()
+{
+ local inputfile="$1"
+ local outputfile="${inputfile/.flac/.mp3}"
+
+ encoding_flac_to_mp3 "$inputfile" "$outputfile"
+ read_flac_to_mp3_tags "$inputfile" "$outputfile"
+}
+
+convert_flac_to_mp3()
+{
+ local workdir="$1"
+
+ export -f flac_to_mp3
+ export -f encoding_flac_to_mp3
+ export -f read_flac_to_mp3_tags
+ find $workdir -name '*.flac' \
+ | sort \
+ | parallel --will-cite \
+ --ungroup \
+ --eta \
+ --progress \
+ flac_to_mp3 {}
+}