I discovered that sometimes my cdrom drive gets confused and all my rips are all zeros. When this happens the average bitrate of my encodes falls to the minimum bitrate. To detect this problem I wrote a script that uses checkmp3:
#! /usr/bin/python
import os, sys, traceback
def get_checkmp3_info(path):
f = os.popen("checkmp3 %s" % path)
ret = {}
while True:
s = f.readline()
if len(s) == 0:
break
dat = s.strip().split()
if len(dat):
ret[dat[0]] = dat[1]
return ret
def check_dir_for_nulls(path, check_all):
for root, dirs, files in os.walk(path):
for name in files:
try:
if name.endswith('.mp3'):
mp3info = get_checkmp3_info(os.path.join(root, name))
vbravg = int(mp3info.get('VBR_AVERAGE', 0))
if vbravg < 33:
print name, vbravg
if not check_all:
break
except:
print >>sys.stderr,"error processing %s" % os.path.join(root,name)
traceback.print_exc(file=sys.stderr)
if __name__ == "__main__":
check_all = True
check_dir_for_nulls(sys.argv[1], check_all)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I discovered that sometimes my cdrom drive gets confused and all my rips are all zeros. When this happens the average bitrate of my encodes falls to the minimum bitrate. To detect this problem I wrote a script that uses checkmp3:
#! /usr/bin/python
import os, sys, traceback
def get_checkmp3_info(path):
f = os.popen("checkmp3 %s" % path)
ret = {}
while True:
s = f.readline()
if len(s) == 0:
break
dat = s.strip().split()
if len(dat):
ret[dat[0]] = dat[1]
return ret
def check_dir_for_nulls(path, check_all):
for root, dirs, files in os.walk(path):
for name in files:
try:
if name.endswith('.mp3'):
mp3info = get_checkmp3_info(os.path.join(root, name))
vbravg = int(mp3info.get('VBR_AVERAGE', 0))
if vbravg < 33:
print name, vbravg
if not check_all:
break
except:
print >>sys.stderr,"error processing %s" % os.path.join(root,name)
traceback.print_exc(file=sys.stderr)
if __name__ == "__main__":
check_all = True
check_dir_for_nulls(sys.argv[1], check_all)
Damn. Well, you can probably imagine how that would look if it was properly indented :-). SF forums apparently suck fo r posting code.