Stream ID using Pipeline with Resolution Preservation

Hi,

I’m implementing a GStreamer pipeline similar to what is used on the example pipeline with resolution preservation (tappas/docs/pipelines/single_network.rst at 0f4813c7683f388886b9900ceaeeb0c4ec49a3f0 · hailo-ai/tappas · GitHub).
For my app, I need to catch also the stream_id. However, when I use “tee” in the pipeline the stream_id is always empty. If I remove the tee the stream_id appears as an SHA256 code :slight_smile:

There is any solution for that?

The pipeline:

source_element = f"rtspsrc location={self.video_source} name=src  message-forward=true ! "
source_element += "rtph264depay !"
source_element += QUEUE(f"queue_rtsp", max_size_buffers=30)
source_element += "decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! "
source_element += "video/x-raw, format=I420 ! "

source_element += QUEUE("queue_src_convert", max_size_buffers=5)
source_element += f"videoconvert n-threads=3 name=src_convert ! "

pipeline_string = source_element

pipeline_string += "tee name=t hailomuxer name=hmux "

pipeline_string += "t. ! "
pipeline_string += QUEUE("bypass_queue", max_size_buffers=20)
pipeline_string += "hmux.sink_0 "

pipeline_string += "t. ! "
pipeline_string += "videoscale ! "
pipeline_string += QUEUE("queue_hailonet", max_size_buffers=5)
pipeline_string += f"hailonet hef-path={self.hef_path} batch-size=1 {thresholds_str} ! "
pipeline_string += QUEUE("queue_hailofilter", max_size_buffers=5)
pipeline_string += f"hailofilter function-name={self.default_network_name} so-path={self.default_postprocess_so} qos=false ! "
pipeline_string += "queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! "
pipeline_string += "hailotracker name=hailo_tracker class-id=-1 keep-past-metadata=true kalman-dist-thr=.5 iou-thr=.6 keep-tracked-frames=2 keep-lost-frames=2 ! "

pipeline_string += QUEUE("queue_hmuc")
pipeline_string += "hmux.sink_1 "
pipeline_string += "hmux. ! "

pipeline_string += QUEUE("queue_hailopython", max_size_buffers=5)
pipeline_string += f"hailopython qos=false module={self.options_menu.python_module} ! "
pipeline_string += QUEUE("queue_hailooverlay", max_size_buffers=5)
pipeline_string += f"hailooverlay ! "
pipeline_string += QUEUE("queue_videoconvert", max_size_buffers=5)
pipeline_string += f"videoconvert n-threads=3 ! "
pipeline_string += f"fpsdisplaysink vide

The callback function:

def run(video_frame: VideoFrame):
    stream_id = video_frame.roi.get_stream_id()
    width = video_frame.video_info.width
    height = video_frame.video_info.height
    

    print(stream_id, width, height)

    return Gst.FlowReturn.OK

Hey @diulhio

The empty stream_id issue when using the tee element in your GStreamer pipeline might be related to metadata handling. Here’s a potential solution and explanation:

  • Metadata Preservation with Identity Elements

To ensure metadata (including stream_id) is correctly preserved and passed through the pipeline, add identity elements after the tee. Here’s how to modify your pipeline string:

python

pipeline_string += "tee name=t hailomuxer name=hmux "

# First branch
pipeline_string += "t. ! identity name=identity_1 ! "
pipeline_string += QUEUE("bypass_queue", max_size_buffers=20)
pipeline_string += "hmux.sink_0 "

# Second branch
pipeline_string += "t. ! identity name=identity_2 ! "
pipeline_string += "videoscale ! "
pipeline_string += QUEUE("queue_hailonet", max_size_buffers=5)
pipeline_string += f"hailonet hef-path={self.hef_path} batch-size=1 {thresholds_str} ! "
# ... (rest of the pipeline remains unchanged)

Key changes:

  • Added identity name=identity_1 after the first t.
  • Added identity name=identity_2 after the second t.

These identity elements act as passthrough elements that help maintain metadata consistency across pipeline branches. This should address the stream_id preservation issue you’re experiencing.

If you implement this change and still face issues, please provide more details about your specific setup and any error messages you encounter.

Hi,

 Please search "STREAM_ID_SO" in Hailo-Application-Code-Examples, you will find how to use the stream-id.

BR

2 Likes

@omria Unfortunately the addition of the two “identity” didn’t work.

@chrysler.chen That worked like a charm!! I wish I had seen this before, I spent a few hours to understand how GStreamer generate the SHA256 id for RTSP streams, in order to identify multiple streamings data. Thank you very much!

1 Like