Created
July 1, 2020 11:20
-
-
Save joshdoe/ec58aad8331a6c8e1194189d0d690e06 to your computer and use it in GitHub Desktop.
GStreamer Python example showing changing of videomixer position
This file contains hidden or 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
import os | |
import sys | |
import time | |
def _prepend_env_path(name, value): | |
os.environ[name] = os.pathsep.join(value + | |
os.environ.get(name, "").split(os.pathsep)) | |
CONFIGURED_GSTREAMER_PATH = r'C:\gstreamer\1.17\x86_64' | |
_prepend_env_path("PATH", [os.path.join(CONFIGURED_GSTREAMER_PATH, 'bin')]) | |
sys.path.insert(0, os.path.join(CONFIGURED_GSTREAMER_PATH, 'lib', 'python3.7', 'site-packages')) | |
import gi | |
gi.require_version('Gst', '1.0') | |
gi.require_version('GstVideo', '1.0') | |
from gi.repository import Gst | |
Gst.init(None) | |
desc = "videomixer name=mix sink_1::xpos=290 sink_1::ypos=10 ! videoconvert ! autovideosink sync=false " \ | |
"videotestsrc pattern=red ! video/x-raw,width=500,height=500 ! mix. " \ | |
"videotestsrc pattern=white ! video/x-raw,width=200,height=200 ! mix." | |
playbin = Gst.parse_launch(desc) | |
playbin.set_state(Gst.State.PLAYING) | |
mix = playbin.get_by_name('mix') | |
pad = mix.get_static_pad('sink_1') | |
time.sleep(1) | |
pad.set_property('xpos', 200) | |
time.sleep(1) | |
playbin.set_state(Gst.State.NULL) | |
Gst.deinit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment