Segfault when setting host and port on gstreamer's udpsink

I am attempting to get a test pipeline. I want to see if I can get an appsrc to take solid colour panes and stream them, from the jetson, to my laptop, using RTP. However, when I try to set host and port on the udpsink, my program crashes.

The snippet which causes the crash is here:

  g_object_set(G_OBJECT(app->udpsink),
               "host", G_TYPE_STRING, "192.168.1.176",
               "port", G_TYPE_INT, 5000,
               nullptr);

Code to demonstrate the issue:

typedef struct {
  GstPipeline *pipeline;
  GstElement  *src, *convert, *encode, *pay, *udpsink;
  GMainLoop *loop;
  guint sourceid;
  FILE *file;
}gst_app_t;

int main()
{
  gst_app_t* app = new gst_app_t();
  GstBus *bus;
  GstStateChangeReturn state_ret;

  gst_init(nullptr, nullptr);

  app->src        = gst_element_factory_make("appsrc", "appsrc");
  app->convert    = gst_element_factory_make("nvvidconv", "nvvidconv");
  app->encode     = gst_element_factory_make("nvv4l2h264enc", "nvv4l2h264enc");
  app->pay        = gst_element_factory_make("rtph264pay", "rtph264pay");
  app->udpsink    = gst_element_factory_make("udpsink", "udpsink");

  assert(app->src);
  assert(app->convert);
  assert(app->encode);
  assert(app->pay);
  assert(app->udpsink);

  cerr << "yay!\n";
  
  g_object_set (G_OBJECT (app->src),
                "caps", gst_caps_new_simple ("video/x-raw",
                                             "format", G_TYPE_STRING, "RGB",
                                             "width", G_TYPE_INT, WIDTH,
                                             "height", G_TYPE_INT, HEIGHT,
                                             "framerate", GST_TYPE_FRACTION, 0, 1,
                                             nullptr),
                "stream-type", 0, // GST_APP_STREAM_TYPE_STREAM
                "format", GST_FORMAT_TIME,
                "is-live", TRUE,
                nullptr);

   cerr << "appsrc config done\n";

   g_object_set(G_OBJECT(app->pay),
               "name", G_TYPE_STRING, "pay0",
               "pt", G_TYPE_INT, 96,
               nullptr); 

  cerr << "payload config done \n";

  g_object_set(G_OBJECT(app->udpsink),
               "port", G_TYPE_INT, 5000,
               "host", "192.168.1.176",
               nullptr);


  cerr << "udpsink config done\n";
  cerr << "config done\n";
}

When the program runs with GST_DEBUG=4 this is the output:

