# Converting NVIDIA DeepStream Pipelines to Deep Learning Streamer Pipeline Framework This article presents how to convert a pipeline from NVIDIA DeepStream to Deep Learning Streamer Pipeline Framework. For this purpose, a working example is described at each step, to help understand the applied 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) ## Preparing Your Model > **Note:** To use Deep Learning Streamer Pipeline Framework and 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 one. 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 inferences on the video, re-encodes 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 GStreamer command line allows quick demonstration of a running pipeline, fine-grain control typically involves using a GStreamer pipeline object in a programmable way: either Python or C/C++ code. 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/master/samples/gstreamer/python/hello_dlstreamer). Both applications implement the same functionality, yet they use DeepStream or DLStreamer elements as illustrated in the table below. The elements in __bold__ are vendor-specific, while 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 DeepStream and DL Streamer applications use same set of regular GStreamer library functions to construct pipelines. The difference is in what elements are created and linked. In addition, DL Streamer `decodebin3` element uses late linking within a callback function.
| DeepStream Pipeline Creation in Python | DLStreamer Pipeline Creation in Python |
|---|---|
|
|
| DeepStream Probe Registration | DLStreamer 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 | DLStreamer Probe Implementation |
|---|---|
|
|
| DeepStream Pipeline Execution | DLStreamer Pipeline Execution |
|---|---|
|
|