vidi/Timeline.py: support setting the canvas size
authorAntonio Ospite <ao2@ao2.it>
Wed, 7 Dec 2016 16:01:02 +0000 (17:01 +0100)
committerAntonio Ospite <ao2@ao2.it>
Wed, 7 Dec 2016 16:04:47 +0000 (17:04 +0100)
vidi/Timeline.py

index da8e83c..ef04c99 100755 (executable)
@@ -35,13 +35,20 @@ TITLE_OUTLINE_COLOR = 0x00000000
 TITLE_FONT_DESC = "Georgia, 24"
 
 class Timeline(object):
-    def __init__(self):
+    def __init__(self, canvas_size=None):
         self.project = GES.Project(extractable_type=GES.Timeline)
         self.timeline = GES.Asset.extract(self.project)
 
         audio_track = GES.AudioTrack.new()
         video_track = GES.VideoTrack.new()
 
+        if canvas_size:
+            width, height = canvas_size
+            caps = Gst.Caps.new_empty_simple("video/x-raw")
+            caps.set_value("width", width)
+            caps.set_value("height", height)
+            video_track.set_restriction_caps(caps)
+
         self.timeline.add_track(audio_track)
         self.timeline.add_track(video_track)