From 1599de57b53c78ac05965fe7038f3a8d67c1a3c0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 21 Aug 2018 15:01:54 +0200 Subject: skip frames --- rpc/img_ops.py | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'rpc') diff --git a/rpc/img_ops.py b/rpc/img_ops.py index bbe1856..6be1d0b 100644 --- a/rpc/img_ops.py +++ b/rpc/img_ops.py @@ -67,7 +67,7 @@ def process_image(opt, data_opt, im): return img last_im = None -def mix_next_image(opt, data_opt, rpc_client, im, i, sequence, sequence_i): +def mix_next_image(opt, data_opt, rpc_client, im, i=0, sequence, sequence_i=0, skip_i=0): global last_im if (i % 100) == 0: @@ -77,17 +77,35 @@ def mix_next_image(opt, data_opt, rpc_client, im, i, sequence, sequence_i): tmp_path = opt.render_dir + "frame_{:05d}_tmp.png".format(i+1) next_path = opt.render_dir + "frame_{:05d}.png".format(i+1) current_path = opt.render_dir + "ren_{:05d}.png".format(i+1) - meta = { 'i': i, 'sequence_i': math.floor(sequence_i), 'sequence_len': len(sequence) } - if data_opt.sequence and len(sequence): - sequence_path = sequence[math.floor(sequence_i)] - if data_opt.sequence_playing and data_opt.sequence_step != 0: - sequence_i += data_opt.sequence_step - if sequence_i >= len(sequence): - print('(((( sequence looped ))))') - sequence_i = sequence_i % len(sequence) - if sequence_i < 0: - print('(((( sequence looped ))))') - sequence_i += len(sequence) + + # skip a certain number of frames + if data_opt.sequence_skip == 0: + skip_i = 0 + else: + skip_i += 1 + if skip_i >= data_opt.sequence_skip: + skip_i = 0 + sequence_i += data_opt.sequence_step * (data_opt.sequence_skip - 1) + + # get the sequence path for the current frame + sequence_path = sequence[math.floor(sequence_i)] + + if skip_i == 0 and data_opt.sequence_playing and data_opt.sequence_step != 0: + sequence_i += data_opt.sequence_step + + if sequence_i >= len(sequence): + print('(((( sequence looped ))))') + sequence_i = sequence_i % len(sequence) + if sequence_i < 0: + print('(((( sequence looped ))))') + sequence_i += len(sequence) + + meta = { + 'i': i, + 'sequence_i': math.floor(sequence_i), + 'skip_i': math.floor(skip_i), + 'sequence_len': len(sequence) + } if data_opt.store_a is not True: os.remove(last_path) @@ -172,4 +190,4 @@ def mix_next_image(opt, data_opt, rpc_client, im, i, sequence, sequence_i): if (i % 20) == 0: print("created {}".format(next_path)) - return sequence_i \ No newline at end of file + return sequence_i, skip_i \ No newline at end of file -- cgit v1.2.3-70-g09d2