Created
March 13, 2017 20:42
-
-
Save lsiden/c66ed5f35a00657c9225d1dc04f07b0c to your computer and use it in GitHub Desktop.
Gst Pipeline demo with control source bound to 'alpha' property of videomixer sink
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 sys | |
import threading | |
import time | |
import gi | |
gi.require_version('Gst', '1.0') | |
from gi.repository import GObject | |
from gi.repository import Gst, GstController, GLib | |
def get_alpha_controller(pad): | |
cs = GstController.InterpolationControlSource() | |
cs.set_property('mode', GstController.InterpolationMode.LINEAR) | |
cb = GstController.DirectControlBinding.new(pad, 'alpha', cs) | |
pad.add_control_binding(cb) | |
return cs | |
GObject.threads_init() | |
Gst.init(sys.argv) | |
pipeline = Gst.parse_launch (""" | |
videomixer name="mix" ! autovideosink | |
videotestsrc pattern="green" ! video/x-raw,width=400,height=400 ! decodebin ! mix.sink_0 | |
videotestsrc pattern="black" ! video/x-raw,width=200,height=200 ! decodebin ! mix.sink_1 | |
""") | |
print([ pad.name for pad in pipeline.get_by_name('mix').pads ]) | |
green_sink = pipeline.get_by_name('mix').get_request_pad('sink_0') | |
black_sink = pipeline.get_by_name('mix').get_request_pad('sink_1') | |
print([ pad.name for pad in pipeline.get_by_name('mix').pads ]) | |
black_sink.set_property('xpos', 50) | |
black_sink.set_property('ypos', 50) | |
cs = get_alpha_controller(black_sink) | |
cs.set(1*Gst.SECOND, 1) | |
cs.set(4*Gst.SECOND, 0) | |
pipeline.set_state (Gst.State.PLAYING) | |
GLib.MainLoop.new(None, False).run() | |
start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment