When I get video stream on localhost with udpsrc, the incoming video stream is lagged and mosaic

I fail to understand what you’re asking for.
If it is just using gst_caps_new_simple here are the caps before and after rtpmp2tpay:

...

  //mux2pay_caps = gst_caps_from_string("video/mpegts, systemstream=(boolean)true, packetsize=(int)188");
  mux2pay_caps = gst_caps_new_simple("video/mpegts", 
	"systemstream", G_TYPE_BOOLEAN, true,
	"packetsize", G_TYPE_INT, 188,
	NULL);

  pay = gst_element_factory_make ("rtpmp2tpay", "pay");

  //pay2udp_caps = gst_caps_from_string("application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T, payload=(int)33");
  pay2udp_caps = gst_caps_new_simple("application/x-rtp",
	 "media", G_TYPE_STRING, "video",
	 "encoding-name", G_TYPE_STRING, "MP2T",
	 "clock-rate", G_TYPE_INT, 90000,
	 "payload", G_TYPE_INT, 33,
	 NULL);

  udpsink = gst_element_factory_make ("udpsink", "udpsink");
  g_object_set (G_OBJECT (udpsink), "host", "10.0.3.30", NULL);
  g_object_set (G_OBJECT (udpsink), "port", 11002, NULL);
  g_object_set (G_OBJECT (udpsink), "auto-multicast", false, NULL);

...

For summarizing up on this topic, I think that:

  • You’re seeing mosaicing because an I frame was lost in UDP traffic (Note that UDP is just datagrams with no control-flow).
  • There are many possible causes for hogging your UDP stack or network.
  • So streaming MP2TS directly on UDP may not be reliable.
  • A first step would be using RTP-MP2T with rtpmp2tpay on sender and rtpmp2tdepay on receiver. This may help.
  • If not enough, or if loosing an I frame is not affordable, you would have to move to TCP transport.

If not enough, you may better explain your expectation into another topic, but as it may be a gstreamer more than a Jetson-related issue, you may better post it into gstreamer devel forum.

1 Like