normailzer optimiert

This commit is contained in:
age 2005-08-09 11:24:00 +00:00
parent b3128c6aba
commit 1ccc4837ed
1 changed files with 45 additions and 15 deletions

View File

@ -5,24 +5,39 @@
## - provides normalized wavefiles using transcode
## - burns an audio-cd
# !!feel free to copy, modify, redistribute and at most _use_ it!!
# comments to: age-at-systemausfall-dot-org 02004
# AGE/02004
import os
import os,sys
import string
m3ufile = "foo.m3u"
wavdir = "/mnt/ionos/mugge/aufnahme/ready"
recorder = "ATAPI:0,0,0" #fuer cdrecord mit 2.6 kernel und ide brenner
#recorder = "ATAPI:0,0,0" #fuer cdrecord mit 2.6 kernel und ide brenner
recorder = "0,0,0" #fuer cdrecord mit 2.6 kernel und ide brenner
__doc__ = """usage: %s file.m3u wav-destination""" % sys.argv[0]
################
### init checks
try:
m3ufile = sys.argv[1]
wavdir = sys.argv[2]
if not os.access(wavdir,os.W_OK) :
print "%s not writeable" % wavdir
sys.exit(3)
except:
print >>sys.stderr, __doc__
sys.exit(1)
print "\nDirty, lame hack in action:\n"
################
### read m3u
### m3u einlesen
try:
temp = open(m3ufile,"r")
m3u = temp.read()
temp.close()
except:
print "I can't find the .m3u file"
sys.exit(2)
# M's Kommentar Schnibbler
notfound = 0
while notfound == 0:
@ -39,21 +54,35 @@ for i in valuepairs:
if i != "":
m3u.append(i)
# im m3u-array stehen jetzt hoffentlich ;) nur noch pfadangaben
# checken ob's stimmt
# checken ob's stimmt & und ob alle files existieren
abort = 0
for i in m3u:
if not os.path.exists(i):
print "===> %s not found!" % i
print "I'll ignore it."
abort = abort + 1
print "===> not found: %s " % i
m3u.remove(i)
print "\nI found %i audiofiles to convert, normalize and burn:" % len(m3u)
if abort > 0:
print "\nI can't find %i audiofiles - giving up" % abort
#TODO
# abfrage ob ohne die files mit gekuertzter m3u weiter gemacht werden
# soll..
sys.exit(0)
else:
print "\nI found %i audiofiles to convert, normalize and burn:" % len(m3u)
##############
### ogg -> wav
### ogg/mp3 -> wav
count = 0
for file in m3u:
count+=1
#TODO: count braucht fuehrende nullen, damit die reihenfolge auf der cd stimmt!!
command = "mplayer \""+file+"\" -ao pcm -aofile "+wavdir+"/"+str(count)+".wav &> /dev/null"
# fuehrende nullen ranballern
#if count < 10:
#count0 = "0"+str(count)
#else:
#count0 = str(count)
count0 = "%.3i" % count
command = "mplayer \""+file+"\" -vc dummy -vo null -ao pcm -aofile "+wavdir+"/"+str(count0)+".wav &> /dev/null"
print "\nexec: "+command
session = os.popen(command,"w")
session.write("")
@ -65,7 +94,6 @@ for file in m3u:
wavefiles = os.listdir(wavdir)
for wave in wavefiles:
command = "transcode -J normalize -y wav -i "+wavdir+"/"+wave+" -m "+wavdir+"/"+ wave+".norm &> /dev/null"
print "\nexec: "+command
session = os.popen(command,"w")
session.write("")
@ -76,9 +104,11 @@ for wave in wavefiles:
### wav -> audiocd
command = "sudo cdrecord -v -dev="+recorder+" -pad -audio "+wavdir+"/*.wav.norm"
print "\nexec: "+command
print "\nwarning: If this fails, try to change the \"recorder\" variable!"
session = os.popen(command,"w")
session.write("")
session.flush()
session.close()
print "\n That's it! Eine Stunde coden und dafuer jetzt den Sommer geniessen..."
#print "\n That's it! Eine Stunde coden und dafuer jetzt den Sommer geniessen..."
print "done"