Hi everyone,
I try to receive the rtsp stream (a MJPEG stream), sent from an Elphel camera. I get no problems when using vlc or the gst-launch tool. The correct pipeline for gst-launch is: gst-launch rtspsrc location="rtsp://192.168.1.9:554" ! rtpjpegdepay ! jpegdec ! xvimagesink I tried to embed this pipeline in my own application, but somehow, I can't link the rtspsrc to another element. I tried to link it to an rtpjpegdepay element, a queue element, even a fakesink, but nothing works. My code looks sth like this: gst_init (&argc, &argv); GMainLoop *loop = g_main_loop_new(NULL, FALSE); GstElement *pipeline = gst_pipeline_new ("Windows Overlay Test"); GstElement *rtspsrc = gst_element_factory_make("rtspsrc", NULL); GstElement *rtpjpeg = gst_element_factory_make("rtpjpegdepay", NULL); GstElement *jpegdec = gst_element_factory_make("jpegdec", NULL); GstElement *fakesink = gst_element_factory_make("fakesink", NULL); if (!(rtspsrc && rtpjpeg && jpegdec && fakesink && queue1 && queue2 && queue3)) { qCritical() << "Elements could not be created!!!"; exit(-1); } g_object_set(G_OBJECT(rtspsrc), "location", "rtsp://192.168.1.9:554", NULL); g_object_set(G_OBJECT(fakesink), "dump", true, NULL); gst_bin_add_many (GST_BIN (pipeline), rtspsrc, rtpjpeg, jpegdec, fakesink, NULL); if (!gst_element_link(rtspsrc, fakesink)) { qCritical() << "RTSPSRC could not be linked!!!"; exit(-1); } The "gst_element_link(rtspsrc, fakesink)" always returns false. Here's the interesting part of the debug output (GST_DEBUG=4): 0:00:00.457158021 6075 0x1195730 DEBUG GST_PARENTAGE gstbin.c:1152:gst_bin_add_func:<Windows Overlay Test> added element "fakesink0" 0:00:00.457173107 6075 0x1195730 INFO GST_ELEMENT_PADS gstutils.c:1614:gst_element_link_pads_full: trying to link element rtspsrc0:(any) to element fakesink0:(any) 0:00:00.457184491 6075 0x1195730 DEBUG GST_ELEMENT_PADS gstutils.c:1755:gst_element_link_pads_full: trying dest pad fakesink0:sink 0:00:00.457193920 6075 0x1195730 DEBUG GST_ELEMENT_PADS gstutils.c:1115:gst_element_get_compatible_pad: finding pad in rtspsrc0 compatible with fakesink0:sink 0:00:00.457204536 6075 0x1195730 DEBUG GST_ELEMENT_PADS gstutils.c:1200:gst_element_get_compatible_pad:<rtspsrc0> Could not find a compatible unlinked always pad to link to fakesink0:sink, now checking request pads 0:00:00.457485856 6075 0x1195730 DEBUG GST_CAPS gstpad.c:2274:gst_pad_get_caps_reffed:<fakesink0:sink> get pad caps 0:00:00.457495564 6075 0x1195730 DEBUG GST_CAPS gstpad.c:2184:gst_pad_get_caps_unlocked:<fakesink0:sink> get pad caps 0:00:00.457504084 6075 0x1195730 DEBUG GST_CAPS gstpad.c:2188:gst_pad_get_caps_unlocked:<fakesink0:sink> dispatching to pad getcaps function 0:00:00.457518681 6075 0x1195730 DEBUG GST_CAPS gstpad.c:2201:gst_pad_get_caps_unlocked:<fakesink0:sink> pad getcaps returned ANY 0:00:00.457546268 6075 0x1195730 DEBUG GST_ELEMENT_PADS gstutils.c:889:gst_element_get_compatible_pad_template: Looking for a suitable pad template in rtspsrc0 out of 1 templates... 0:00:00.457557513 6075 0x1195730 DEBUG GST_CAPS gstutils.c:905:gst_element_get_compatible_pad_template: compatible direction: found src pad template "stream%d" 0:00:00.457566313 6075 0x1195730 DEBUG GST_CAPS gstutils.c:908:gst_element_get_compatible_pad_template: intersecting ANY 0:00:00.457575462 6075 0x1195730 DEBUG GST_CAPS gstutils.c:910:gst_element_get_compatible_pad_template: ..and application/x-rtp; application/x-rdt 0:00:00.457585659 6075 0x1195730 DEBUG GST_CAPS gstutils.c:916:gst_element_get_compatible_pad_template: caps are compatible 0:00:00.457593830 6075 0x1195730 DEBUG GST_ELEMENT_PADS gstutils.c:928:gst_element_get_compatible_pad_template: Returning new pad template 0x1556bb0 0:00:00.457602770 6075 0x1195730 INFO GST_ELEMENT_PADS gstelement.c:960:gst_element_get_static_pad: no such pad 'stream%d' in element "rtspsrc0" 0:00:00.457617018 6075 0x1195730 INFO GST_ELEMENT_PADS gstutils.c:1221:gst_element_get_compatible_pad:<rtspsrc0> Could not find a compatible pad to link to fakesink0:sink 0:00:00.457626795 6075 0x1195730 DEBUG GST_ELEMENT_PADS gstutils.c:1797:gst_element_link_pads_full: we might have request pads on both sides, checking... 0:00:00.457635944 6075 0x1195730 DEBUG GST_ELEMENT_PADS gstutils.c:1838:gst_element_link_pads_full: no link possible from rtspsrc0 to fakesink0 RTSPSRC could not be linked!!! Where's the problem? Thanks for your help! Hanno ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today http://p.sf.net/sfu/msIE9-sfdev2dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Hi,
Applications must listen "pad-added" signal fired from rtspsrc and link element in callback function. Here is an example for reference static void on_pad_added (GstElement *element, GstPad *pad, void *data) { GstElement *rtpjpeg = GST_ELEMENT (data); GstPad *sinkpad; sinkpad = gst_element_get_pad (rtpjpeg, "sink"); gst_pad_link (pad, sinkpad); gst_object_unref (sinkpad); } int main (int argc, char *argv[]) { GstElement *rtspsrc = gst_element_factory_make("rtspsrc", NULL); GstElement *rtpjpeg = gst_element_factory_make("rtpjpegdepay", NULL); // creats some other elements // adds elements to pipeline // links elements except rtspsrc g_signal_connect (rtspsrc , "pad-added", G_CALLBACK (on_pad_added), rtpjpeg); } 於 2010/11/21 上午 12:55, Hanno Jaspers 提到: > Hi everyone, > > I try to receive the rtsp stream (a MJPEG stream), sent from an Elphel > camera. I get no problems when using vlc or the gst-launch tool. The > correct pipeline for gst-launch is: gst-launch rtspsrc > location="rtsp://192.168.1.9:554" ! rtpjpegdepay ! jpegdec ! xvimagesink > > I tried to embed this pipeline in my own application, but somehow, I > can't link the rtspsrc to another element. I tried to link it to an > rtpjpegdepay element, a queue element, even a fakesink, but nothing > works. My code looks sth like this: > > gst_init (&argc,&argv); > GMainLoop *loop = g_main_loop_new(NULL, FALSE); > > GstElement *pipeline = gst_pipeline_new ("Windows Overlay Test"); > > GstElement *rtspsrc = gst_element_factory_make("rtspsrc", NULL); > GstElement *rtpjpeg = gst_element_factory_make("rtpjpegdepay", NULL); > GstElement *jpegdec = gst_element_factory_make("jpegdec", NULL); > GstElement *fakesink = gst_element_factory_make("fakesink", NULL); > > if (!(rtspsrc&& rtpjpeg&& jpegdec&& fakesink&& queue1&& queue2&& > queue3)) { > qCritical()<< "Elements could not be created!!!"; > exit(-1); > } > > g_object_set(G_OBJECT(rtspsrc), "location", "rtsp://192.168.1.9:554", > NULL); > g_object_set(G_OBJECT(fakesink), "dump", true, NULL); > > gst_bin_add_many (GST_BIN (pipeline), rtspsrc, rtpjpeg, jpegdec, > fakesink, NULL); > if (!gst_element_link(rtspsrc, fakesink)) { > qCritical()<< "RTSPSRC could not be linked!!!"; > exit(-1); > } > > The "gst_element_link(rtspsrc, fakesink)" always returns false. Here's > the interesting part of the debug output (GST_DEBUG=4): > 0:00:00.457158021 6075 0x1195730 DEBUG GST_PARENTAGE > gstbin.c:1152:gst_bin_add_func:<Windows Overlay Test> added element > "fakesink0" > 0:00:00.457173107 6075 0x1195730 INFO GST_ELEMENT_PADS > gstutils.c:1614:gst_element_link_pads_full: trying to link element > rtspsrc0:(any) to element fakesink0:(any) > 0:00:00.457184491 6075 0x1195730 DEBUG GST_ELEMENT_PADS > gstutils.c:1755:gst_element_link_pads_full: trying dest pad > fakesink0:sink > 0:00:00.457193920 6075 0x1195730 DEBUG GST_ELEMENT_PADS > gstutils.c:1115:gst_element_get_compatible_pad: finding pad in rtspsrc0 > compatible with fakesink0:sink > 0:00:00.457204536 6075 0x1195730 DEBUG GST_ELEMENT_PADS > gstutils.c:1200:gst_element_get_compatible_pad:<rtspsrc0> Could not find > a compatible unlinked always pad to link to fakesink0:sink, now checking > request pads > 0:00:00.457485856 6075 0x1195730 DEBUG GST_CAPS > gstpad.c:2274:gst_pad_get_caps_reffed:<fakesink0:sink> get pad caps > 0:00:00.457495564 6075 0x1195730 DEBUG GST_CAPS > gstpad.c:2184:gst_pad_get_caps_unlocked:<fakesink0:sink> get pad caps > 0:00:00.457504084 6075 0x1195730 DEBUG GST_CAPS > gstpad.c:2188:gst_pad_get_caps_unlocked:<fakesink0:sink> dispatching to > pad getcaps function > 0:00:00.457518681 6075 0x1195730 DEBUG GST_CAPS > gstpad.c:2201:gst_pad_get_caps_unlocked:<fakesink0:sink> pad getcaps > returned ANY > 0:00:00.457546268 6075 0x1195730 DEBUG GST_ELEMENT_PADS > gstutils.c:889:gst_element_get_compatible_pad_template: Looking for a > suitable pad template in rtspsrc0 out of 1 templates... > 0:00:00.457557513 6075 0x1195730 DEBUG GST_CAPS > gstutils.c:905:gst_element_get_compatible_pad_template: compatible > direction: found src pad template "stream%d" > 0:00:00.457566313 6075 0x1195730 DEBUG GST_CAPS > gstutils.c:908:gst_element_get_compatible_pad_template: intersecting ANY > 0:00:00.457575462 6075 0x1195730 DEBUG GST_CAPS > gstutils.c:910:gst_element_get_compatible_pad_template: ..and > application/x-rtp; application/x-rdt > 0:00:00.457585659 6075 0x1195730 DEBUG GST_CAPS > gstutils.c:916:gst_element_get_compatible_pad_template: caps are > compatible > 0:00:00.457593830 6075 0x1195730 DEBUG GST_ELEMENT_PADS > gstutils.c:928:gst_element_get_compatible_pad_template: Returning new > pad template 0x1556bb0 > 0:00:00.457602770 6075 0x1195730 INFO GST_ELEMENT_PADS > gstelement.c:960:gst_element_get_static_pad: no such pad 'stream%d' in > element "rtspsrc0" > 0:00:00.457617018 6075 0x1195730 INFO GST_ELEMENT_PADS > gstutils.c:1221:gst_element_get_compatible_pad:<rtspsrc0> Could not find > a compatible pad to link to fakesink0:sink > 0:00:00.457626795 6075 0x1195730 DEBUG GST_ELEMENT_PADS > gstutils.c:1797:gst_element_link_pads_full: we might have request pads > on both sides, checking... > 0:00:00.457635944 6075 0x1195730 DEBUG GST_ELEMENT_PADS > gstutils.c:1838:gst_element_link_pads_full: no link possible from > rtspsrc0 to fakesink0 > RTSPSRC could not be linked!!! > > Where's the problem? Thanks for your help! > Hanno > > > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today http://p.sf.net/sfu/msIE9-sfdev2dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Hi Bobby,
thank you very much! It works like a charm ;) > Hi, > > Applications must listen "pad-added" signal fired from rtspsrc and link > element in callback function. > > Here is an example for reference > > static void on_pad_added (GstElement *element, GstPad *pad, void *data) > { > GstElement *rtpjpeg = GST_ELEMENT (data); > GstPad *sinkpad; > > sinkpad = gst_element_get_pad (rtpjpeg, "sink"); > gst_pad_link (pad, sinkpad); > gst_object_unref (sinkpad); > } > > int main (int argc, char *argv[]) > { > GstElement *rtspsrc = gst_element_factory_make("rtspsrc", NULL); > GstElement *rtpjpeg = gst_element_factory_make("rtpjpegdepay", NULL); > // creats some other elements > // adds elements to pipeline > // links elements except rtspsrc > g_signal_connect (rtspsrc , "pad-added", G_CALLBACK (on_pad_added), > rtpjpeg); > } > > ? 2010/11/21 ?? 12:55, Hanno Jaspers ??: >> Hi everyone, >> >> I try to receive the rtsp stream (a MJPEG stream), sent from an Elphel >> camera. I get no problems when using vlc or the gst-launch tool. The >> correct pipeline for gst-launch is: gst-launch rtspsrc >> location="rtsp://192.168.1.9:554" ! rtpjpegdepay ! jpegdec ! xvimagesink >> >> I tried to embed this pipeline in my own application, but somehow, I >> can't link the rtspsrc to another element. I tried to link it to an >> rtpjpegdepay element, a queue element, even a fakesink, but nothing >> works. My code looks sth like this: >> >> gst_init (&argc,&argv); >> GMainLoop *loop = g_main_loop_new(NULL, FALSE); >> >> GstElement *pipeline = gst_pipeline_new ("Windows Overlay Test"); >> >> GstElement *rtspsrc = gst_element_factory_make("rtspsrc", NULL); >> GstElement *rtpjpeg = gst_element_factory_make("rtpjpegdepay", NULL); >> GstElement *jpegdec = gst_element_factory_make("jpegdec", NULL); >> GstElement *fakesink = gst_element_factory_make("fakesink", NULL); >> >> if (!(rtspsrc&& rtpjpeg&& jpegdec&& fakesink&& queue1&& queue2&& >> queue3)) { >> qCritical()<< "Elements could not be created!!!"; >> exit(-1); >> } >> >> g_object_set(G_OBJECT(rtspsrc), "location", "rtsp://192.168.1.9:554", >> NULL); >> g_object_set(G_OBJECT(fakesink), "dump", true, NULL); >> >> gst_bin_add_many (GST_BIN (pipeline), rtspsrc, rtpjpeg, jpegdec, >> fakesink, NULL); >> if (!gst_element_link(rtspsrc, fakesink)) { >> qCritical()<< "RTSPSRC could not be linked!!!"; >> exit(-1); >> } >> >> The "gst_element_link(rtspsrc, fakesink)" always returns false. Here's >> the interesting part of the debug output (GST_DEBUG=4): >> 0:00:00.457158021 6075 0x1195730 DEBUG GST_PARENTAGE >> gstbin.c:1152:gst_bin_add_func:<Windows Overlay Test> added element >> "fakesink0" >> 0:00:00.457173107 6075 0x1195730 INFO GST_ELEMENT_PADS >> gstutils.c:1614:gst_element_link_pads_full: trying to link element >> rtspsrc0:(any) to element fakesink0:(any) >> 0:00:00.457184491 6075 0x1195730 DEBUG GST_ELEMENT_PADS >> gstutils.c:1755:gst_element_link_pads_full: trying dest pad >> fakesink0:sink >> 0:00:00.457193920 6075 0x1195730 DEBUG GST_ELEMENT_PADS >> gstutils.c:1115:gst_element_get_compatible_pad: finding pad in rtspsrc0 >> compatible with fakesink0:sink >> 0:00:00.457204536 6075 0x1195730 DEBUG GST_ELEMENT_PADS >> gstutils.c:1200:gst_element_get_compatible_pad:<rtspsrc0> Could not >> find >> a compatible unlinked always pad to link to fakesink0:sink, now checking >> request pads >> 0:00:00.457485856 6075 0x1195730 DEBUG GST_CAPS >> gstpad.c:2274:gst_pad_get_caps_reffed:<fakesink0:sink> get pad caps >> 0:00:00.457495564 6075 0x1195730 DEBUG GST_CAPS >> gstpad.c:2184:gst_pad_get_caps_unlocked:<fakesink0:sink> get pad caps >> 0:00:00.457504084 6075 0x1195730 DEBUG GST_CAPS >> gstpad.c:2188:gst_pad_get_caps_unlocked:<fakesink0:sink> dispatching to >> pad getcaps function >> 0:00:00.457518681 6075 0x1195730 DEBUG GST_CAPS >> gstpad.c:2201:gst_pad_get_caps_unlocked:<fakesink0:sink> pad getcaps >> returned ANY >> 0:00:00.457546268 6075 0x1195730 DEBUG GST_ELEMENT_PADS >> gstutils.c:889:gst_element_get_compatible_pad_template: Looking for a >> suitable pad template in rtspsrc0 out of 1 templates... >> 0:00:00.457557513 6075 0x1195730 DEBUG GST_CAPS >> gstutils.c:905:gst_element_get_compatible_pad_template: compatible >> direction: found src pad template "stream%d" >> 0:00:00.457566313 6075 0x1195730 DEBUG GST_CAPS >> gstutils.c:908:gst_element_get_compatible_pad_template: intersecting ANY >> 0:00:00.457575462 6075 0x1195730 DEBUG GST_CAPS >> gstutils.c:910:gst_element_get_compatible_pad_template: ..and >> application/x-rtp; application/x-rdt >> 0:00:00.457585659 6075 0x1195730 DEBUG GST_CAPS >> gstutils.c:916:gst_element_get_compatible_pad_template: caps are >> compatible >> 0:00:00.457593830 6075 0x1195730 DEBUG GST_ELEMENT_PADS >> gstutils.c:928:gst_element_get_compatible_pad_template: Returning new >> pad template 0x1556bb0 >> 0:00:00.457602770 6075 0x1195730 INFO GST_ELEMENT_PADS >> gstelement.c:960:gst_element_get_static_pad: no such pad 'stream%d' in >> element "rtspsrc0" >> 0:00:00.457617018 6075 0x1195730 INFO GST_ELEMENT_PADS >> gstutils.c:1221:gst_element_get_compatible_pad:<rtspsrc0> Could not >> find >> a compatible pad to link to fakesink0:sink >> 0:00:00.457626795 6075 0x1195730 DEBUG GST_ELEMENT_PADS >> gstutils.c:1797:gst_element_link_pads_full: we might have request pads >> on both sides, checking... >> 0:00:00.457635944 6075 0x1195730 DEBUG GST_ELEMENT_PADS >> gstutils.c:1838:gst_element_link_pads_full: no link possible from >> rtspsrc0 to fakesink0 >> RTSPSRC could not be linked!!! >> >> Where's the problem? Thanks for your help! >> Hanno >> >> >> >> ------------------------------------------------------------------------------ >> Beautiful is writing same markup. Internet Explorer 9 supports >> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3. >> Spend less time writing and rewriting code and more time creating great >> experiences on the web. Be a part of the beta today >> http://p.sf.net/sfu/msIE9-sfdev2dev >> _______________________________________________ >> gstreamer-devel mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel > > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel > ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today http://p.sf.net/sfu/msIE9-sfdev2dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
This post was updated on .
Facing the same issue but in python.
I also have kind of the same problem here. I am replicating the function of element uridecodebin to my own custom nbin which can work with MJPEG RTSP stream. For that I am using rtspsrc and rtpjpegdepay inside the custom bin and linking them when rtspsrc received the pad added signal. Yet, I cannot link them with element_src_pad.link(peer_element_sink_pad) both of which having the same capabilities of pads as seen using gst-inspect-1.0 rtspsrc and get-inspect-1.0 rtpjpegdepay. Unable to link elements(rtspsrc -> rtpjpegdepay) from child_added signal callback I'm trying to get an MJPEG encoded RTSP stream from Mobotix brand camera using python script and gstreamer. 1st Try: Tried using **uridecodebin** ! **autovideosink** but gave internal data **stream error** for mjpeg format. 2nd Try: Tried to lookup what elements are used for jpeg decoding (nvjpegdecoder). Also tried to set **property** "**DeepStream**" to **True** in nvjpegdec element but still not worked. 3rd Try: Created a **custom bin** with elements to support jpeg stream over RTSP sources. The cutom bin ghost src pad is also set to target src pad of nvvidconv element when the bin is created. The pipeline consists a custom bin (just like **uridecodebin**, that has **rtspsrc** ! **rtpjpegdepay** ! **jpegdec** ! **nvvidconv**) and **autovideosink**. My main aim is to stream an RTSP stream encoded in MJPEG format. I also verified the rtspsrc has src template that has capability of application/rtp as well as rtpjpegday has the sink pad's capability as application/rtp using gst-inspect-1.0 <element_name> command. So technically it should work but still the linking fails. rtspsrc : Receive data over the network via RTSP src : application/x-rtp application/x-rdt rtpjpegdepay: Extracts JPEG video from RTP packets (RFC 2435) sink : application/x-rtp src : image/jpeg I've also added the pad_added signal handler for **rtspsrc** and tried to link **rtspsrc** and **rtpjpegdepay** src and sink pads in the callback function but it fails somehow. Note: I've also tried to run the pipeline from the command line and it successfully shows the video stream, but linking always fails in python code. gst-launch-1.0 **rtspsrc** location=$RTSP_PATH ! **rtpjpegdepay** ! **jpegdec** ! **nvvidconv** ! **autovideosink** Here is a snippet of main function def main(args): if len(args) < 2: # Check the command if camera information given or not. sys.stderr.write("usage: %s <uri1> [uri2] ... [uriN]\n" % args[0]) sys.exit(1) for i in range(0,len(args)-1): fps_streams["stream{0}".format(i)]=GETFPS(i) number_sources=len(args)-1 # Standard GStreamer initialization GObject.threads_init() # Create thread for GObject Gst.init(None) # Create Pipeline element that will form a connection of other elements pipeline = Gst.Pipeline() is_live = False if not pipeline: sys.stderr.write(" Unable to create Pipeline \n") # Create nvstreammux instance to form batches from one or more sources. streammux = Gst.ElementFactory.make("nvstreammux", "Stream-muxer") # stream mux use to display videos in one display. If we have 4 video then it divide's 1 screen for 4 videos. if not streammux: sys.stderr.write(" Unable to create NvStreamMux \n") pipeline.add(streammux) for i in range(number_sources): # check how many cameras are connected uri_name=args[i+1] if uri_name.find("rtsp://") == 0 : # check if the streaming is RTSP link is_live = True source_bin=make_video_source(i,uri_name) if not source_bin: sys.stderr.write("Unable to create source bin \n") pipeline.add(source_bin) padname="sink_%u" %i sinkpad= streammux.get_request_pad(padname) # set windows according to camera if not sinkpad: sys.stderr.write("Unable to create sink pad bin \n") srcpad=source_bin.get_static_pad("src") if not srcpad: sys.stderr.write("Unable to create src pad bin \n") srcpad.link(sinkpad) . . . Custom Bin Video source def make_video_source(i, uri): dict_data = {} bin_name="source-bin-%02d" %i nbin = None nbin = Gst.Bin.new(bin_name) ### Create elements source = Gst.ElementFactory.make("rtspsrc", f'source_{i}') depay = Gst.ElementFactory.make("rtpjpegdepay", f'depay_{i}') decoder = Gst.ElementFactory.make("jpegdec", f'decode_{i}') conv = Gst.ElementFactory.make("nvvidconv", f'nvvidconv_{i}') ### set properties source.set_property("location", uri) ### Add elements to Gst Bin Gst.Bin.add(nbin, source) Gst.Bin.add(nbin, depay) Gst.Bin.add(nbin, decoder) Gst.Bin.add(nbin, conv) ### link elements depay.link(decoder) decoder.link(conv) # dict_data['queue'] = queue # dict_data['capsfilter'] = capsfilter dict_data['rtpjitterbuffer'] = rtpjitterbuffer dict_data['nbin'] = nbin # dict_data['typefind'] = typefind dict_data['source'] = source dict_data['depay'] = depay dict_data['decoder'] = decoder dict_data['conv'] = conv ### Add signal handler source.connect("pad-added", on_new_pad_added, dict_data) # Add ghost source pad to nbin conv_src_pad = conv.get_static_pad("src") bin_ghost_pad_ret = nbin.add_pad(Gst.GhostPad.new("src", conv_src_pad)) if not bin_ghost_pad_ret: print(f'Failed to add ghost and link pad in source bin') return None else: bin_ghost_src_pad = nbin.get_static_pad("src") print(f'bin_ghost_src_pad: {bin_ghost_src_pad}') print(f'bin_ghost_src_pad name : {bin_ghost_src_pad.get_name()}') print(f'Created src ghost pad and linked to : conv src pad, {conv_src_pad}') if (not bin_ghost_src_pad): print("Failed to get recently added src ghost pad src of bin. Exiting.\n") return None # release the src (conv_src_pad).unref() # GST_OBJECT/GObject might cause error return nbin New Pad added signal handler def on_new_pad_added(element, new_pad, dict_data): peer_sink_element = dict_data['depay'] peer_sink_pad = peer_sink_element.get_static_pad("sink") if(peer_sink_pad.is_linked()): print("peer_sink_element is already linked. Ignoring.\n") return else: print("peer_sink_element is not linked already. Continuing linking.\n") print('\n\n\n') print(f'---------------- new padd added ----------------') print(f'\nInfo') print(f'source element name - {element.get_name()}') print(f'source : {element}') print(f'\nInfo: peer element') print(f'peer_sink_element name : {peer_sink_element.get_name()}') print(f'peer_sink_element : {peer_sink_element}') print(f'\nInfo: incomming pad') print(f'new src pad name: {new_pad.get_name()}') # check pad type/name if(new_pad_type.find("application/x-rtp")!=-1): print(f'found application/x-rtp in caps') if not new_pad.is_linked(): # if the other pad is linked anywhere, unlink it. if peer_sink_pad.is_linked(): print(f'Peer sink pad is linked. Not Linking...') peer_sink_pad.get_peer().unlink(peer_sink_pad) else: print(f'Peer sink pad is also not linked. Linking...') # try to link the pad if not new_pad.link(peer_sink_pad): print(f'Failed to link decoder src pad to source bin ghost pad') Log ---------------- rtspsrc new padd added ---------------- Info: source element name - source_0 source : <__gi__.GstRTSPSrc object at 0x7f882e5c18 (GstRTSPSrc at 0xaa3e5d0)> Info: peer element peer_sink_element element name : depay_0 peer_sink_element : <__gi__.GstRtpJPEGSrc object at 0x7f88280678 (GstQueue at 0xb6540d0)> Info: incomming pad new src pad name : recv_rtp_src_0_1697348806_26 found rtp in caps 0:02:44.151083610 16703 0xaabb0a0 INFO GST_PADS gstpad.c:2378:gst_pad_link_prepare: trying to link source_0:recv_rtp_src_0_1697348806_26 and queue_0:sink 0:02:44.151197361 16703 0xaabb0a0 INFO GST_PADS gstpad.c:2586:gst_pad_link_full: linked source_0:recv_rtp_src_0_1697348806_26 and queue_0:sink, successful 0:02:44.151224757 16703 0xaabb0a0 INFO GST_EVENT gstevent.c:1517:gst_event_new_reconfigure: creating reconfigure event Failed to link decoder src pad to source bin ghost pad Is there any way to know what's wrong with linking pads here? |
Free forum by Nabble | Edit this page |