About dynamic link with a rtspsrc

Hi, I tried to use a CCTV cam with gstreamer recently. And I get a GST_PAD_LINK_NOFORMAT error when i tried to dynamically link a stream_%u pad to parse264 at the second time I created the same pipeline. Here is my python call-back function:

def video_newpad(src, pad, det)
    vdec_pad = det.get_static_pad("sink")
    pad.link(vpad)

Despite I still get frame data from pipeline, I still need to fix it. Before the program exit, I just called pipeline.set_state(Gst.State.NULL). I wonder if the resource was not released.

rtspsrc outputs data in form of RTP packets (application/x-rtp media type).

You need to first plug a depayloader such as e.g. rtph264depay which will re-assemble the RTP packets into H.264 video data. After that you can then plug h264parse and a decoder.

Hello, thanks for your suggestion. This dynamic link is established for rtspsrc and rtph264depay. Here is my pipeline building method:

def cb_video_newpad(src, pad, dst):
    print(pad.get_property("template").name_template)
    vdec_pad = dst.get_static_pad("sink")
    if not vdec_pad.is_linked():
    # new_caps = pad.get_current_caps()
    # new_pad_struct = new_caps.get_structure(0)
    # new_pad_type = new_pad_struct.get_name()
        pad.link(vdec_pad)

def create_nv_pipeline(name, rtsp_path,framedata):
    # create pipe
    # create elements
    pipe = Gst.Pipeline.new(name)
    src = Gst.ElementFactory.make("rtspsrc", "src")
    src.set_property("location", rtsp_path)
    #src.set_property("location", "rtsp://admin:Dh123456@192.168.1.108")
    src.set_property("latency", 50)

    parse264 = Gst.ElementFactory.make("rtph264depay", "parse264")
    decodebin = Gst.ElementFactory.make("nvv4l2decoder", "decodebin")
    conv = Gst.ElementFactory.make("nvvidconv", "conv")
    caps = Gst.caps_from_string("video/x-raw, format=(string)BGRx")
    filter = Gst.ElementFactory.make("capsfilter", "filter")
    filter.set_property("caps", caps)
    conv2 = Gst.ElementFactory.make("videoconvert", "conv2")
    sink = Gst.ElementFactory.make("appsink", "sink")

    # config the appsink
    sink.set_property("emit-signals", True)
    sink.connect("new-sample", new_buffer, framedata)

    # add elements
    pipe.add(src)
    pipe.add(parse264)
    pipe.add(decodebin)
    pipe.add(conv)
    pipe.add(filter)
    pipe.add(conv2)
    pipe.add(sink)

    # link elements
    src.connect("pad-added", cb_video_newpad, parse264)
    # src.connect("pad-added", cb_demuxer_newpad, parse264)
    parse264.link(decodebin)
    decodebin.link(conv)
    conv.link(filter)
    filter.link(conv2)
    conv2.link(sink)

    return pipe

Please forgive me, I haven’t mentioned it before.

How sure are you that the stream you’re linking is actually an H.264 RTP stream?

Does it work / link if you just have rtspsrc ! rtph264depay ! fakesink (or appsink without caps specified)?

You could check the GST_DEBUG=*:6 log to see what it shows during the linking (you can also enable the debug log programmatically just before you link and disable right after in order to only get the info you need).