Created
March 6, 2017 22:31
-
-
Save lsiden/1d75ba2946ef5dbc49271a1629638c3f to your computer and use it in GitHub Desktop.
Based on demo in https://tangopardo.com.ar/2cf7/2013/07/30/using-the-gstreamer-controller-subsystem-from-python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import gi | |
import sys | |
from gi.repository import GObject | |
gi.require_version('Gst', '1.0') | |
from gi.repository import Gst | |
from gi.repository import GstController | |
from gi.repository import GLib | |
GObject.threads_init() | |
Gst.init(sys.argv) | |
p = Gst.parse_launch (""" | |
videotestsrc pattern="colors" ! decodebin ! mix.sink_0 | |
videotestsrc pattern="black" ! decodebin ! mix.sink_1 | |
videomixer name="mix" sink_1::ypos=25 sink_1::xpos=25 sink_1::zorder=99 ! videoconvert ! videoscale ! autovideosink | |
""") | |
mix = p.get_by_name ("mix") | |
if not mix: | |
raise Exception('Cannot find mix element') | |
for pad in mix.pads: | |
print pad.name | |
#sink1 = [pad for pad in mix.pads if pad.name == 'sink_1'][0] | |
sink1 = mix.get_static_pad('sink_1') | |
if not sink1: | |
raise Exception('Cannot find sink_1') | |
cs = GstController.InterpolationControlSource() | |
cs.set_property('mode', GstController.InterpolationMode.LINEAR) | |
cb = GstController.DirectControlBinding.new(sink1, 'alpha', cs) | |
sink1.add_control_binding(cb) | |
cs.set(0*Gst.SECOND, 1) | |
cs.set(4*Gst.SECOND, 0.5) | |
p.set_state (Gst.State.PLAYING) | |
GLib.MainLoop.new(None, False).run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment