Need help extending RTSP decode source bin to support JPEG encoding

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
Jetson
• DeepStream Version
6.0.1
• JetPack Version (valid for Jetson only)
4.6.1
• TensorRT Version
8.2.1
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
Questions, possible bug?
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

We’re trying to extend an our current implementation of a DeepStream/gstreamer RTSP decode source bin – that is based on your provided example in:

apps/apps-common/src/deepstream_source.bin.c

The current solution works well for H264 and H265 encoding, but we’d like to support RTSP/JPEG as well.

We’ve confirmed that the following launch command works with our cameras…

gst-launch-1.0 -vvv rtspsrc location=rtsp://192.168.1.140:554/jpeg ! rtpjpegdepay ! jpegparse ! nvjpegdec ! nveglglessink sync=0

The below code, although based on our own framework, should help to illustrate what we’re trying to do.

this is logic executed from the context of the rtspsrc select-stream callback function. The function simply loads specific plugin’s based on the encoding found… with a few extra log statements for the JPEG case.

bool RtspSourceBintr::HandleSelectStream(GstElement *pBin, uint num, GstCaps *caps)
{
    GstStructure *structure = gst_caps_get_structure(caps, 0);
    std::string media = gst_structure_get_string(structure, "media");
    std::string encoding = gst_structure_get_string(structure, "encoding-name");

    if (media.find("video") != std::string::npos)
    {            
        if (encoding.find("H264") != std::string::npos)
        {
            m_pParser = DSL_ELEMENT_NEW("h264parse", GetCStrName());
            m_pDepay = DSL_ELEMENT_NEW("rtph264depay", GetCStrName());
            m_pDecodeBin = DSL_ELEMENT_NEW("decodebin", GetCStrName());
        }
        else if (encoding.find("H265") != std::string::npos)
        {
            m_pParser = DSL_ELEMENT_NEW("h265parse", GetCStrName());
            m_pDepay = DSL_ELEMENT_NEW("rtph265depay", GetCStrName());
            m_pDecodeBin = DSL_ELEMENT_NEW("decodebin", GetCStrName());
        }
        else if (encoding.find("JPEG") != std::string::npos)
        {
            m_pParser = DSL_ELEMENT_NEW("jpegparse", GetCStrName());
            LOG_INFO("Define jpegparse");
            m_pDepay = DSL_ELEMENT_NEW("rtpjpegdepay", GetCStrName());
            LOG_INFO("Define rtpjpegdepay");
            m_pDecodeBin = DSL_ELEMENT_NEW("nvjpegdec", GetCStrName());
            LOG_INFO("Define nvjpegdec");
        }

Again, the H264 and H265 case work fine. The JPEG case, however, leads to a segfault as show with the logs below

0:00:00.828271016  3696 0x56080aff6c00 INFO                     DSL src/DslSourceBintr.cpp:2632:HandleSelectStream:  : Media = 'video' for RtspSourceBitnr 'rtsp-source'
0:00:00.828285478  3696 0x56080aff6c00 INFO                     DSL src/DslSourceBintr.cpp:2633:HandleSelectStream:  : Encoding = 'JPEG' for RtspSourceBitnr 'rtsp-source'
0:00:00.828585566  3696 0x56080aff6c00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstjpegformat.so" loaded
0:00:00.828596836  3696 0x56080aff6c00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "jpegparse" named "rtsp-source-jpegparse"
0:00:00.828646973  3696 0x56080aff6c00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseParse@0x7f55e801ec40> adding pad 'sink'
0:00:00.828657730  3696 0x56080aff6c00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstBaseParse@0x7f55e801ec40> adding pad 'src'
0:00:00.828686082  3696 0x56080aff6c00 INFO                     DSL src/DslSourceBintr.cpp:2658:HandleSelectStream:  : Define jpegparse
0:00:00.829178220  3696 0x56080aff6c00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstrtp.so" loaded
0:00:00.829186671  3696 0x56080aff6c00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "rtpjpegdepay" named "rtsp-source-rtpjpegdepay"
0:00:00.829226547  3696 0x56080aff6c00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstRTPBaseDepayload@0x7f55e8029e60> adding pad 'sink'
0:00:00.829239611  3696 0x56080aff6c00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstRTPBaseDepayload@0x7f55e8029e60> adding pad 'src'
0:00:00.829255753  3696 0x56080aff6c00 INFO                     DSL src/DslSourceBintr.cpp:2660:HandleSelectStream:  : Define rtpjpegdepay
0:00:00.830291341  3696 0x56080aff6c00 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_jpegdec.so" loaded
0:00:00.830302014  3696 0x56080aff6c00 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:359:gst_element_factory_create: creating element "nvjpegdec" named "rtsp-source-nvjpegdec"
0:00:00.830348805  3696 0x56080aff6c00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstVideoDecoder@0x7f55e80457e0> adding pad 'sink'
0:00:00.830358482  3696 0x56080aff6c00 INFO        GST_ELEMENT_PADS gstelement.c:670:gst_element_add_pad:<GstVideoDecoder@0x7f55e80457e0> adding pad 'src'
Segmentation fault (core dumped)

It appears as if loading the nvjpegdec plugin in the context of the rtspsrc stream-select
context is causing the fault.

My first questions are… before I spend time trying to reproduce the problem with you DS example code…

  1. do you have a working example for RTSP/JPEG?
  2. and do you know of any reason why this may be an issue?

Thanks,
Robert.

1 Like

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

Please use “nvv4l2decoder” to decode jpeg and mjpeg stream. The nvjpegdec is old.

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