gstreamer-cheat-sheet/python_examples/playbin.py

23 lines
464 B
Python
Raw Normal View History

2018-03-20 07:43:36 +00:00
#!/usr/bin/env python
#
2018-03-20 08:18:38 +00:00
# Plays a file to screen.
#
2018-03-20 07:43:36 +00:00
# Make sure the environment variable SRC is set to a playable file
# e.g.
# export SRC='/tmp/me.mp4'
#
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
import os
Gst.init(None)
2018-03-20 07:43:36 +00:00
mainloop = GObject.MainLoop()
2018-03-20 08:18:38 +00:00
pipeline = Gst.ElementFactory.make("playbin", "player")
pipeline.set_property('uri','file://'+os.environ['SRC'])
2018-03-20 07:43:36 +00:00
2018-03-20 08:18:38 +00:00
pipeline.set_state(Gst.State.PLAYING)
2018-03-20 07:43:36 +00:00
mainloop.run()