gst-interpipe
gst-interpipe copied to clipboard
Switching between sources not working with Python.
I have this test code.
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst, GLib
from threading import Thread
Gst.init(None)
main_loop = GLib.MainLoop()
thread = Thread(target=main_loop.run)
pipeline = Gst.Pipeline()
image1 = Gst.parse_launch("videotestsrc ! interpipesink name=src1")
image2 = Gst.parse_launch("videotestsrc pattern=snow ! interpipesink name=src2")
source = Gst.ElementFactory.make("interpipesrc", "source")
source.set_property("listen-to", "src1")
play = Gst.ElementFactory.make("autovideosink", "play")
pipeline.add(source, play)
source.link(play)
image1.set_state(Gst.State.PLAYING)
image2.set_state(Gst.State.PLAYING)
pipeline.set_state(Gst.State.PLAYING)
print(source.get_property("listen-to"))
input()
source.set_property("listen-to", "src2")
input()
image1.set_state(Gst.State.NULL)
image2.set_state(Gst.State.NULL)
pipeline.set_state(Gst.State.NULL)
main_loop.quit()
But when running it, the frame doesn't change when I enter input. But if I change the state to READY then back to PLAYING, it works, but I don't want to this because it doesn't have the intended behavior for my program. Is there a way to fix this? Is python not support? Is autovideosink
not the right way to play the video?
Thanks