This commit is contained in:
j 2017-10-05 12:29:37 +00:00
parent 708b27bdb1
commit 5f58c7aab7
4 changed files with 62 additions and 4 deletions

View file

@ -29,9 +29,9 @@ def is_new(xml, mp4):
xtime = max( xtime = max(
os.path.getmtime(xml), os.path.getmtime(xml),
os.path.getmtime('text.html'), os.path.getmtime('text.html'),
os.path.getmtime('encode.py'),
os.path.getmtime('DRONES.json'), os.path.getmtime('DRONES.json'),
os.path.getmtime('VOCALS.json'), os.path.getmtime('VOCALS.json'),
os.path.getmtime('encode.py'),
) )
return vtime < xtime return vtime < xtime
@ -52,7 +52,9 @@ def encode(xml, force=False, prefix='.'):
public_mp4 = os.path.join(prefix, 'public', mp4.split('/')[-1][0].lower() + mp4.split('/')[-2] + '.1080p.mp4') public_mp4 = os.path.join(prefix, 'public', mp4.split('/')[-1][0].lower() + mp4.split('/')[-2] + '.1080p.mp4')
public_mp4_480p = public_mp4.replace('.1080p.mp4', '.480p.mp4') public_mp4_480p = public_mp4.replace('.1080p.mp4', '.480p.mp4')
if force or is_new(xml, public_mp4): if force or is_new(xml, public_mp4):
print(public_mp4)
cmd = [ cmd = [
'qmelt', xml, '-consumer', 'qmelt', xml, '-consumer',
'avformat:' + video, 'avformat:' + video,
@ -132,6 +134,8 @@ def encode(xml, force=False, prefix='.'):
item_json item_json
] ]
subprocess.call(cmd) subprocess.call(cmd)
else:
print('skip', public_mp4)
def encode_all(prefix): def encode_all(prefix):
for xml in sorted(glob(os.path.join(prefix, 'output/*/*.xml'))): for xml in sorted(glob(os.path.join(prefix, 'output/*/*.xml'))):

View file

@ -463,6 +463,9 @@ if __name__ == '__main__':
with open(tjson, 'w') as fd: with open(tjson, 'w') as fd:
fd.write(current) fd.write(current)
if render_xml: if render_xml:
if current != old or os.path.getmtime(tjson) < os.path.getmtime('render_mlt.py'): txml = tjson.replace('.json', '.xml')
if not os.path.exists(txml) or \
os.path.getmtime(tjson) < os.path.getmtime('render_mlt.py') or \
os.path.getmtime(txml) < os.path.getmtime(tjson):
subprocess.call(['./render_mlt.py', '--prefix', opts.prefix, tjson]) subprocess.call(['./render_mlt.py', '--prefix', opts.prefix, tjson])
#subprocess.call(['./render_audio.py', tjson]) #subprocess.call(['./render_audio.py', tjson])

51
render_all_gongs.py Executable file
View file

@ -0,0 +1,51 @@
#!/usr/bin/python3
from argparse import ArgumentParser
from concurrent.futures import ThreadPoolExecutor
import json
import os
import string
import subprocess
import sys
def render_gongs(source):
gongs_wav = source.replace('.json', '.gongs.wav')
render_gongs = not os.path.exists(gongs_wav)
if not render_gongs:
render_gongs = os.path.getmtime(source) > os.path.getmtime(gongs_wav)
if render_gongs:
with open(source) as fd:
data = json.load(fd)
duration = sum(clip['duration'] for clip in data['clips'])
cmd = [
# offset in pi, duration, number of tracks, target
'./render_gongs.py',
str(data['gongs']['offset']),
str(duration),
str(data['gongs']['tracks']),
gongs_wav
]
print(cmd)
subprocess.call(cmd)
if __name__ == '__main__':
usage = "usage: %(prog)s [options] json"
parser = ArgumentParser(usage=usage)
parser.add_argument('-p', '--prefix', dest='prefix', help='version prefix', default='.')
parser.add_argument('files', metavar='path', type=str, nargs='*', help='json source file')
opts = parser.parse_args()
files = opts.files
if not files:
files = []
for n in range(10):
for letter in string.ascii_uppercase:
f = os.path.join(opts.prefix, 'output/%02d/%s.json' % (n, letter))
files.append(f)
with ThreadPoolExecutor(max_workers=4) as e:
for f in sorted(files):
e.submit(render_gongs, f)

View file

@ -213,8 +213,8 @@ save_xml(music, target_music)
if version == 'performance': if version == 'performance':
# render gongs # render gongs
render_gongs = not os.path.exists(gongs_wav) render_gongs = not os.path.exists(gongs_wav)
if not render_gongs: #if not render_gongs:
render_gongs = os.path.getmtime(source) > os.path.getmtime(gongs_wav) # render_gongs = os.path.getmtime(source) > os.path.getmtime(gongs_wav)
if render_gongs: if render_gongs:
subprocess.call([ subprocess.call([
# offset in pi, duration, number of tracks, target # offset in pi, duration, number of tracks, target