add command line option to render one specific frame, e.g. titles for debugging

This commit is contained in:
Andreas Hubel 2017-10-26 22:41:40 +02:00
parent d851c1d989
commit f1d511b97f
2 changed files with 23 additions and 7 deletions

View file

@ -26,6 +26,11 @@ parser.add_argument('--debug', action="store_true", default=False, help='''
This argument must not be used together with --id This argument must not be used together with --id
Usage: ./make.py yourproject/ --debug Usage: ./make.py yourproject/ --debug
''') ''')
parser.add_argument('--only-frame', action="store", default=None, type=int, help='''
Only render the given frames (of the intro), e.g. to quickly render snapshots of the tiles frame.
Usage: ./make.py yourproject/ --debug --only-frame 300
./make.py yourproject/ --only-frame 300
''')
parser.add_argument('--id', nargs='+', action="store", type=int, help=''' parser.add_argument('--id', 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

View file

@ -101,6 +101,10 @@ def rendertask(task):
skip_rendering = False skip_rendering = False
if args.skip_frames: if args.skip_frames:
skip_rendering = (frameNr <= args.skip_frames) skip_rendering = (frameNr <= args.skip_frames)
if args.only_frame:
skip_rendering = (frameNr != args.only_frame)
# print a line for each and every frame generated # print a line for each and every frame generated
if debug and not skip_rendering: if debug and not skip_rendering:
print("frameNr {0:3d} => {1}".format(frameNr, frame)) print("frameNr {0:3d} => {1}".format(frameNr, frame))
@ -159,19 +163,28 @@ def rendertask(task):
if args.only_frame:
task.outfile = '{0}.frame{1:04d}.png'.format(task.outfile, args.only_frame)
# remove the dv/ts we are about to (re-)generate # remove the dv/ts we are about to (re-)generate
ensureFilesRemoved(os.path.join(task.workdir, task.outfile)) ensureFilesRemoved(os.path.join(task.workdir, task.outfile))
if task.outfile.endswith('.png'):
cmd = 'cd {0} && cp ".frames/{1:04d}.png" "{2}"'.format(task.workdir, args.only_frame, task.outfile)
# invoke avconv aka ffmpeg and renerate a lossles-dv from the frames # invoke avconv aka ffmpeg and renerate a lossles-dv from the frames
# if we're not in debug-mode, suppress all output # if we're not in debug-mode, suppress all output
if task.outfile.endswith('.ts'): elif task.outfile.endswith('.ts'):
cmd = 'cd {0} && '.format(task.workdir) cmd = 'cd {0} && '.format(task.workdir)
cmd += 'ffmpeg -f image2 -i .frames/%04d.png ' cmd += 'ffmpeg -f image2 -i .frames/%04d.png '
if task.audiofile is None: if task.audiofile is None:
cmd += '-ar 48000 -ac 1 -f s16le -i /dev/zero -ar 48000 -ac 1 -f s16le -i /dev/zero ' cmd += '-ar 48000 -ac 1 -f s16le -i /dev/zero -ar 48000 -ac 1 -f s16le -i /dev/zero '
else: else:
cmd += '-i {0} -i {0} '.format(task.audiofile) cmd += '-i {0} -i {0} '.format(task.audiofile)
cmd += '-map 0:0 -c:v mpeg2video -q:v 0 -aspect 16:9'
cmd += '-map 0:0 -c:v mpeg2video -q:v 5 -aspect 16:9 '
if task.audiofile is None: if task.audiofile is None:
cmd += '-map 1:0 -map 2:0 ' cmd += '-map 1:0 -map 2:0 '
else: else:
@ -190,11 +203,9 @@ def rendertask(task):
if r != 0: if r != 0:
sys.exit() sys.exit()
if not debug:
print("cleanup") print("cleanup")
# remove the .frames-dir with all frames in it
if not debug:
shutil.rmtree(os.path.join(task.workdir, '.frames'))
# remove the generated svg # remove the generated svg
ensureFilesRemoved(os.path.join(task.workdir, '.gen.svg')) ensureFilesRemoved(os.path.join(task.workdir, '.gen.svg'))