Deepstream test4 modified code with RTSP(rtspsrc) in jetson xavier NX not displaying anything

Hi, I’m trying the deepstream test4 app with RTSP camera, I’m using the rtspsrc instead of filesrc by modifying and adding the following code, of course I linked them together, and it seems like working, but it doesn’t display anything on the screen… can anyone help me with this?

// added function
static void cb_new_rtspsrc_pad(GstElement *element, GstPad *pad, gpointer data) {
    gchar *name;
    GstCaps *p_caps;
    gchar *description;
    GstElement *p_rtph264depay;

    name = gst_pad_get_name(pad);
    g_print("A new pad %s was created\n", name);

    // here, you would setup a new pad link for the newly created pad
    // sooo, now find that rtph264depay is needed and link them?
    p_caps = gst_pad_get_pad_template_caps(pad);

    description = gst_caps_to_string(p_caps);
    g_printf("%s\n", &p_caps);
    g_printf("%s\n", description);
    g_free(description);

    p_rtph264depay = GST_ELEMENT(data);

    // try to link the pads then ...
    if (!gst_element_link_pads(element, name, p_rtph264depay, "sink")) {
        printf("Failed to link elements 3\n");
    }

    g_free(name);
}
//--------main function-----------------
  // source = gst_element_factory_make ("filesrc", "file-source");
  source = gst_element_factory_make ("rtspsrc", "rtsp-source");
  g_object_set (G_OBJECT (source), "location", "rtsp://192.168.1.120:554/live/main", NULL);
  g_object_set (G_OBJECT (source), "user-id", "admin", NULL);
  g_object_set (G_OBJECT (source), "user-pw", "12345", NULL);
  rtppay = gst_element_factory_make("rtph264depay", "depayl");
....
  // change nvstreammux's live-source  to 1
  g_object_set (G_OBJECT (nvstreammux), "live-source", 1, NULL);
.....
  // connect the rtspsrc to rtph264depay
  g_signal_connect(source, "pad-added", G_CALLBACK(cb_new_rtspsrc_pad), rtppay);
  // change the following link_many from source to rtppay
  if (!gst_element_link_many (rtppay, h264parser, decoder, NULL)) {
    g_printerr ("Elements could not be linked. Exiting.\n");
    return -1;
  }

And I got this following output from the modified deepstream-test4 app. It seems like working , but not displaying anything…

administrator@artibrainsjetsonnx1:/opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/deepstream-test4$ ./deepstream-test4-app -i rtsp://192.168.1.120:554/live/main -c cfg_amqp.txt -p /opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_amqp_proto.so --conn-str "192.168.1.181;5672;guest" -t deepstream
Now playing: rtsp://192.168.1.120:554/live/main

Using winsys: x11
Opening in BLOCKING MODE
0:00:05.060886367 31384   0x5562d19440 INFO                 nvinfer gstnvinfer.cpp:602:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1577> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-5.0/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
INFO: [Implicit Engine Info]: layers num: 3
0   INPUT  kFLOAT input_1         3x368x640
1   OUTPUT kFLOAT conv2d_bbox     16x23x40
2   OUTPUT kFLOAT conv2d_cov/Sigmoid 4x23x40

0:00:05.061306660 31384   0x5562d19440 INFO                 nvinfer gstnvinfer.cpp:602:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1681> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-5.0/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
0:00:05.065924476 31384   0x5562d19440 INFO                 nvinfer gstnvinfer_impl.cpp:311:notifyLoadModelStatus:<primary-nvinference-engine> [UID 1]: Load new model:dstest4_pgie_config.txt sucessfully
Running...
A new pad recv_rtp_src_0_1542084603_96 was created
�u*bU
application/x-rtp; application/x-rdt
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261

You may try to remove h264parse from the pipeline.

1 Like

Thank you so much ! after removing the h264parse it just work! I would like to further adding the uridecodebin method to deepstream test 4!