7 #FONT_DESC = "Andale Mono, 72"
10 SAMPLE_LENGTH_SECONDS = 4
12 # 48000 samples per seconds, at 1024 samples per buffer
13 NUM_AUDIO_BUFFERS = round(SAMPLE_LENGTH_SECONDS * 48000 / 1024)
15 LIVE_PIPELINE_TEMPLATE = """
16 videotestsrc num-buffers=1 pattern=black ! \
17 textoverlay valignment=center halignment=center font-desc="%s" text="{0}" ! \
19 audiotestsrc num-buffers=%d freq={1:f} ! audio/x-raw,rate=48000 ! \
21 """ % (FONT_DESC, NUM_AUDIO_BUFFERS)
23 FILE_PIPELINE_TEMPLATE = """
24 matroskamux name=mux ! filesink location="{2}/sample_{0}.mkv"
25 videotestsrc num-buffers=1 pattern=black ! \
26 textoverlay valignment=center halignment=center font-desc="%s" text="{0}" ! \
27 queue ! schroenc rate-control=3 ! mux.
28 audiotestsrc num-buffers=%d freq={1:f} ! audio/x-raw,rate=48000 ! \
29 queue ! audioconvert ! vorbisenc quality=0.5 ! queue ! mux.
30 """ % (FONT_DESC, NUM_AUDIO_BUFFERS)
33 def create_test_videofont(pipeline_template, notes_range, destination_dir=None):
34 for i, note_number in enumerate(notes_range):
35 note = vidi.SpnNote(note_number)
37 print("%2d %s" % (i, note))
39 pipeline_string = pipeline_template.format(note.name, note.frequency, destination_dir)
41 player = vidi.Player.from_pipeline_string(pipeline_string)
48 print("usage: %s [<videofont_destination_dir>]" %
49 os.path.basename(sys.argv[0]))
53 if len(sys.argv) > 1 and sys.argv[1] in ["-h", "--help"]:
57 notes_range = vidi.PIANO_88_KEYS_RANGE
60 destination_dir = os.path.realpath(sys.argv[1])
61 if os.path.exists(destination_dir):
62 sys.stderr.write("The destination already exists '%s'!\n"
66 os.mkdir(destination_dir)
67 create_test_videofont(FILE_PIPELINE_TEMPLATE, notes_range,
70 create_test_videofont(LIVE_PIPELINE_TEMPLATE, notes_range)
73 if __name__ == "__main__":