I'm in a bind repairing some archived music.
BACKGROUND
My CDRs deteriorated over time and I no longer have a turntable to rip my
vinyl again. I've found most of the corrupted albums in a FLAC format, so as
to avoid lossy -> lossy conversion. The problems are 1) I don't have the room
to store FLAC, and 2) I would like to normalize the per-track volume.
(Depeche Mode, for instance, is notoriously loud in their recordings, whereas
Dire Straits record too quietly. Sadly, ogg doesn't support a normalization
setting in the files for playback, and it seems very spotty whether a
particular playback device/program supports normalization even on mp3s.)
ATTEMPTS SO FAR:
I've used soundKonvert in KDE often enough to change formats, but I don't know
a way to get soundKonvert or any batch audio tools to normalize the resulting
wav file before oggenc takes over.
A decade ago, when converting batches of 320kbps mp3s, I found a lovely script
that was easy to add normailze-audio into. Trying to adapt it for FLAC works
well EXCEPT that every single track number 08 or 09 loses the track number
information of the tag! Artist, title, album, year, and genre all convert over
beautifully. But tracks 08 and 09 have to be re-tagged from 00. (At least the
error is consistant.)
WHAT I'M WANTING:
If any script-geniuses can point out my error in the attached script, I would
be awfully grateful.
If someone out there knows another tool that can be modified to normalize the
WAV file before oggenc, or a way to do so in soundKonvert, that would be
equally appreciated.
Thanks for taking the time to read and hopefully respond!
<code>
#/bin/bash
#
# omftoc - one more FLAC to OGG converter
# based on ommtoc by Todd Slater
#
# revised Apr 2013
#
# requires metaflac, oggenc(vorbis-tools) normalize-audio
#
# If the flac has ID3 info, ommtoc renames ogg files to format:
# track# - title - album - artist.ogg
# You can change the renaming format in line 80
# (look for -n "$workingPath/$prettyTrack - %t - %l - %a.ogg")
# ^^ ^^ ^^ ^^
# Options:
# -d <directory>: search <directory> for mp3's to convert to ogg;
# if none specified, defaults to current directory
# SEARCH IS RECURSIVE!!
# -k : keep mp3s after conversion--by default they are deleted
# -q n : quality for oggenc--default is 3, can be between 1 and 10
# -w : keep wavs after conversion--by default they are deleted
#
# not extensively tested!!
#
quality=7
keepWav=false
keepFlac=false
while getopts d:kq:w OPTION ;
do
case "$OPTION" in
d) searchPath="$OPTARG" ;;
k) keepFlac="true" ;;
q) quality="$OPTARG" ;;
w) keepWav="true" ;;
?) echo "Invalid option"; exit 1 ;;
esac
done
if [ $searchPath ] ; then
if [ ! -d $searchPath ] ; then
echo "Error: Directory does not exist"
exit 1
fi
else
searchPath=`pwd`
fi
# find all flac's
find "$searchPath" -type f -iname '*.flac' > flaclist
while read flac
do
workingPath=`dirname "$flac"`
wavName=`basename "$flac"|sed s/\.[fF][lL][aA][cC]/\.wav/`
echo "Basename= "$basename "workingPath= " $workingPath
testID3=`metaflac "$flac" --show-tag=ARTIST | sed s/.*=//g`
if [ -z "$testID3" ] ; then
noID3Name=`basename "$flac"|sed s/\.[fF][lL][aA][cC]/\.ogg/`
echo "Converting '$flac' to wav..."
flac --decode "$flac" >/dev/null 2>&1
echo "Normalizing "$wavName
normalize-audio "$workingPath/$wavName"
echo "Encoding "$wavName" to ogg..."
oggenc -q $quality -o "$workingPath/$noID3Name" "$workingPath/$wavName"
if [ $keepFlac = "false" ] ; then
rm -f "$flac"
fi
if [ $keepWav = "false" ] ; then
rm -f "$workingPath/$wavName"
fi
else
album=`metaflac "$flac" --show-tag=ALBUM | sed s/.*=//g`
artist=`metaflac "$flac" --show-tag=ARTIST | sed s/.*=//g`
genre=`metaflac "$flac" --show-tag=GENRE | sed s/.*=//g`
title=`metaflac "$flac" --show-tag=TITLE | sed s/.*=//g`
track=`metaflac "$flac" --show-tag=TRACKNUMBER | sed s/.*=//g`
prettyTrack=`printf "%02d" $track`
year=`metaflac "$flac" --show-tag=DATE | sed s/.*=//g`
echo "Converting "$flac" to wav..."
flac --decode "$flac" >/dev/null 2>&1
echo "Normalizing "$wavName
normalize-audio "$workingPath/$wavName"
echo "Encoding "$wavName" to ogg..."
oggenc -q $quality -a "$artist" -N "$prettyTrack" -l "$album" -t
"$title" -G "$genre" -d "$year" -n "$workingPath/%n - %t.ogg"
"$workingPath/$wavName"
if [ $keepFlac = "false" ] ; then
rm -f "$flac"
fi
if [ $keepWav = "false" ] ; then
rm -f "$workingPath/$wavName"
fi
track=''
prettyTrack=''
fi
done < flaclist
rm flaclist
echo Done!
</code>
--
Mike F.--------------------
BYU Unix Users Group
http://uug.byu.edu/
The opinions expressed in this message are the responsibility of their
author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
___________________________________________________________________
List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list