create_test_videofont.py: make the pipelines more configurable
authorAntonio Ospite <ao2@ao2.it>
Thu, 1 Dec 2016 21:31:21 +0000 (22:31 +0100)
committerAntonio Ospite <ao2@ao2.it>
Thu, 1 Dec 2016 21:31:21 +0000 (22:31 +0100)
While at it also calculate the proper number of video buffers, this
produces more robust samples in which both the audio and the video
streams have the same length in seconds.

create_test_videofont.py

index 14c6509..40125a6 100755 (executable)
@@ -9,25 +9,31 @@ FONT_DESC = "Mono, 72"
 
 SAMPLE_LENGTH_SECONDS = 4
 
 
 SAMPLE_LENGTH_SECONDS = 4
 
-# 48000 samples per seconds, at 1024 samples per buffer
-NUM_AUDIO_BUFFERS = round(SAMPLE_LENGTH_SECONDS * 48000 / 1024)
+VIDEO_FRAMERATE = 25
+VIDEO_BUFFERS = SAMPLE_LENGTH_SECONDS * VIDEO_FRAMERATE
+
+AUDIO_SAMPLERATE = 48000
+AUDIO_SAMPLESPERBUFFER = 1024
+AUDIO_BUFFERS = round(SAMPLE_LENGTH_SECONDS * 48000 / 1024)
 
 LIVE_PIPELINE_TEMPLATE = """
 
 LIVE_PIPELINE_TEMPLATE = """
-  videotestsrc num-buffers=1 pattern=black ! \
+  videotestsrc num-buffers=%d pattern=black ! video/x-raw,framerate=%d/1 ! \
           textoverlay valignment=center halignment=center font-desc="%s" text="{0}" ! \
           autovideosink \
           textoverlay valignment=center halignment=center font-desc="%s" text="{0}" ! \
           autovideosink \
-  audiotestsrc num-buffers=%d freq={1:f} ! audio/x-raw,rate=48000 ! \
+  audiotestsrc num-buffers=%d samplesperbuffer=%d freq={1:f} ! audio/x-raw,rate=%d ! \
           autoaudiosink
           autoaudiosink
-""" % (FONT_DESC, NUM_AUDIO_BUFFERS)
+""" % (VIDEO_BUFFERS, VIDEO_FRAMERATE, FONT_DESC, AUDIO_BUFFERS,
+       AUDIO_SAMPLESPERBUFFER, AUDIO_SAMPLERATE)
 
 FILE_PIPELINE_TEMPLATE = """
   webmmux name=mux ! filesink location="{2}/sample_{0}.webm"
 
 FILE_PIPELINE_TEMPLATE = """
   webmmux name=mux ! filesink location="{2}/sample_{0}.webm"
-  videotestsrc num-buffers=1 pattern=black ! \
+  videotestsrc num-buffers=%d pattern=black ! video/x-raw,framerate=%d/1 ! \
           textoverlay valignment=center halignment=center font-desc="%s" text="{0}" ! \
           queue ! vp9enc ! mux.
           textoverlay valignment=center halignment=center font-desc="%s" text="{0}" ! \
           queue ! vp9enc ! mux.
-  audiotestsrc num-buffers=%d freq={1:f} ! audio/x-raw,rate=48000 ! \
+  audiotestsrc num-buffers=%d samplesperbuffer=%d freq={1:f} ! audio/x-raw,rate=%d ! \
           queue ! audioconvert ! vorbisenc quality=0.5 ! queue ! mux.
           queue ! audioconvert ! vorbisenc quality=0.5 ! queue ! mux.
-""" % (FONT_DESC, NUM_AUDIO_BUFFERS)
+""" % (VIDEO_BUFFERS, VIDEO_FRAMERATE, FONT_DESC, AUDIO_BUFFERS,
+       AUDIO_SAMPLESPERBUFFER, AUDIO_SAMPLERATE)
 
 
 def create_test_videofont(pipeline_template, notes_range, destination_dir=None):
 
 
 def create_test_videofont(pipeline_template, notes_range, destination_dir=None):