[ale] CD -> MP3
Phil Turmel
philip at turmel.org
Wed Aug 5 11:03:04 EDT 2015
+1 for Flac. And as noted by others, you really need to keep the CDs.
I put mine on the spindles that blank media were on.
I keep a substantial collection of Flac on my home media server and
maintain a parallel folder of MP3s with the attached script. I have a
lot of international music and the script does a decent job with the
character set handling.
When I want to shuffle the content of my portable devices, the MP3s are
close at hand. Everything in the house plays the Flac files.
On 08/04/2015 05:31 PM, DJ-Pfulio wrote:
> Flac. No question. Flac. It is just storage. Anything less is lossy.
>
> On 08/04/2015 05:23 PM, Chris Fowler wrote:
>> These are ideas. I could recycle the cases and just store the CDs in
>> sleeves. That would cut down on space usage. What is the best format
>> for export? Ogg or MP3? What rate would be the best rate without
>> eating up tons of space?
-------------- next part --------------
#! /bin/bash
#
# Flac to MP3 conversion tool w/ companding
if test -z "$2" ; then
echo "Usage:"
echo " $(basename "$0") inputdir outputdir"
echo "The input directory given is recursive scanned for .flac files and"
echo "auxiliary files (album art, whatever). The output directory is filled"
echo "with .mp3 conversions of the FLAC files and copies of the auxiliary"
echo "files. Any MP3 files encountered in the input directory are"
echo "skipped."
exit 1
fi
export SCRIPT="$(readlink -f "$0")"
export ORIGIN="$(readlink -f "$1")"
export DEST="$(readlink -f "$2")"
export TAGS="$(mktemp --tmpdir tags-XXXXXXXX.txt)"
if test \( ! -d "$ORIGIN" \) -a \( ! -d "$DEST" \) ; then
echo "Usage:"
echo " $(basename "$0") inputdir outputdir"
echo "Error! The parameters must be directories."
exit 1
fi
function cond_convert () {
if [[ "$1" =~ ^.+(\.mp3)$ ]] ; then
FFILE="${1%%.mp3}.flac"
if test ! -e "$FFILE" ; then
printf "Copying: %s\n To: %s\n" "$1" "$2"
cp --preserve=timestamps "$1" "$2"
fi
return
fi
if [[ "$1" =~ ^(.+)(\.flac)$ ]] ; then
printf "Converting: %s\n To: %s\n" "$1" "$2"
metaflac --export-tags-to=- "$1" |iconv -c -f utf-8 -t 8859_1 >"${TAGS}"
# Custom normalization.
# 0.3 second Predictive companding w/ 1.0 second attack &
# 1.0 second decay. Soft (-65dB to -43dB) is boosted 20dB.
# Medium to Loud (-43dB to -3dB) is companded 2:1. Very
# Loud (> -3dB) is unchanged.
sox --buffer 65536 "$1" -C 256.2 \
--comment-file="${TAGS}" \
"$2" \
compand 1.0,2.0 6:-70,-65,-45,-43,-23,-3,-3 -10 -70 1.0 gain -n
touch -c -r "$1" "$2"
else
printf "Copying: %s\n To: %s\n" "$1" "$2"
cp --preserve=timestamps "$1" "$2"
fi
}
function process_changes () {
while read file ; do
DFILE="${DEST}${file##$ORIGIN}"
[[ "$DFILE" =~ ^(.+)(\.flac)$ ]] && DFILE="${BASH_REMATCH[1]}.mp3"
if test -d "$file" ; then
mkdir -p "$DFILE"
else
if test -f "$file" ; then
if test -f "$DFILE" ; then
OTIME=$(stat -c %Y "$file")
DTIME=$(stat -c %Y "$DFILE")
if test $OTIME -ne $DTIME ; then
cond_convert "$file" "$DFILE"
fi
else
cond_convert "$file" "$DFILE"
fi
else
if test -d "$DFILE" ; then
rm -rf "$DFILE"
else
if test -f "$DFILE" ; then
rm -f "$DFILE"
fi
fi
fi
fi
done
}
function process_deletes () {
while read file ; do
SFILE="${ORIGIN}${file##$DEST}"
if test ! -e "$SFILE" ; then
if [[ "$SFILE" =~ ^(.+)(\.mp3)$ ]] ; then
SFILE="${BASH_REMATCH[1]}.flac"
if test ! -e "$SFILE" ; then
echo "Discarding: $file"
rm -f "$file" &>/dev/null
fi
else
echo "Deleting: $file"
rm -rf "$file" &>/dev/null
fi
fi
done
}
find "$DEST" |process_deletes
find "$ORIGIN" |sort -V |process_changes
More information about the Ale
mailing list