diff --git a/encode.py b/encode.py index ce98399..88ad69c 100755 --- a/encode.py +++ b/encode.py @@ -17,7 +17,7 @@ def get_videoduration(video): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stdin = p.communicate() data = json.loads(stdout.decode()) - duration = float([s for s in data['streams'] if 'width' in s][0]['duration']) - 10/60 + duration = float([s for s in data['streams'] if 'width' in s][0]['duration']) - 70/60 return '%0.3f' % duration for xml in sorted(glob('output/*/*.xml')): diff --git a/render.py b/render.py index d9825be..319e9d3 100755 --- a/render.py +++ b/render.py @@ -178,6 +178,7 @@ def filter_clips(clips, duration, max_duration=0): def sequence(seq, letter): tags = KEYWORDS[letter] clips = {tag: get_clips(tag) for tag in tags} + all_clips = clips.copy() result = { 'clips': [], 'text': [], @@ -195,10 +196,11 @@ def sequence(seq, letter): max_duration = MAX_DURATION - duration clips_n = filter_clips(clips, n, max_duration) - tags_n = [] - for tag in tags: - if tag in clips_n: - tags_n.append(tag) + tags_n = [tag for tag in tags if tag in clips_n] + if not tags_n: + print('MISSING CLIPS, fall back to all clips!', letter, n) + clips_n = filter_clips(all_clips, n, max_duration) + tags_n = [tag for tag in tags if tag in clips_n] if not tags_n: print('NO tags for', letter, n) sys.exit(1) @@ -208,6 +210,10 @@ def sequence(seq, letter): clip = random_choice(seq, clips_n[tag]) duration += clip['duration'] result['clips'].append(clip.copy()) + + # no reuse + for t in clips: + clips[t] = [c for c in clips[t] if not c['id'] == clip['id']] ''' for clip in result['clips']: if seq() == 0: diff --git a/render_mlt.py b/render_mlt.py index 8797b77..372714a 100755 --- a/render_mlt.py +++ b/render_mlt.py @@ -86,6 +86,7 @@ for clip in data['clips']: in_ = int(clip['in'] * fps) frames = int(clip['duration'] * fps) add_clip(video, clip['path'], in_, frames) +add_color(video, 'black', 60) for clip in data['text']: if clip.get('blank'):