Skip to content

Instantly share code, notes, and snippets.

@dphov
Last active April 28, 2023 14:33
Show Gist options
  • Save dphov/defa51222286f4a0923327192106fb90 to your computer and use it in GitHub Desktop.
Save dphov/defa51222286f4a0923327192106fb90 to your computer and use it in GitHub Desktop.
GStreamer mac os x hello world basic tutorial python pygobject
# coding=utf-8
# https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html
# Also big thanks to https://stackoverflow.com/questions/35137165/gstreamer-1-0-video-from-tutorials-is-not-playing-on-macos
import gi
gi.require_versions({'Gst': '1.0'})
from gi.repository import Gst, GLib
Gst.init(None)
Gst.debug_set_active(True)
Gst.debug_set_default_threshold(3)
class Main:
def __init__(self):
self.pipeline = Gst.parse_launch('playbin uri=https://gstreamer.freedesktop.org/data/media/small/sintel.mkv')
self.pipeline.set_state(Gst.State.PLAYING)
self.main_loop = GLib.MainLoop.new(None, False)
GLib.MainLoop.run(self.main_loop)
self.bus = self.pipeline.get_bus()
self.msg = self.bus.timed_pop_filtered(
Gst.CLOCK_TIME_NONE,
Gst.MessageType.ERROR | Gst.MessageType.EOS
)
if self.msg is not None:
self.msg.unref()
self.bus.unref()
self.pipeline.set_state(Gst.State.NULL)
self.pipeline.unref()
Main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment