Gstreamer fails on Jetson Orin NX but not on Nvidia Laptop

Hello everyone,
I’m trying to use Yolo to detect trucks but when gstreamer tries to decode the video, it crashes mentioned the following error.

Error: gst-stream-error-quark: Internal data stream error. (1): ../gst/matroska/matroska-demux.c(6097): gst_matroska_demux_loop (): /GstPipeline:pipeline0/GstBin:source-bin-00/GstURIDecodeBin:uri-decode-bin/GstDecodeBin:decodebin0/GstMatroskaDemux:matroskademux0:
streaming stopped, reason error (-5)

But when I do the same in my own PC inside a container with the Base image nvcr.io/nvidia/deepstream:7.0-samples-multiarch, the same code works and I can track trucks. I also tried to use the container on the Jetson but same error

My device is a Jetson Orin NX 8GB with Jetpack 6.0 and Deepstream 7.0

If you need more information,
let me know

Thanks in advance

Which DeepStream app are you using? Can you provide the app, configuration file and the mkv video?
You may also “export GST_DEBUG=3” to get more log.

Hello Fiona,
Thanks for your help on this:

Can you provide the app, configuration file

Configuration file: config_infer_primary.txt (870 Bytes)

This is how I configured gstreamer on my python script based on deepstream_python_apps

# Standard GStreamer initialization
    Gst.init(None)
    # Create gstreamer elements
    # Create Pipeline element that will form a connection of other elements
    print("Creating Pipeline \n ")
    pipeline = Gst.Pipeline()

    if not pipeline:
        sys.stderr.write(" Unable to create Pipeline \n")
    print("Creating streamux \n ")

    # Create nvstreammux instance to form batches from one or more sources.
    streammux = create_nvstreammux_instance(platform_info, pipeline, 
                                            number_sources, args)
    queue1=Gst.ElementFactory.make("queue","queue1")
    queue2=Gst.ElementFactory.make("queue","queue2")
    queue3=Gst.ElementFactory.make("queue","queue3")
    queue4=Gst.ElementFactory.make("queue","queue4")
    queue5=Gst.ElementFactory.make("queue","queue5")
    pipeline.add(queue1)
    pipeline.add(queue2)
    pipeline.add(queue3)
    pipeline.add(queue4)
    pipeline.add(queue5)
    nvdslogger = None
    pgie = create_pgie(requested_pgie, number_sources)

    print("Creating nvvidconv \n ")
    nvvidconv = Gst.ElementFactory.make("nvvideoconvert", "convertor")
    if not nvvidconv:
        sys.stderr.write(" Unable to create nvvidconv \n")
    
    nvosd = create_nvosd()

    print("Creating Container \n")
    container = Gst.ElementFactory.make("qtmux", "qtmux")
    if not container:
        sys.stderr.write(" Unable to create code parser \n")
 
    sink = create_render_sink()
    tiler = create_tiler(number_sources)
    tracker = create_tracker()
    file_sink = create_file_sink()
   
    container = Gst.ElementFactory.make("qtmux", "qtmux")
    if not container:
        sys.stderr.write(" Unable to create code parser \n")
    codeparser = Gst.ElementFactory.make("mpeg4videoparse", "mpeg4-parser")
    if not codeparser:
        sys.stderr.write(" Unable to create code parser \n")
        
    encoder = Gst.ElementFactory.make("avenc_mpeg4", "encoder")
    if not encoder:
        sys.stderr.write(" Unable to create encoder \n")
    encoder.set_property("bitrate", 2000000)
    
    print("Creating capsfilter \n")
    capsfilter = Gst.ElementFactory.make("capsfilter", "capsfilter")
    if not capsfilter:
        sys.stderr.write(" Unable to create capsfilter \n")
    caps = Gst.Caps.from_string("video/x-raw, format=I420")
    capsfilter.set_property("caps", caps)
    print("Creating converter 2\n")
    nvvidconv2 = Gst.ElementFactory.make("nvvideoconvert", "convertor2")
    if not nvvidconv2:
        sys.stderr.write(" nvvidconv2 to create nvvidconv2 \n")
        
    #############################################
    # Add nvvidconv1 and filter1 to convert the frames to RGBA
    # which is easier to work with in Python.
    print("Creating nvvidconv1 \n ")
    nvvidconv1 = Gst.ElementFactory.make("nvvideoconvert", "convertor1")
    #if not nvvidconv1:
    #sys.stderr.write(" Unable to create nvvidconv1 \n")
    print("Creating filter1 \n ")
    caps1 = Gst.Caps.from_string("video/x-raw(memory:NVMM), format=RGBA")
    filter1 = Gst.ElementFactory.make("capsfilter", "filter1")
    if not filter1:
        sys.stderr.write(" Unable to get the caps filter1 \n")
    filter1.set_property("caps", caps1)   
    pipeline.add(filter1)
    pipeline.add(nvvidconv1)

    mem_type = int(pyds.NVBUF_MEM_CUDA_UNIFIED)
    print(mem_type)
    nvvidconv.set_property("nvbuf-memory-type", mem_type)
    streammux.set_property("nvbuf-memory-type", mem_type)
    nvvidconv1.set_property("nvbuf-memory-type", mem_type)

    print("Adding elements to Pipeline \n")
    pipeline.add(pgie)
    pipeline.add(tracker)
    pipeline.add(tiler)
    pipeline.add(nvvidconv)
    pipeline.add(nvosd)
    if no_display:
        pipeline.add(nvvidconv2)
        pipeline.add(capsfilter)
        pipeline.add(encoder)
        pipeline.add(codeparser)
        pipeline.add(container)
        pipeline.add(file_sink)
    else:
        pipeline.add(sink)

    print("Linking elements in the Pipeline \n")
    streammux.link(queue1)
    queue1.link(pgie)
    pgie.link(tracker)
    tracker.link(queue2)
    if nvdslogger:
        queue2.link(nvdslogger)
        nvdslogger.link(tiler)
    else:
        queue2.link(tiler)
    tiler.link(queue3)
    queue3.link(nvvidconv)
    nvvidconv.link(queue4)
    queue4.link(nvosd)
    if no_display:
        nvosd.link(queue5)
        queue5.link(nvvidconv2)
        nvvidconv2.link(capsfilter)
        capsfilter.link(encoder)
        encoder.link(codeparser)
        codeparser.link(container)
        container.link(file_sink)
    else:
        queue4.link(nvvidconv1)
        nvvidconv1.link(filter1)
        filter1.link(nvosd)
        queue5.link(nvosd)
        nvosd.link(sink)
    # create an event loop and feed gstreamer bus mesages to it
    loop = create_event_loop(pipeline, nvosd)
    
    # Enable latency measurement via probe if environment variable NVDS_ENABLE_LATENCY_MEASUREMENT=1 is set.
    # To enable component level latency measurement, please set environment variable
    # NVDS_ENABLE_COMPONENT_LATENCY_MEASUREMENT=1 in addition to the above.
    if environ.get('NVDS_ENABLE_LATENCY_MEASUREMENT') == '1':
        print ("Pipeline Latency Measurement enabled!\nPlease set env var NVDS_ENABLE_COMPONENT_LATENCY_MEASUREMENT=1 for Component Latency Measurement")
        global measure_latency
        measure_latency = True

    # List the sources
    print("Now playing...")
    for i, source in enumerate(args):
        print(i, ": ", source)

    print("Starting pipeline \n")
    # start play back and listed to events		
    pipeline.set_state(Gst.State.PLAYING)

Video:

FYI: I also tried using mp4 videos, the error disappeared but the video is not replayed.
Video:

  • mp4:

Logs:

Could you try to set the mem_type to your decoder like deepstream_imagedata-multistream.py?

Hello yuweiw,
Thanks for your input but still same issues after changing
What I noticed is also this error:
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:4490: => Surface type not supported for transformation NVBUF_MEM_CUDA_UNIFIED

output_gst_4.txt (257.8 KB)

Hello all,
I have removed this from my code and works on the Jetson but I would like to understand why this discrepancy between x64 and Jetson

With this works on my PC but not on the Jetson but if I remove, It works on the Jetson but not on my PC

mem_type = int(pyds.NVBUF_MEM_CUDA_UNIFIED)
print(mem_type)
nvvidconv.set_property("nvbuf-memory-type", mem_type)
streammux.set_property("nvbuf-memory-type", mem_type)
nvvidconv1.set_property("nvbuf-memory-type", mem_type)

Thanks in advance

You may not be modifying your code correctly. You can try to run our deepstream_imagedata-multistream.py directly first both on your PC and your Jetson. Then modify your code based on this sample.

The main diff is that the default memory type of the decoder is different on PC and Jetson. You need to set the Object.set_property(“cudadec-memtype”, 2) on the Jetson.