0:00:00.000113961 18425   0x55b3cd0a00 INFO                GST_INIT gst.c:586:init_pre: Initializing GStreamer Core Library version 1.14.5
0:00:00.000185213 18425   0x55b3cd0a00 INFO                GST_INIT gst.c:587:init_pre: Using library installed in /usr/lib/aarch64-linux-gnu
0:00:00.000223131 18425   0x55b3cd0a00 INFO                GST_INIT gst.c:607:init_pre: Linux desktop 4.9.201-tegra #1 SMP PREEMPT Wed May 5 09:31:36 PDT 2021 aarch64
0:00:00.000697935 18425   0x55b3cd0a00 INFO                GST_INIT gstmessage.c:127:_priv_gst_message_initialize: init messages
0:00:00.001790879 18425   0x55b3cd0a00 INFO                GST_INIT gstcontext.c:84:_priv_gst_context_initialize: init contexts
0:00:00.002225422 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:317:_priv_gst_plugin_initialize: registering 0 static plugins
0:00:00.002460844 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:225:gst_plugin_register_static: registered static plugin "staticelements"
0:00:00.002497512 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:227:gst_plugin_register_static: added static plugin "staticelements", result: 1
0:00:00.002545690 18425   0x55b3cd0a00 INFO            GST_REGISTRY gstregistry.c:1727:ensure_current_registry: reading registry cache: ~/.cache/gstreamer-1.0/registry.aarch64.bin
0:00:00.041980864 18425   0x55b3cd0a00 INFO            GST_REGISTRY gstregistrybinary.c:621:priv_gst_registry_binary_read_cache: loaded ~/.cache/gstreamer-1.0/registry.aarch64.bin in 0.039374 seconds
0:00:00.042121337 18425   0x55b3cd0a00 INFO            GST_REGISTRY gstregistry.c:1583:scan_and_update_registry: Validating plugins from registry cache: ~/.cache/gstreamer-1.0/registry.aarch64.bin
0:00:00.047360846 18425   0x55b3cd0a00 INFO            GST_REGISTRY gstregistry.c:1685:scan_and_update_registry: Registry cache has not changed
0:00:00.047399336 18425   0x55b3cd0a00 INFO            GST_REGISTRY gstregistry.c:1762:ensure_current_registry: registry reading and updating done, result = 1
0:00:00.047422514 18425   0x55b3cd0a00 INFO                GST_INIT gst.c:807:init_post: GLib runtime version: 2.56.4
0:00:00.047444442 18425   0x55b3cd0a00 INFO                GST_INIT gst.c:809:init_post: GLib headers version: 2.56.4
0:00:00.047461004 18425   0x55b3cd0a00 INFO                GST_INIT gst.c:810:init_post: initialized GStreamer successfully
0:00:00.047973778 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstapp.so" loaded
0:00:00.048009560 18425   0x55b3cd0a00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "appsrc" named "appsrc"
0:00:00.048414571 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseSrc@0x55b3f101d0> adding pad 'src'
0:00:00.079080146 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvidconv.so" loaded
0:00:00.079136814 18425   0x55b3cd0a00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "nvvidconv" named "nvvidconv"
0:00:00.079500573 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseTransform@0x55b3d99cd0> adding pad 'sink'
0:00:00.079556512 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseTransform@0x55b3d99cd0> adding pad 'src'
0:00:00.082245747 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so" loaded
0:00:00.082293822 18425   0x55b3cd0a00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "nvv4l2h264enc" named "nvv4l2h264enc"
0:00:00.082677477 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstVideoEncoder@0x55b3f5a4f0> adding pad 'sink'
0:00:00.082773209 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstVideoEncoder@0x55b3f5a4f0> adding pad 'src'
0:00:00.086190692 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtp.so" loaded
0:00:00.086241370 18425   0x55b3cd0a00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "rtph264pay" named "rtph264pay"
0:00:00.086497106 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstRTPBasePayload@0x55b3f6a1c0> adding pad 'src'
0:00:00.086546430 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstRTPBasePayload@0x55b3f6a1c0> adding pad 'sink'
0:00:00.090331266 18425   0x55b3cd0a00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstudp.so" loaded
0:00:00.090377049 18425   0x55b3cd0a00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "udpsink" named "udpsink"
0:00:00.090915500 18425   0x55b3cd0a00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseSink@0x55b3f74a00> adding pad 'sink'
yay!
appsrc config done
Segmentation fault (core dumped)

Not sure at all, but your snippet code lacks the type argument for host property of udpsink, while your post has it.
Is it the same with it ?

Sorry - I’ve run both versions and it makes no change.

Not sure framerate 0/1 is suitable for this. Have you tried another one that your appsrc could provide ?

With GST_DEBUG=5 I get the following:

