Compare commits

...
Sign in to create a new pull request.

4 commits
master ... 34c3

Author SHA1 Message Date
Peter Körner
f5e193871f fix the text output 2017-12-27 20:25:39 +01:00
Peter Körner
2eb1d247b0 fix the --ids handling 2017-12-27 20:25:18 +01:00
Peter Körner
456e4f860a use qt-animation 2017-12-27 20:24:56 +01:00
Peter Körner
04a66cb90c 34c3 mods 2017-12-27 15:07:46 +01:00
4 changed files with 2694 additions and 111 deletions

2536
GPN17-Fahrplan.XML Executable file

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,7 @@ parser.add_argument('--debug', action="store_true", default=False, help='''
Usage: ./make.py yourproject/ --debug Usage: ./make.py yourproject/ --debug
''') ''')
parser.add_argument('--id', dest='ids', nargs='+', action="store", type=int, help=''' parser.add_argument('--id', dest='ids', nargs='*', action="store", type=int, help='''
Only render the given ID(s) from your projects schedule. Only render the given ID(s) from your projects schedule.
This argument must not be used together with --debug This argument must not be used together with --debug
Usage: ./make.py yourproject/ --id 4711 0815 4223 1337 Usage: ./make.py yourproject/ --id 4711 0815 4223 1337
@ -41,17 +41,20 @@ parser.add_argument('--id', dest='ids', nargs='+', action="store", type=int, hel
args = parser.parse_args() args = parser.parse_args()
def headline(str): def headline(str):
print("##################################################") print("##################################################")
print(str) print(str)
print("##################################################") print("##################################################")
print() print()
def error(str): def error(str):
headline(str) headline(str)
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)
if not args.motn: if not args.motn:
error("The Motion-File is a rquired argument") error("The Motion-File is a rquired argument")
@ -72,14 +75,17 @@ if args.debug:
else: else:
events = list(renderlib.events(args.schedule)) events = list(renderlib.events(args.schedule))
def describe_event(event): def describe_event(event):
return "#{}: {}".format(event['id'], event['title']) return "#{}: {}".format(event['id'], event['title'])
def event_print(event, message): def event_print(event, message):
print("{} {}".format(describe_event(event), message)) print("{} {}".format(describe_event(event), message))
tempdir = tempfile.TemporaryDirectory()
print('working in '+tempdir.name) tempdir = '/Users/pkoerner/VOC/34c3_intro_bix'
print('working in ' + tempdir)
def fmt_command(command, **kwargs): def fmt_command(command, **kwargs):
@ -90,10 +96,12 @@ def fmt_command(command, **kwargs):
command = command.format(**args) command = command.format(**args)
return shlex.split(command) return shlex.split(command)
def run(command, **kwargs): def run(command, **kwargs):
return subprocess.check_call( return subprocess.check_call(
fmt_command(command, **kwargs)) fmt_command(command, **kwargs))
def run_output(command, **kwargs): def run_output(command, **kwargs):
return subprocess.check_output( return subprocess.check_output(
fmt_command(command, **kwargs), fmt_command(command, **kwargs),
@ -101,33 +109,69 @@ def run_output(command, **kwargs):
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
def enrich_event(event):
print(event)
result = {}
result.update(event)
art = {"red":"1", "green":"1", "blue":"0.20000000298023224"}
ccc = {"red":"0.60000002384185791", "green":"0.80000001192092896", "blue":"0"}
entertainment = ccc
ethics = {"red":"1", "green":"0.20000000298023224", "blue":"1"}
hardware = {"red":"1", "green":"0.40000000596046448", "blue":"0"}
resilience = {"red":"0.64313727617263794", "green":"0.10980392247438431", "blue":"0.19215686619281769"}
science = {"red":"1", "green":"0.40000000596046448", "blue":"0"}
security = {"red":"0.4117647111415863", "green":"0", "blue":"0.82745099067687988"}
if "Art" in event['track']:
result.update(art)
elif "CCC" in event['track']:
result.update(ccc)
elif "Entertainment" in event['track']:
result.update(entertainment)
elif "Ethics" in event['track']:
result.update(ethics)
elif "Hardware" in event['track']:
result.update(hardware)
elif "Resilience" in event['track']:
result.update(resilience)
elif "Science" in event['track']:
result.update(science)
elif "Security" in event['track']:
result.update(security)
else:
print("Found unrecognized track name %s, assuming CCC track colour" % (event['track']))
result.update(ccc)
return result
def enqueue_job(event): def enqueue_job(event):
event_id = str(event['id']) event_id = str(event['id'])
work_doc = os.path.join(tempdir.name, event_id+'.motn') work_doc = os.path.join(tempdir, event_id + '.motn')
intermediate_clip = os.path.join(tempdir.name, event_id+'.mov') intermediate_clip = os.path.join(tempdir, event_id + '.mov')
with open(args.motn, 'r') as fp: with open(args.motn, 'r') as fp:
xmlstr = fp.read() xmlstr = fp.read()
for key, value in event.items(): for key, value in event.items():
xmlstr = xmlstr.replace("$"+str(key), xmlescape(str(value))) xmlstr = xmlstr.replace("$" + str(key), xmlescape(str(value)))
with open(work_doc, 'w') as fp: with open(work_doc, 'w') as fp:
fp.write(xmlstr) fp.write(xmlstr)
compressor_info = run_output( compressor_info = run_output(
'/Applications/Compressor.app/Contents/MacOS/Compressor -batchname {batchname} -jobpath {jobpath} -settingpath apple-prores-4444.cmprstng -locationpath {locationpath}', '/Applications/Compressor.app/Contents/MacOS/Compressor -batchname {batchname} -jobpath {jobpath} -settingpath qt-animation.cmprstng -locationpath {locationpath}',
batchname=describe_event(event), batchname=describe_event(event),
jobpath=work_doc, jobpath=work_doc,
locationpath=intermediate_clip) locationpath=intermediate_clip)
match = re.search("<jobID ([A-Z0-9\-]+) ?\/>", compressor_info) match = re.search("<jobID ([A-Z0-9\-]+) ?\/>", compressor_info)
if not match: if not match:
event_print(event, "unexpected output from compressor: \n"+compressor_info) event_print(event, "unexpected output from compressor: \n" + compressor_info)
return return
return match.group(1) return match.group(1)
def fetch_job_status(): def fetch_job_status():
compressor_status = run_output('/Applications/Compressor.app/Contents/MacOS/Compressor -monitor') compressor_status = run_output('/Applications/Compressor.app/Contents/MacOS/Compressor -monitor')
job_status_matches = re.finditer("<jobStatus (.*) \/jobStatus>", compressor_status) job_status_matches = re.finditer("<jobStatus (.*) \/jobStatus>", compressor_status)
@ -144,8 +188,6 @@ def fetch_job_status():
return status_dict return status_dict
def filter_finished_jobs(active_jobs): def filter_finished_jobs(active_jobs):
job_status = fetch_job_status() job_status = fetch_job_status()
@ -163,22 +205,24 @@ def filter_finished_jobs(active_jobs):
elif status == 'Successful': elif status == 'Successful':
finished_jobs.append((job_id, event)) finished_jobs.append((job_id, event))
else: else:
event_print(event, "failed with staus="+status+" removing from postprocessing queue") event_print(event, "failed with staus=" + status + " removing from postprocessing queue")
return new_active_jobs, finished_jobs return new_active_jobs, finished_jobs
def finalize_job(job_id, event): def finalize_job(job_id, event):
event_id = str(event['id']) event_id = str(event['id'])
intermediate_clip = os.path.join(tempdir.name, event_id+'.mov') intermediate_clip = os.path.join(tempdir, event_id + '.mov')
final_clip = os.path.join(os.path.dirname(args.motn), event_id+'.ts') final_clip = os.path.join(os.path.dirname(args.motn), event_id + '.mov')
run('ffmpeg -y -hide_banner -loglevel error -i "{input}" -ar 48000 -ac 1 -f s16le -i /dev/zero -map 0:v -c:v mpeg2video -q:v 0 -aspect 16:9 -map 1:0 -map 1:0 -map 1:0 -map 1:0 -shortest -f mpegts "{output}"', # run('ffmpeg -y -hide_banner -loglevel error -i "{input}" -ar 48000 -ac 1 -f s16le -i /dev/zero -map 0:v -c:v mpeg2video -q:v 0 -aspect 16:9 -map 1:0 -map 1:0 -map 1:0 -map 1:0 -shortest -f mpegts "{output}"',
# input=intermediate_clip,
# output=final_clip)
run('mv "{input}" "{output}"',
input=intermediate_clip, input=intermediate_clip,
output=final_clip) output=final_clip)
event_print(event, "finalized intro to "+final_clip) event_print(event, "finalized intro to " + final_clip)
active_jobs = [] active_jobs = []
@ -188,12 +232,14 @@ for event in events:
if args.ids and event['id'] not in args.ids: if args.ids and event['id'] not in args.ids:
continue continue
event = enrich_event(event)
job_id = enqueue_job(event) job_id = enqueue_job(event)
if not job_id: if not job_id:
event_print(event, "job was not enqueued successfully, skipping postprocessing") event_print(event, "job was not enqueued successfully, skipping postprocessing")
continue continue
event_print(event, "enqueued as "+job_id) event_print(event, "enqueued as " + job_id)
active_jobs.append((job_id, event)) active_jobs.append((job_id, event))
print("waiting for rendering to complete") print("waiting for rendering to complete")
@ -207,6 +253,5 @@ while len(active_jobs) > 0:
event_print(event, "finalizing job") event_print(event, "finalizing job")
finalize_job(job_id, event) finalize_job(job_id, event)
print('all done, cleaning up ' + tempdir)
print('all done, cleaning up '+tempdir.name) #tempdir.cleanup()
tempdir.cleanup()

1
qt-animation.cmprstng Normal file
View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><setting name="QuickTime-Animation%20Kopie"><version>327680</version><description>QuickTime-Film%20mit%20Animation-Codec%20und%20unkomprimiertem%20Audio.</description><default-destination></default-destination><descriptionKey>moGraphicsANIMATIONSettingDescription</descriptionKey><encoder name="QT"><audio-video-encode isEnabled="no"/><file-extension>mov</file-extension><job-can-be-segmented>yes</job-can-be-segmented><duration-change factor="100" new-duration="" source-at-output="no"/><marker-image width="0" height="0"/><encode-cc>yes</encode-cc><encode-chapters>yes</encode-chapters><audio-encode name="QT" isEnabled="yes"><auto-channel_layout>no</auto-channel_layout><auto-channel_sampleSize>no</auto-channel_sampleSize><auto-format_sampleRate>no</auto-format_sampleRate><audio-format-info>48000.000000 2 16 48000 N 6619138 Y</audio-format-info><codec-type>NONE</codec-type><itSC>no</itSC></audio-encode><video-encode name="QT" isEnabled="yes"><bounds width="-100" height="-100" pixelAspect="0"/><crop left="0" top="0" right="0" bottom="0"/><padding left="0" top="0" right="0" bottom="0"/><frame-rate>0.000000</frame-rate><automatic video-conversion="" color-spec="" width="-100" height="-100" frame-rate="-100" crop="no" padding="no" center-crop="0" field-dominance="yes"/><video-conversion>1 3 1 0 N 0 100 0 0</video-conversion><color-spec>0</color-spec><computed-pad>no</computed-pad><computed-crop>no</computed-crop><color-space primaries="2" transfer="2" matrix="2"/><color-spec-default>-1000</color-spec-default><ignore-crop-during-processing>no</ignore-crop-during-processing><dithering-setting>0</dithering-setting><codec-type>rle </codec-type><codec-manufacturer>appl</codec-manufacturer><spatial pixelDepth="32" minQuality="0" quality="1024"/><temporal keyFrameInterval="24" minQuality="0" quality="1024" partial-sync="0"/><icm2-options max-passes="1" allow-frame-reoder="no"/><data-rate>0</data-rate><data-rate-limit-size>0</data-rate-limit-size><data-rate-limit-duration>0</data-rate-limit-duration><video-360-metadata-format>0</video-360-metadata-format><video-360-metadata-auto>yes</video-360-metadata-auto></video-encode><write-clap>yes</write-clap><qt-streaming>0</qt-streaming><qt-audio-passthrough>no</qt-audio-passthrough><qt-video-passthrough>no</qt-video-passthrough></encoder><filter-set/></setting>

View file

@ -223,6 +223,7 @@ def events(scheduleUrl, titlemap={}):
'persons': personnames, 'persons': personnames,
'personnames': ', '.join(personnames), 'personnames': ', '.join(personnames),
'room': room.attrib['name'], 'room': room.attrib['name'],
'track': event.find('track').text,
} }
try: try: