# Converting NVIDIA DeepStream Pipelines to Deep Learning Streamer Pipeline Framework This article explains how to convert a pipeline from NVIDIA DeepStream to the Deep Learning Streamer Pipeline Framework. A working example is provided at each step to help illustrate the required modifications. > **Note:** The intermediate steps of the pipeline are not meant to run. They are > simply there as a reference example of the changes being made in each > section. ## Contents - [Preparing Your Model](#preparing-your-model) - [Conversion Examples](#conversion-examples) - [Command Line Applications](#command-line-applications) - [Python Applications](#python-applications) - [Conversion Rules](#conversion-rules-for-pipeline-elements) - [Mux and Demux Elements](#mux-and-demux-elements) - [Inferencing Elements](#inferencing-elements) - [Video Processing Elements](#video-processing-elements) - [Metadata Elements](#metadata-elements) - [Multiple Input Streams](#multiple-input-streams) - [DeepStream to DL Streamer Mapping](#deepstream-to-dl-streamer-mapping) - [Element Mapping](#element-mapping) - [Property Mapping](#property-mapping) - [AI-Supported Conversions](#ai-supported-conversions) ## Preparing Your Model > **Note:** To use the Deep Learning Streamer Pipeline Framework and the OpenVINO™ Toolkit, the > model needs to be in Intermediate Representation (IR) format. To convert > your model to this format, follow the steps in [model preparation](./model_preparation.md). > ## Conversion Examples ### Command Line Applications The following sections show how to convert a DeepStream pipeline to a DL Streamer pipeline. The DeepStream pipeline is taken from one of the [examples](https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps). It reads a video stream from the input file, decodes it, runs inference, overlays the inference results on the video, re-encodes it, and outputs a new .mp4 file. ```shell filesrc location=input_file.mp4 ! decodebin ! \ nvstreammux batch-size=1 width=1920 height=1080 ! queue ! \ nvinfer config-file-path=./config.txt ! \ nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! \ nvdsosd ! queue ! \ nvvideoconvert ! "video/x-raw, format=I420" ! videoconvert ! avenc_mpeg4 bitrate=8000000 ! qtmux ! filesink location=output_file.mp4 ``` The mapping below represents the typical changes that need to be made to the pipeline to convert it to Deep Learning Streamer Pipeline Framework. The pipeline is broken down into sections based on the elements used in the pipeline.  ### Python Applications While the GStreamer command line allows a quick demonstration of a running pipeline, fine-grained control typically involves using a GStreamer pipeline object programmatically in Python or C/C++. This section illustrates how to convert a [DeepStream Python example](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/tree/master/apps/deepstream-test1) into a [DL Streamer Python example](https://github.com/open-edge-platform/dlstreamer/tree/main/samples/gstreamer/python/hello_dlstreamer). Both applications implement the same functionality, but they use DeepStream and DL Streamer elements differently, as illustrated in the table below. The elements in __bold__ are vendor-specific, while the others are regular GStreamer elements. | DeepStream Element | DL Streamer Element | Function | |---|---|---| | filesrc | filesrc | Read video file | | h264parse ! __nvv4l2decoder__ | decodebin3 | Decode video file | | __nvstreammux__ ! __nvinfer__ | __gvadetect__ ! queue | Create batch buffer and run AI inference | | __nvvideoconvert__ | videoconvertscale | Convert video format | | __nvosd__ | __gvawatermark__ | Overlay analytics results | | __nv3dsink__ | audiovideosink | Render results in a window | Such pipelines can be created programmatically in a Python application using a sequence of API calls: ```python element = Gst.ElementFactory.make(...) element.set_property(...) pipeline.add(element) element.link(next_element) ``` Please note that DeepStream and DL Streamer applications use the same set of regular GStreamer library functions to construct pipelines. The difference lies in which elements are created and linked. In addition, the DL Streamer `decodebin3` element uses late linking within a callback function.
| DeepStream Pipeline Creation in Python | DL Streamer Pipeline Creation in Python |
|---|---|
|
|
| DeepStream Probe Registration | DL Streamer Probe Registration |
|---|---|
osdsinkpad = nvosd.get_static_pad("sink")
osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, osd_sink_pad_buffer_probe, 0)
|
watermarksinkpad = watermark.get_static_pad("sink")
watermarksinkpad.add_probe(Gst.PadProbeType.BUFFER, watermark_sink_pad_buffer_probe, 0)
|
| DeepStream Probe Implementation | DL Streamer Probe Implementation |
|---|---|
|
|
| DeepStream Pipeline Execution | DL Streamer Pipeline Execution |
|---|---|
|
|