...
0:00:00.723322785 18715   0x55861dba00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseSink@0x5586483600> adding pad 'sink'
0:00:00.723343046 18715   0x55861dba00 DEBUG        GST_REFCOUNTING gstobject.c:675:gst_object_set_parent:<'':sink> set parent (ref and sink)
0:00:00.723424350 18715   0x55861dba00 DEBUG           multiudpsink gstmultiudpsink.c:1596:gst_multiudpsink_add_internal:<GstUDPSink@0x5586483600> adding client on host localhost, port 5004
0:00:00.724706726 18715   0x55861dba00 DEBUG           multiudpsink gstmultiudpsink.c:467:gst_udp_client_new:<GstUDPSink@0x5586483600> IP address for host localhost is 127.0.0.1
0:00:00.724759332 18715   0x55861dba00 DEBUG           multiudpsink gstmultiudpsink.c:1631:gst_multiudpsink_add_internal:<GstUDPSink@0x5586483600> add client with host localhost, port 5004
0:00:00.724786728 18715   0x55861dba00 DEBUG           multiudpsink gstmultiudpsink.c:1657:gst_multiudpsink_add_internal:<GstUDPSink@0x5586483600> added client on host localhost, port 5004
0:00:00.724818188 18715   0x55861dba00 DEBUG    GST_ELEMENT_FACTORY gstelementfactory.c:389:gst_element_factory_create: created element "udpsink"
yay!
0:00:00.724934597 18715   0x55861dba00 DEBUG        GST_PERFORMANCE gstcaps.c:179:_gst_caps_copy:video/x-raw, format=(string)RGB, width=(int)384, height=(int)288, framerate=(fraction)0/1 doing copy 0x5586463de0 -> 0x5586463e30
0:00:00.725011213 18715   0x55861dba00 DEBUG                 appsrc gstappsrc.c:1344:gst_app_src_set_caps:<appsrc> setting caps to video/x-raw, format=(string)RGB, width=(int)384, height=(int)288, framerate=(fraction)0/1
0:00:00.725051735 18715   0x55861dba00 DEBUG                 appsrc gstappsrc.c:1509:gst_app_src_set_stream_type:<appsrc> setting stream_type of 0
appsrc config done
Segmentation fault (core dumped)

This leads me to believe you’re right in thinking I’ve messed up the appsrc configuration. I just tried 24/1 and saw no change. That appsrc setup worked on my linux, intel machine.

(aside: the program crashes far earlier when running with gdb so can’t seem to use that to debug)

Does changing appsrc with videotestsrc instead works ? This may help to find out where is the issue.

Still crashes

New code:

