Stop processing video files.

Hello,

I use this project: GitHub - hailo-ai/hailo-rpi5-examples to make detection. how to stop processing when the script goes through all frames?

Now it show: “Video rewound successfully. Restarting playback…”.

I tried edit gstreamer_app.py in venv_hailo_rpi5_examples\site-packages\site-packages\hailo_apps_infra\gstreamer_app.py, but it looks like project doesn`t use this file.

I’m asking for help.

Hey @hubert12301,

You’re right, to prevent the video from looping and stop the execution when all frames have been processed, you need to modify the gstreamer_app.py file. Keep in mind that you might need to update this file every time you reinstall the examples.

Here’s how you can make the necessary changes:

  1. Locate the following function in gstreamer_app.py:
def on_eos(self):
    if self.source_type == "file":
        # Seek to the start (position 0) in nanoseconds
        success = self.pipeline.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH, 0)
        if success:
            print("Video rewound successfully. Restarting playback...")
        else:
            print("Error rewinding the video.", file=sys.stderr)
    else:
        self.shutdown()
  1. Modify the function to stop the execution instead of looping:
def on_eos(self):
    print("End-of-stream reached. Exiting...")
    self.shutdown()  # Stop the pipeline and exit gracefully

If you’ve made these changes and are still encountering issues or receiving an error, please provide more details about the specific error you’re seeing. Include any relevant error messages or tracebacks, as well as information about your setup and the steps you’ve taken. This will help me better understand the problem and provide more targeted assistance.

Let me know if you have any further questions!