X-Git-Url: https://git.ao2.it/vidi-player.git/blobdiff_plain/f778b0ade9ac49e0deab3f694c7e4a0905388f1b..a2244f398d67ed5d9e82e99f851a3f7d91f3c7b9:/vidi-timeline.py diff --git a/vidi-timeline.py b/vidi-timeline.py index 17165fc..7e58863 100755 --- a/vidi-timeline.py +++ b/vidi-timeline.py @@ -22,15 +22,31 @@ import sys import mido import vidi -# TODO: turn that into a command line option +# TODO: turn these into command line options ADD_REST_BACKGROUND = True +ADD_TITLE = True +TITLE_TEXT = None +TITLE_DURATION = 5 +TITLE_CREDITS = "Created with vidi-timeline\nhttps://git.ao2.it/vidi-player.git" +CANVAS_SIZE = (640, 480) -def timeline_from_midi(midi_file, video_font_path): - timeline = vidi.Timeline() +def timeline_from_midi(midi_file, canvas_size, video_font_path): + timeline = vidi.Timeline(canvas_size) + + if ADD_TITLE: + title = TITLE_TEXT + if not title: + title = os.path.splitext(os.path.basename(midi_file.filename))[0] + title += "\n\n" + title += TITLE_CREDITS + + timeline.add_title_clip(title, 0, TITLE_DURATION) + + elapsed_time = start_time = TITLE_DURATION + else: + elapsed_time = start_time = 0 - elapsed_time = 0 - start_time = 0 for msg in midi_file: elapsed_time += msg.time if vidi.is_note_on(msg) and msg.channel == 0: @@ -84,7 +100,7 @@ def main(): video_font_path = os.path.realpath(sys.argv[2]) - timeline = timeline_from_midi(midi_file, video_font_path) + timeline = timeline_from_midi(midi_file, CANVAS_SIZE, video_font_path) if len(sys.argv) > 3: timeline.save(sys.argv[3])