int main()
{
  gst_app_t* app = new gst_app_t();
  GstBus *bus;
  GstStateChangeReturn state_ret;

  gst_init(nullptr, nullptr);

  app->src        = gst_element_factory_make("videotestsrc", "appsrc");
  app->convert    = gst_element_factory_make("nvvidconv", "nvvidconv");
  app->encode     = gst_element_factory_make("nvv4l2h264enc", "nvv4l2h264enc");
  app->pay        = gst_element_factory_make("rtph264pay", "rtph264pay");
  app->udpsink    = gst_element_factory_make("udpsink", "udpsink");

  assert(app->src);
  assert(app->convert);
  assert(app->encode);
  assert(app->pay);
  assert(app->udpsink);

  cerr << "yay!\n";

//   g_object_set (G_OBJECT (app->src),
//                 "caps", gst_caps_new_simple ("video/x-raw",
//                                              "format", G_TYPE_STRING, "RGB",
//                                              "width", G_TYPE_INT, WIDTH,
//                                              "height", G_TYPE_INT, HEIGHT,
//                                              "framerate", GST_TYPE_FRACTION, 24, 1,
//                                              nullptr),
//                 "stream-type", 0, // GST_APP_STREAM_TYPE_STREAM
//                 "format", GST_FORMAT_TIME,
//                 "is-live", TRUE,
//                 nullptr);

   cerr << "appsrc config done\n";

  g_object_set(G_OBJECT(app->udpsink),
               "host", G_TYPE_STRING, "192.168.1.176",
               nullptr);

  cerr << "udpsink host set\n";

  g_object_set(G_OBJECT(app->udpsink),
               "port", G_TYPE_INT, 5000,
               nullptr);

  cerr << "udpsink config done\n";
  cerr << "config done\n";

New debug output:

...
0:00:00.533839609 18968   0x55775c8800 DEBUG     GST_PLUGIN_LOADING gstpluginfeature.c:107:gst_plugin_feature_load: loading plugin for feature 0x55777a8dd0; 'udpsink'
0:00:00.533859297 18968   0x55775c8800 DEBUG     GST_PLUGIN_LOADING gstpluginfeature.c:111:gst_plugin_feature_load: loading plugin udp
0:00:00.533877891 18968   0x55775c8800 DEBUG     GST_PLUGIN_LOADING gstplugin.c:1321:gst_plugin_load_by_name: looking up plugin udp in default registry
0:00:00.533984977 18968   0x55775c8800 DEBUG     GST_PLUGIN_LOADING gstplugin.c:1324:gst_plugin_load_by_name: loading plugin udp from file /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstudp.so
0:00:00.534009249 18968   0x55775c8800 DEBUG     GST_PLUGIN_LOADING gstplugin.c:760:_priv_gst_plugin_load_file_for_registry: attempt to load plugin "/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstudp.so"
0:00:00.537005523 18968   0x55775c8800 DEBUG               GST_META gstmeta.c:88:gst_meta_api_type_register: register API "GstNetAddressMetaAPI"
0:00:00.537056983 18968   0x55775c8800 DEBUG               GST_META gstmeta.c:95:gst_meta_api_type_register:   adding tag "origin"
0:00:00.537095525 18968   0x55775c8800 DEBUG               GST_META gstmeta.c:198:gst_meta_register: register "GstNetAddressMeta" implementing "GstNetAddressMetaAPI" of size 24
0:00:00.537157141 18968   0x55775c8800 DEBUG    GST_ELEMENT_FACTORY gstelementfactory.c:224:gst_element_register:<registry0> update existing feature 0x55777a8dd0 (udpsink)
0:00:00.537188028 18968   0x55775c8800 DEBUG    GST_ELEMENT_FACTORY gstelementfactory.c:224:gst_element_register:<registry0> update existing feature 0x55777a8eb0 (multiudpsink)
0:00:00.537236519 18968   0x55775c8800 DEBUG    GST_ELEMENT_FACTORY gstelementfactory.c:224:gst_element_register:<registry0> update existing feature 0x55777aa830 (dynudpsink)
0:00:00.537306156 18968   0x55775c8800 DEBUG    GST_ELEMENT_FACTORY gstelementfactory.c:224:gst_element_register:<registry0> update existing feature 0x55777aa910 (udpsrc)
0:00:00.537339282 18968   0x55775c8800 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstudp.so" loaded
0:00:00.537358188 18968   0x55775c8800 DEBUG     GST_PLUGIN_LOADING gstpluginfeature.c:116:gst_plugin_feature_load: loaded plugin udp
0:00:00.537382043 18968   0x55775c8800 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "udpsink" named "udpsink"
0:00:00.537412200 18968   0x55775c8800 DEBUG       GST_ELEMENT_PADS gstelement.c:302:gst_element_base_class_init: type GstBaseSink : factory (nil)
0:00:00.537522255 18968   0x55775c8800 DEBUG       GST_ELEMENT_PADS gstelement.c:302:gst_element_base_class_init: type GstMultiUDPSink : factory 0x55777a8eb0
0:00:00.537858097 18968   0x55775c8800 DEBUG       GST_ELEMENT_PADS gstelement.c:302:gst_element_base_class_init: type GstUDPSink : factory 0x55777a8dd0
0:00:00.537941849 18968   0x55775c8800 DEBUG               GST_PADS gstpad.c:1736:gst_pad_set_activate_function_full:<'':sink> activatefunc set to gst_base_sink_pad_activate
0:00:00.537967735 18968   0x55775c8800 DEBUG               GST_PADS gstpad.c:1771:gst_pad_set_activatemode_function_full:<'':sink> activatemodefunc set to gst_base_sink_pad_activate_mode
0:00:00.537991382 18968   0x55775c8800 DEBUG               GST_PADS gstpad.c:1992:gst_pad_set_query_function_full:<'':sink> queryfunc set to gst_base_sink_sink_query
0:00:00.538012476 18968   0x55775c8800 DEBUG               GST_PADS gstpad.c:1912:gst_pad_set_event_function_full:<'':sink> eventfunc for set to gst_base_sink_event
0:00:00.538033674 18968   0x55775c8800 DEBUG               GST_PADS gstpad.c:1806:gst_pad_set_chain_function_full:<'':sink> chainfunc set to gst_base_sink_chain
0:00:00.538054196 18968   0x55775c8800 DEBUG               GST_PADS gstpad.c:1843:gst_pad_set_chain_list_function_full:<'':sink> chainlistfunc set to gst_base_sink_chain_list
0:00:00.538075863 18968   0x55775c8800 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseSink@0x5577872a60> adding pad 'sink'
0:00:00.538091801 18968   0x55775c8800 DEBUG        GST_REFCOUNTING gstobject.c:675:gst_object_set_parent:<'':sink> set parent (ref and sink)
0:00:00.538158573 18968   0x55775c8800 DEBUG           multiudpsink gstmultiudpsink.c:1596:gst_multiudpsink_add_internal:<GstUDPSink@0x5577872a60> adding client on host localhost, port 5004
0:00:00.539360687 18968   0x55775c8800 DEBUG           multiudpsink gstmultiudpsink.c:467:gst_udp_client_new:<GstUDPSink@0x5577872a60> IP address for host localhost is 127.0.0.1
0:00:00.539411314 18968   0x55775c8800 DEBUG           multiudpsink gstmultiudpsink.c:1631:gst_multiudpsink_add_internal:<GstUDPSink@0x5577872a60> add client with host localhost, port 5004
0:00:00.539438346 18968   0x55775c8800 DEBUG           multiudpsink gstmultiudpsink.c:1657:gst_multiudpsink_add_internal:<GstUDPSink@0x5577872a60> added client on host localhost, port 5004
0:00:00.539469075 18968   0x55775c8800 DEBUG    GST_ELEMENT_FACTORY gstelementfactory.c:389:gst_element_factory_create: created element "udpsink"
yay!
appsrc config done
Segmentation fault (core dumped)

Does the following pipeline works with your system?

gst-launch-1.0 -v videotestsrc ! nvvidconv ! nvv4l2h264enc insert-sps-pps=1 insert-vui=1 ! rtph264pay ! udpsink host=127.0.0.1 port=5000

You would receive on jetson with:

gst-launch-1.0 -e udpsrc port=5000 ! application/x-rtp, media=video, encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! xvimagesink

may take 10s to display.

If yes, you may try using GstParse to programatically do the same and then move forward with your appsrc.

No crashes, I’m running headless so can’t verify that the image is correct but I get the following output from:

sender:

t-sps-pps=1 insert-vui=1 ! rtph264pay ! udpsink host=127.0.0.1 port=5000
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE
Opening in BLOCKING MODE 
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/Gstnvvconv:nvvconv0.GstPad:src: caps = video/x-raw(memory:NVMM), width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, format=(string)I420, multiview-mode=(string)mono, interlace-mode=(string)progressive
/GstPipeline:pipeline0/nvv4l2h264enc:nvv4l2h264enc0.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)NULL, level=(string)NULL, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, chroma-site=(string)jpeg, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)NULL, level=(string)NULL, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, chroma-site=(string)jpeg, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono
Redistribute latency...
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
/GstPipeline:pipeline0/nvv4l2h264enc:nvv4l2h264enc0.GstPad:sink: caps = video/x-raw(memory:NVMM), width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, format=(string)I420, multiview-mode=(string)mono, interlace-mode=(string)progressive
/GstPipeline:pipeline0/Gstnvvconv:nvvconv0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
H264: Profile = 66, Level = 0 
NVMEDIA_ENC: bBlitMode is set to TRUE 
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:src: caps = application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)H264, ssrc=(uint)3017367961, timestamp-offset=(uint)347497841, seqnum-offset=(uint)10328, a-framerate=(string)30
/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)H264, ssrc=(uint)3017367961, timestamp-offset=(uint)347497841, seqnum-offset=(uint)10328, a-framerate=(string)30
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:src: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, sprop-parameter-sets=(string)"Z0JAFZZUCg/TUAAAVAAAAwAEAAADAPI8IhGo\,aM48gA\=\=", payload=(int)96, seqnum-offset=(uint)10328, timestamp-offset=(uint)347497841, ssrc=(uint)3017367961, a-framerate=(string)30
/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, sprop-parameter-sets=(string)"Z0JAFZZUCg/TUAAAVAAAAwAEAAADAPI8IhGo\,aM48gA\=\=", payload=(int)96, seqnum-offset=(uint)10328, timestamp-offset=(uint)347497841, ssrc=(uint)3017367961, a-framerate=(string)30
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: timestamp = 347497841
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: seqnum = 10328
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

