3 #=======================================================================
5 # File ID: dde2fab8-3dfd-11e0-9b12-1b57187fd9d3
7 # Convert .wav files to .flac and keep metadata
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
27 " -n "$progname" -- "$@
")"
28 test "$?" = "0" ||
exit 1
36 -h|
--help) opt_help
=1; shift ;;
37 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
38 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
39 --version) echo $progname $VERSION; exit 0 ;;
41 *) echo $progname: Internal error
>&2; exit 1 ;;
44 opt_verbose
=$
(($opt_verbose - $opt_quiet))
46 if test "$opt_help" = "1"; then
47 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
50 Convert .wav files to .flac and keep all metadata + verify that the file
51 uncompresses to an identical .wav file. If the tiniest difference is
52 found, the file is skipped and an error message is written to
55 Usage: $progname [options] wav_file [...]
62 Be more quiet. Can be repeated to increase silence.
64 Increase level of verbosity. Can be repeated.
66 Print version information.
73 echo $progname: No files specified
>&2
77 tmpuuid
=$
(suuid
-m -t c_konvflac
-wa -c "Starting conversion")
78 test -z "$tmpuuid" && { echo "konvflac: Broken suuid(1)" >&2; exit 1; }
79 chkfile
="/tmp/konvflac.$tmpuuid.tmp"
82 echo ======== $
(ls -l "$curr")
84 noext
="$(basename "$curr" .wav)"
86 flacfile
="$noext.flac"
87 test -e "$flacfile" && {
88 echo $flacfile: File already exists
>&2
91 wavsha
=$
(sha1sum "$wavfile" | cut
-f1 -d ' ')
92 wavid
=$
(finduuid
"$wavfile")
94 test -n "$wavid" && wavid_str
=" (File ID $wavid)"
96 $CMD_FLAC -T FILEID
=$
(
97 suuid
-m -t encode
,c_konvflac
-wa \
98 -c "Converting $wavfile$wavid_str to flac"
99 ) --keep-foreign-metadata "$wavfile" 2>&1 |
101 -e "keep-foreign-metadata is a new feature" \
102 -e "2000,2001,2002,2003,2004,2005,2006,2007" \
103 -e "2000-2009, 2011-2013" \
104 -e "flac comes with ABSOLUTELY NO WARRANTY" \
105 -e "welcome to redistribute it under certain conditions" \
107 $CMD_FLAC -d -o "$chkfile" --keep-foreign-metadata "$flacfile" 2>&1 |
109 -e "keep-foreign-metadata is a new feature" \
110 -e "2000,2001,2002,2003,2004,2005,2006,2007" \
111 -e "2000-2009, 2011-2013" \
112 -e "flac comes with ABSOLUTELY NO WARRANTY" \
113 -e "welcome to redistribute it under certain conditions" \
115 flacsha
=$
(sha1sum "$chkfile" | cut
-f 1 -d ' ')
116 if test "$wavsha" = "$flacsha"; then
120 echo ==== ENCODING ERROR
====
121 echo "$noext" >>konvflac-error.txt