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(
os.path.getmtime(xml),
os.path.getmtime('text.html'),
os.path.getmtime('encode.py'),
os.path.getmtime('DRONES.json'),
os.path.getmtime('VOCALS.json'),
os.path.getmtime('encode.py'),
)
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_480p = public_mp4.replace('.1080p.mp4', '.480p.mp4')
if force or is_new(xml, public_mp4):
print(public_mp4)
cmd = [
'qmelt', xml, '-consumer',
'avformat:' + video,
@ -132,6 +134,8 @@ def encode(xml, force=False, prefix='.'):
item_json
]
subprocess.call(cmd)
else:
print('skip', public_mp4)
def encode_all(prefix):
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:
fd.write(current)
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_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':
# render gongs
render_gongs = not os.path.exists(gongs_wav)
if not render_gongs:
render_gongs = os.path.getmtime(source) > os.path.getmtime(gongs_wav)
#if not render_gongs:
# render_gongs = os.path.getmtime(source) > os.path.getmtime(gongs_wav)
if render_gongs:
subprocess.call([
# offset in pi, duration, number of tracks, target