receiver:

 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! xvimagesink
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE
Opening in BLOCKING MODE 
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 

(gst-launch-1.0:19148): GStreamer-CRITICAL **: 21:08:51.369: gst_mini_object_unref: assertion 'mini_object != NULL' failed
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
^Chandling interrupt.
Interrupt: Stopping pipeline ...
EOS on shutdown enabled -- Forcing EOS on the pipeline
Waiting for EOS...
Got EOS from element "pipeline0".
EOS received - stopping pipeline...
Execution ended after 0:01:10.477851056
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

If running remotely, you would connect to Jetson with ssh -X or -Y, and xvimagesink should be forwarded (assuming your host has a X server).

I do have an x server running on the jetson (i think it’s the one from the gnome display manager). I got access to it using MIT-MAGIC_COOKIE-1. I also have an x server running on the machine I am sshing from.

However, when I run the pipeline to receive the stream I get:

nvbuf_utils: Could not get EGL display connection
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1773): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
Could not open display (null)
Setting pipeline to NULL ...
Freeing pipeline ...

Hi,
RGB format is not supported in nvvidconv plugin. You would need to run like

videotestsrc ! videoconvert ! nvvidconv ! ...

And you may try with gst-launch-1.0 commands first. Make sure the pipeline can be run successfully in gst-launch-1.0, and then do C programming.

