I want to push video after Yolov8 pose estimation

So I change the code which from Hailo raspberry example:

def get_pipeline_string(self):

        if (self.source_type == "rpi"):
            source_element = f"libcamerasrc name=src_0 auto-focus-mode=2 ! "
            source_element += f"video/x-raw, format={self.network_format}, width=1536, height=864 ! "
            source_element += QUEUE("queue_src_scale")
            source_element += f"videoscale ! "
            source_element += f"video/x-raw, format={self.network_format}, width={self.network_width}, height={self.network_height}, framerate=30/1 ! "
        
        elif (self.source_type == "usb"):
            source_element = f"v4l2src device={self.video_source} name=src_0 ! "
            source_element += f"video/x-raw, width=640, height=480, framerate=30/1 ! "
        else:  
            source_element = f"filesrc location={self.video_source} name=src_0 ! "
            source_element += QUEUE("queue_dec264")
            source_element += f" qtdemux ! h264parse ! avdec_h264 max-threads=2 ! "
            source_element += f" video/x-raw,format=I420 ! "
        source_element += QUEUE("queue_scale")
        source_element += f"videoscale n-threads=2 ! "
        source_element += QUEUE("queue_src_convert")
        source_element += f"videoconvert n-threads=2 name=src_convert qos=false ! "
        source_element += f"video/x-raw, format={self.network_format}, width={self.network_width}, height={self.network_height}, pixel-aspect-ratio=1/1 ! "
        
        pipeline_string = "hailomuxer name=hmux "
        pipeline_string += source_element
        pipeline_string += "tee name=t ! "
        pipeline_string += QUEUE("bypass_queue", max_size_buffers=20) + "hmux.sink_0 "
        pipeline_string += "t. ! " + QUEUE("queue_hailonet")
        pipeline_string += "videoconvert n-threads=2 ! "
        pipeline_string += f"hailonet hef-path={self.hef_path} batch-size={self.batch_size} force-writable=true ! "
        pipeline_string += QUEUE("queue_hailofilter")
        pipeline_string += f"hailofilter function-name={self.post_function_name} so-path={self.default_postprocess_so} qos=false ! "
        pipeline_string += QUEUE("queue_hmuc") + " hmux.sink_1 "
        pipeline_string += "hmux. ! " + QUEUE("queue_hailo_python")
        pipeline_string += QUEUE("queue_user_callback")
        pipeline_string += f"identity name=identity_callback ! "
        pipeline_string += QUEUE("queue_hailooverlay")
        pipeline_string += f"hailooverlay ! "
        pipeline_string += QUEUE("queue_videoconvert")
        pipeline_string += f"videoconvert n-threads=2 qos=false ! "
        pipeline_string += QUEUE("queue_hailo_display")
        pipeline_string += f"fpsdisplaysink video-sink={self.video_sink} name=hailo_display sync={self.sync} text-overlay={self.options_menu.show_fps} signal-fps-measurements=true "

        # pipeline_string += f"tee name=t2 ! queue ! videoconvert ! x264enc ! rtph264pay ! udpsink host=192.168.49.160 port=2000"


        print(pipeline_string)
        return pipeline_string

The commented-out code is the code I added. Am I right, but It does not work.

First, I think you cannot just add an element at the end of the GStreamer pipeline. The displaysink element is the end of the pipeline. It does not have a source pad where you can continue the pipeline. It also may be a bit too much work for the Raspberry Pi to display and stream the video.

Second there is no x264enc element on the Raspberry Pi 5. There is one called openh264enc. You can get the elements in your system running the following command:

gst-inspect-1.0

Try to replace the line with fpsdisplaysink with the following line (adapt to your host/receiver IP address and a port):

+ f"videoconvert ! openh264enc ! rtph264pay ! udpsink host=192.168.x.x port=5000"

The video quality is not brilliant but it worked on my system. Maybe the encoder uses the CPU and you need another video encoder element.

For further help with GStreamer pipelines I can recommend ChatGPT. It seems to have seen some GStreamer code during training. Have fun.

1 Like

Thank you very much, that solved my problem, and I want to show FPS on video and then push to remote port, and I have tried to solve this proble with ChatGPT, but it does not solve my question.