mny small things
This commit is contained in:
parent
952b3f7586
commit
68dea8b842
10
gen.py
10
gen.py
@ -69,7 +69,13 @@ def emit_audio(file, data_dir):
|
||||
#out += "<duration>" + a["length"] + "</duration>\n"
|
||||
out += "</info>\n"
|
||||
out += "<audio controls preload>\n"
|
||||
out += '<source src="' + a["file"] + '" type="audio/' + a["type"] + '">'
|
||||
# if it is a list of files
|
||||
if isinstance(a["type"], list):
|
||||
for t in a["type"]:
|
||||
out += '<source src="' + a["file"] + '.' + t + '" type="audio/' + t + '">\n'
|
||||
else:
|
||||
out += '<source src="' + a["file"] + '" type="audio/' + a["type"] + '">\n'
|
||||
|
||||
out += "</audio>\n"
|
||||
out += "</track>\n"
|
||||
|
||||
@ -141,6 +147,8 @@ def index_content(dir_name, data_dir, index_txt, desc_txt, template):
|
||||
else:
|
||||
files += [os.path.basename(a) for a in glob.glob(f)];
|
||||
|
||||
# sort files?
|
||||
files.sort()
|
||||
|
||||
for j in files:
|
||||
x, ext = os.path.splitext(j);
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<a href="http://pgp.mit.edu/pks/lookup?op=get&search=0x1848D82FADED2A21"><img src="+++/yeux.png" width="500" class="tableau"></a>
|
||||
<a href="+++/"><img src="+++/yeux.png" width="500" class="tableau"></a>
|
||||
<h1><i>Gauthiier - (Selected) Index</i></h1>
|
||||
<h4><a href="http://www.uva.nl/en/profile/g/a/d.gauthier/d.gauthier.html">index of recent academic work</a></h4>
|
||||
<h4>d[at]gauthiier.info</h4>
|
||||
|
||||
61
wavconv.py
Normal file
61
wavconv.py
Normal file
@ -0,0 +1,61 @@
|
||||
import argparse, sys, os, glob, subprocess
|
||||
|
||||
supported = ['ogg', 'mp3']
|
||||
|
||||
def sanity_check_system():
|
||||
r = subprocess.call("ffmpeg -version", shell=True) == 0
|
||||
if not r:
|
||||
sys.exit("ffmpeg not installed. Aborting...")
|
||||
|
||||
def convert(i, o, f):
|
||||
global supported
|
||||
if f not in supported:
|
||||
print("warning: format " + f + "is not supported")
|
||||
return
|
||||
|
||||
if f == 'mp3':
|
||||
codec = 'libmp3lame'
|
||||
elif f == 'ogg':
|
||||
codec = 'libvorbis'
|
||||
|
||||
subprocess.call(['ffmpeg', '-i', i, '-acodec', codec, o])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
p = argparse.ArgumentParser(description='Converts .wav files to other formats (using ffmpeg)');
|
||||
p.add_argument('-i', '--input', help='input directory');
|
||||
p.add_argument('-f', '--format', help='output formats (ogg and/or mp3)', nargs="+");
|
||||
|
||||
sanity_check_system()
|
||||
|
||||
args = p.parse_args()
|
||||
|
||||
if not args.format:
|
||||
sys.exit("Nor formats specified. Aborting.")
|
||||
|
||||
formats = []
|
||||
for f in args.format:
|
||||
if f not in supported:
|
||||
print("warning: format " + f + "is not supported")
|
||||
else:
|
||||
formats.append(f)
|
||||
|
||||
if not formats:
|
||||
sys.exit("None of the specified formats are supported. Aborting.")
|
||||
|
||||
input_dir = "."
|
||||
if args.input:
|
||||
input_dir = args.input
|
||||
|
||||
wav_files = glob.glob(os.path.join(input_dir, "*.wav"))
|
||||
for w in wav_files:
|
||||
for f in formats:
|
||||
fn = os.path.join(input_dir, os.path.basename(w).replace('.wav', '.' + f))
|
||||
convert(w, fn, f)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user