Gstreamer Pipeline Dynamic Change Python

1.4k views Asked by At

I have been trying to dynamically change the gstreamer pipeline but it just stops the stream as soon as I change the state. What is it that I am doing wring here. Here is my code :

#!/usr/bin/python
import gobject
import time

gobject.threads_init()
import pygst

pygst.require("0.10")
import gst

p = gst.parse_launch("""filesrc location=/home/jango/Pictures/4.jpg name=src1 ! decodebin ! queue ! videoscale ! ffmpegcolorspace !
imagefreeze ! capsfilter name=vfps caps="video/x-raw-yuv, framerate=60/1, width=640, height=420" ! theoraenc ! oggmux name=mux ! filesink location=1.ogg""")

p.set_state(gst.STATE_PLAYING)
time.sleep(10)
print "State change"
p.set_state(gst.STATE_READY)
source = p.get_by_name("src1")
source.set_property("location", "/home/jango/Pictures/2.jpg")
p.set_state(gst.STATE_PLAYING)
gobject.MainLoop().run()

Please suggest me if there is any alternative methods or any tutorials which I can refer to. Thanks in advance.

1

There are 1 answers

2
Mathieu_Du On

using Gstreamer-Editing-Services might be an option, it will handle all the pipeline rewiring for you, with a higher level API than GStreamer.