Using DeepStream Python sample app with .mp4 file input

I am trying to modify the deepstream_test_1.py app included with the DeepStream Python bindings to take an MP4 file as input (sample_1080p_h264.mp4) instead of an H.264 elementary stream (sample_720p.h264). Eventually, I want to use an RTSP camera source. To support MP4, I modified the sample app to add a qtdemux element, and dynamically linked it to the h264 parser element based on the deepstream_test_3 app. The problem is the pipeline fails to start with an internal data stream error because qtdemux cannot be linked to h264parser.

When I run the sample unaltered with sample_720p.h264 as source, it works, so the issue is most likely with the way I am adding qtdemux or dynamically linking the Gstreamer pipeline.

  • Jetson Nano B01
  • L4T version:
    • R32 (release), REVISION: 4.2, GCID: 20074772, BOARD: t210ref, EABI: aarch64, DATE: Thu Apr 9 01:22:12 UTC 2020
  • DeepStream 5 with Python bindings

Here are the modified code snippets:

def demux_pad_added(qtdemux, qtdemux_src_pad, h264parser):
    print ("In demux_pad_added")
    caps = qtdemux_src_pad.get_current_caps()
    gststruct = caps.get_structure(0)
    gstname = gststruct.get_name()

    print("gstname =", gstname)
    if gstname.find("video") != -1:
        # Link to h264 parser
        print("Linking qtdemux to h264parse")
        qtdemux_src_pad.link(h264parser.get_static_pad("sink"))
    print("FINISHED demux_pad_added")

def main(args):

    ....

    source = Gst.ElementFactory.make("filesrc", "file-source")
    demux = Gst.ElementFactory.make("qtdemux", "demux")

    ...

    pipeline.add(source)
    pipeline.add(demux)
    pipeline.add(h264parser)

    ...

    demux.connect("pad-added", demux_pad_added, h264parser)

    ...

    source.link(demux)

    ...

Full Python source: deepstream_test_2.txt (10.9 KB)

Here is a full log of the output with GST_DEBUG=GST_CAPS:6.
deepstream_test_2.log (55.0 KB)

Any ideas?

Thanks,
Alex.

Hi, uridecodebin is your best friend.

  • You can use it on files: uridecodebin uri="file:///home/nvidia/.../file.mp4"
  • Or with an RTSP stream: uridecodebin uri="rtspt://170.93.143.139/rtplive/..."

uridecodebin automatically selects the required elements to get the source, decode, depayload, demux, and convert. If multiple elements provide a functionality it will select them according to the element rank, which almost always means that hardware-accelerated elements are used whenever possible.

3 Likes

Hi,
We suggest you try deepstream-test3.

The source in the sample is uridecodebin. It is more close to your usecase.

It is indeed the best thing ever, (after regular decodebin).

1 Like