diff options
author | Thibault Saunier <thibault.saunier@collabora.com> | 2012-09-18 14:40:51 +0200 |
---|---|---|
committer | Thibault Saunier <thibault.saunier@collabora.com> | 2012-12-19 18:59:48 -0300 |
commit | 3097efec7f2d926e3e0f36cbeb0204994b4e9c37 (patch) | |
tree | 692f40ab54605d472faae6e40caa385ca284bfd4 /bindings | |
parent | df4040a10699e82372bae9083cf1689ed1cf727c (diff) |
bindings: Add simple python examples
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/python/examples/material.py | 44 | ||||
-rw-r--r-- | bindings/python/examples/simple.py | 31 |
2 files changed, 75 insertions, 0 deletions
diff --git a/bindings/python/examples/material.py b/bindings/python/examples/material.py new file mode 100644 index 00000000..424679f2 --- /dev/null +++ b/bindings/python/examples/material.py @@ -0,0 +1,44 @@ +from gi.repository import Gst, GES, GLib + +import os + +class Simple: + def __init__(self, uri): + timeline = GES.Timeline() + trackv = GES.Track.video_raw_new() + self.layer = GES.TimelineLayer() + self.pipeline = GES.TimelinePipeline() + self.pipeline.add_timeline(timeline) + + + timeline.add_track(trackv) + timeline.add_layer(self.layer) + + GES.Asset.new_async(GES.TimelineFileSource, uri, None, self.discoveredCb, None) + self.loop = GLib.MainLoop() + self.loop.run() + + def discoveredCb(self, asset, result, blop): + self.layer.add_asset(asset, long(0), long(0), long(10 * Gst.SECOND), 1.0, GES.TrackType.VIDEO) + self.start() + + def busMessageCb(self, bus, message, udata): + if message.type == Gst.MessageType.EOS: + print "EOS" + self.loop.quit() + if message.type == Gst.MessageType.ERROR: + print "ERROR" + self.loop.quit() + + def start(self): + self.pipeline.set_state(Gst.State.PLAYING) + self.pipeline.get_bus().add_watch(GLib.PRIORITY_DEFAULT, self.busMessageCb, None) + +if __name__ == "__main__": + if len(os.sys.argv) < 2: + print "You must specify a file URI" + exit(-1) + GES.init() + + # And try! + Simple(os.sys.argv[1]) diff --git a/bindings/python/examples/simple.py b/bindings/python/examples/simple.py new file mode 100644 index 00000000..0987d8c3 --- /dev/null +++ b/bindings/python/examples/simple.py @@ -0,0 +1,31 @@ +from gi.repository import Gst, GES, GLib + +class Simple: + def __init__(self, uri): + timeline = GES.Timeline() + trackv = GES.Track.video_raw_new() + layer = GES.TimelineLayer() + self.pipeline = GES.TimelinePipeline() + self.pipeline.add_timeline(timeline) + + timeline.add_track(trackv) + timeline.add_layer(layer) + + src = GES.TimelineFileSource.new(uri=uri) + src.set_start(long(0)) + src.set_duration(long(10 * Gst.SECOND)) + print src + layer.add_object(src) + + def start(self): + self.pipeline.set_state(Gst.State.PLAYING) + +if __name__ == "__main__": + if len(os.sys.argv) < 2: + print "You must specify a file URI" + exit(-1) + + loop = GLib.MainLoop() + widget = Simple() + widget.start() + loop.run() |