mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 02:15:31 +00:00
examples: python: Simplify the simple example
We shouldn't show assets usage in the simplest example we have as it is useful for more advanced use cases. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/252>
This commit is contained in:
parent
7f17367ce5
commit
b24d1918f8
2 changed files with 9 additions and 21 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
import sys
|
import sys
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
|
|
|
@ -31,22 +31,17 @@ from gi.repository import Gst, GES, GLib # noqa
|
||||||
class Simple:
|
class Simple:
|
||||||
def __init__(self, uri):
|
def __init__(self, uri):
|
||||||
timeline = GES.Timeline.new_audio_video()
|
timeline = GES.Timeline.new_audio_video()
|
||||||
self.project = timeline.get_asset()
|
layer = timeline.append_layer()
|
||||||
|
layer.add_clip(GES.UriClip.new(uri))
|
||||||
self.project.connect("asset-added", self._asset_added_cb)
|
self.pipeline = pipeline = GES.Pipeline()
|
||||||
self.project.connect("error-loading-asset", self._error_loading_asset_cb)
|
pipeline.set_timeline(timeline)
|
||||||
self.project.create_asset(uri, GES.UriClip)
|
pipeline.set_state(Gst.State.PLAYING)
|
||||||
self.layer = timeline.append_layer()
|
bus = pipeline.get_bus()
|
||||||
self._create_pipeline(timeline)
|
|
||||||
self.loop = GLib.MainLoop()
|
|
||||||
|
|
||||||
def _create_pipeline(self, timeline):
|
|
||||||
self.pipeline = GES.Pipeline()
|
|
||||||
self.pipeline.set_timeline(timeline)
|
|
||||||
bus = self.pipeline.get_bus()
|
|
||||||
bus.add_signal_watch()
|
bus.add_signal_watch()
|
||||||
bus.connect("message", self.bus_message_cb)
|
bus.connect("message", self.bus_message_cb)
|
||||||
|
|
||||||
|
self.loop = GLib.MainLoop()
|
||||||
|
|
||||||
def bus_message_cb(self, unused_bus, message):
|
def bus_message_cb(self, unused_bus, message):
|
||||||
if message.type == Gst.MessageType.EOS:
|
if message.type == Gst.MessageType.EOS:
|
||||||
print("eos")
|
print("eos")
|
||||||
|
@ -59,14 +54,6 @@ class Simple:
|
||||||
def start(self):
|
def start(self):
|
||||||
self.loop.run()
|
self.loop.run()
|
||||||
|
|
||||||
def _asset_added_cb(self, project, asset):
|
|
||||||
self.layer.add_asset(asset, 0, 0, Gst.SECOND * 5, GES.TrackType.UNKNOWN)
|
|
||||||
self.pipeline.set_state(Gst.State.PLAYING)
|
|
||||||
|
|
||||||
def _error_loading_asset_cb(self, project, error, asset_id, type):
|
|
||||||
print("Could not load asset %s: %s" % (asset_id, error))
|
|
||||||
self.loop.quit()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(os.sys.argv) != 2:
|
if len(os.sys.argv) != 2:
|
||||||
print("You must specify a file URI")
|
print("You must specify a file URI")
|
||||||
|
|
Loading…
Reference in a new issue