Hello.I try to use Gstreamer in python. I just want the pipeline like RTMP source → flvdemux → fakesink.But it doesn’t work.
This is the output
Creating Pipeline
Creating Source And other
Adding elements to Pipeline
Linking elements in the Pipeline
Starting pipeline
0:00:03.159383897 16325 0x55af55fb20 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop:<rtmp-source> error: Internal data stream error.
0:00:03.159478234 16325 0x55af55fb20 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop:<rtmp-source> error: streaming stopped, reason not-linked (-1)
Error: gst-stream-error-quark: Internal data stream error. (1): gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTMPSrc:rtmp-source:
streaming stopped, reason not-linked (-1)
This my code
import sys
sys.path.append('../')
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from common.bus_call import bus_call
import os
os.environ["GST_DEBUG_DUMP_DOT_DIR"] = "/tmp"
os.putenv('GST_DEBUG_DUMP_DIR_DIR', '/tmp')
def main(args):
GObject.threads_init()
Gst.init(None)
print("Creating Pipeline \n ")
pipeline = Gst.Pipeline()
if not pipeline:
sys.stderr.write(" Unable to create Pipeline \n")
print("Creating Source And other \n ")
source = Gst.ElementFactory.make("rtmpsrc", "rtmp-source")
if not source:
sys.stderr.write(" Unable to create Source \n")
flvdemux1 = Gst.ElementFactory.make("flvdemux", "flv-demux")
if not flvdemux1:
sys.stderr.write(" Unable to create flvdemux \n")
fakesink = Gst.ElementFactory.make("fakesink", "fake-sink")
if not fakesink:
sys.stderr.write(" Unable to create fake sink \n")
source.set_property('location', 'rtmp://121.43.126.231:12966/live/28de595627d6d45cc11e4d17cbf021ee4c947bbb8ba8ddbc live=1')
print("Adding elements to Pipeline \n")
pipeline.add(source)
pipeline.add(flvdemux1)
pipeline.add(fakesink)
print("Linking elements in the Pipeline \n")
source.link(flvdemux1)
flvdemux1.link(fakesink)
# create an event loop and feed gstreamer bus mesages to it
loop = GObject.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)
Gst.debug_bin_to_dot_file(pipeline, Gst.DebugGraphDetails.ALL, "pipeline")
# start play back and listen to events
print("Starting pipeline \n")
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except:
pass
# cleanup
pipeline.set_state(Gst.State.NULL)
if __name__ == '__main__':
print(sys.argv)
sys.exit(main(sys.argv))
And my pipeline.png tell me that the flvdemux doesn’t link to fakesink.Please help me.