fix AE render

This commit is contained in:
derchris 2021-12-28 03:26:36 +01:00
parent e57134af26
commit 9dd516d624

View file

@ -173,12 +173,29 @@ def run_output(command, **kwargs):
stderr=subprocess.STDOUT)
def run_once(command, **kwargs):
DETACHED_PROCESS = 0x00000008
return subprocess.Popen(
fmt_command(command, **kwargs),
shell=False,
stdin=None,
stdout=None,
stderr=None,
close_fds=True,
creationflags=DETACHED_PROCESS)
def enqueue_job(event):
event_id = str(event['id'])
if (os.path.exists(os.path.join(args.project, event_id + '.ts')) or os.path.exists(os.path.join(args.project, event_id + '.mov'))) and not args.force:
event_print(event, "file exist, skipping " + str(event['id']))
return
work_doc = os.path.join(tempdir.name, event_id + '.aepx')
script_doc = os.path.join(tempdir.name, event_id+'.jsx')
ascript_doc = os.path.join(tempdir.name, event_id+'.scpt')
if platform.system() == 'Windows':
intermediate_clip = os.path.join(tempdir.name, event_id + '.avi')
else:
intermediate_clip = os.path.join(tempdir.name, event_id + '.mov')
if event_id == 'pause' or event_id == 'outro' or event_id == 'bgloop':
@ -196,33 +213,57 @@ def enqueue_job(event):
locationpath=intermediate_clip)
else:
with open(args.project + 'intro.aepx', 'r') as fp:
with open(args.project + 'intro.jsx', 'r') as fp:
scriptstr = fp.read()
scriptstr = scriptstr.replace("$filename", work_doc.replace("\\", "/"))
for key, value in event.items():
value = str(value).replace('"', '\\"')
scriptstr = scriptstr.replace("$" + str(key), value)
with open(work_doc, 'w', encoding='utf-8') as fp:
with open(script_doc, 'w', encoding='utf-8') as fp:
fp.write(scriptstr)
copyfile(args.project+'intro.aepx',work_doc)
if platform.system() == 'Darwin':
run(r'/Applications/Adobe\ After\ Effects\ 2020/aerender -project {jobpath} -comp "intro" -mp -output {locationpath}',
copyfile(args.project+'intro.scpt',ascript_doc)
run('osascript {ascript_path} {jobpath} {scriptpath}',
jobpath=work_doc,
scriptpath=script_doc,
ascript_path=ascript_doc)
run(r'/Applications/Adobe\ After\ Effects\ 2022/aerender -project {jobpath} -comp "intro" -mp -output {locationpath}',
jobpath=work_doc,
locationpath=intermediate_clip)
if platform.system() == 'Windows':
run(r'C:/Program\ Files/Adobe/Adobe\ After\ Effects\ 2020/Support\ Files/aerender.exe -project {jobpath} -comp "intro" -mp -output {locationpath}',
run_once(r'C:/Program\ Files/Adobe/Adobe\ After\ Effects\ 2022/Support\ Files/AfterFX.exe -noui -r {scriptpath}',
scriptpath=script_doc)
time.sleep(2)
run(r'C:/Program\ Files/Adobe/Adobe\ After\ Effects\ 2022/Support\ Files/aerender.exe -project {jobpath} -comp "intro" -mfr on 100 -output {locationpath}',
jobpath=work_doc,
locationpath=intermediate_clip)
if args.debug or args.keep:
path = tempdir.name
dirs = os.listdir( path )
for file in dirs:
print(file)
copyfile(work_doc, args.project + event_id + '.aepx')
copyfile(script_doc, args.project + event_id + '.jsx')
copyfile(intermediate_clip, args.project + event_id + '.avi')
return event_id
def finalize_job(job_id, event):
event_id = str(event['id'])
if platform.system() == 'Windows':
intermediate_clip = os.path.join(tempdir.name, event_id + '.avi')
else:
intermediate_clip = os.path.join(tempdir.name, event_id + '.mov')
final_clip = os.path.join(os.path.dirname(args.project), event_id + '.ts')