How flvdemux and other plugins are linked together in Gstreamer?

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.

This is my gst command’s pipeline png. The flvdemux has “video” part


Why my code can’t gei it?Please help me .

I found this, i think maybe it’s the same problem.But it’s a long time away from now, can someone tell me how to do?

Hi,
You would need to link the pad dynamically as mentioned in this discussion thread:
c - Gstreamer:dynamically link realize - Stack Overflow

Suggest try it in C code first to have a working C sample, and then apply to python.

I only use python…I know the discussion says, but i don’t know how to apply to python.Any other example?

Hi,
Found a sample with qtdemux. Please take a look and give it a try:
python - Seamless video loop in gstreamer - Stack Overflow

THANKS!! Problem solved

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.