For UDP streaming, here is a reference post:
Gstreamer TCPserversink 2-3 seconds latency - #5 by DaneLLL

Do you have a reference in C/C++ for udp streaming?

@DaneLLL is correct that if your appsrc sends BGR, you would have to use videoconvert with CPU overhead.
For videotestsrc, it has many formats available with some suitable for nvvidconv such as YUY2.

You would try this simple example RTP/UDP streaming to local host :

#include <iostream>
#include <unistd.h>
#include <gst/gst.h>

int main (gint argc, gchar * argv[])
	gst_init (&argc, &argv);

	/* Create the pipeline...this will negociate unspecified caps between plugins */
	GstElement *pipeline = gst_parse_launch ("videotestsrc is-live=1 ! nvvidconv ! nvv4l2h264enc insert-sps-pps=1 insert-vui=1 ! rtph264pay ! udpsink host=127.0.0.1 port=5000", NULL);
	if (!pipeline) {
		std::cerr << "Failed to create pipeline\n";
		exit(-1);
	}

	/* Ok, successfully created the pipeline, now start it */
  	gst_element_set_state (pipeline, GST_STATE_READY);
  	gst_element_set_state (pipeline, GST_STATE_PLAYING);

	/* Forever loop */
	while(1) {
	    sleep(1);
	}

	return 0;
}

Save this to file gst_testlaunch.cpp.

You would build with:

gcc -Wall -o gst_testlaunch -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include gst_testlaunch.cpp -lstdc++ -lgstreamer-1.0

Once built, run it:

./gst_testlaunch

Then in another terminal in Jetson, you would receive, decode and display to X with :

gst-launch-1.0 udpsrc port=5000 ! application/x-rtp, media=video, encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! xvimagesink

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