vidi/Timeline.py: add support for adding clips on their own layers
authorAntonio Ospite <ao2@ao2.it>
Mon, 5 Dec 2016 13:45:30 +0000 (14:45 +0100)
committerAntonio Ospite <ao2@ao2.it>
Mon, 5 Dec 2016 13:45:30 +0000 (14:45 +0100)
This can be used for instance to add a "background" clip, in case of
a midi file with intervals of silence, the background clip could be the
videofont sample representing a rest.

vidi/Timeline.py

index fe98677..59c891a 100755 (executable)
@@ -53,6 +53,14 @@ class Timeline(object):
         self.layer.add_asset(asset, start_time * Gst.SECOND, 0,
                              duration * Gst.SECOND, GES.TrackType.UNKNOWN)
 
         self.layer.add_asset(asset, start_time * Gst.SECOND, 0,
                              duration * Gst.SECOND, GES.TrackType.UNKNOWN)
 
+    def add_layer_clip(self, clip_path, start_time, duration):
+        """Add a clip on its own layer"""
+        clip_uri = Gst.filename_to_uri(clip_path)
+        asset = GES.UriClipAsset.request_sync(clip_uri)
+        new_layer = self.timeline.append_layer()
+        new_layer.add_asset(asset, start_time * Gst.SECOND, 0,
+                            duration * Gst.SECOND, GES.TrackType.UNKNOWN)
+
     def play(self):
         self.timeline.commit()
         self.player.play()
     def play(self):
         self.timeline.commit()
         self.player.play()