Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
GPU
• DeepStream Version
deepstream-5.0
• TensorRT Version
7.0.0-1+cuda10.2
• NVIDIA GPU Driver Version (valid for GPU only)
Driver Version: 460.32.03
• Issue Type( questions, new requirements, bugs)
Error/Question
I have a Python Deepstream app and I want it to end properly when pressed Ctrl+C.
My pipeline has the following elements (less important elements are skipped, just to have an idea):
source -> streammux -> tee -> nvinfer -> nvvideoconvert -> nvdosd -> filesink
|---> filesink
My main code is:
self.loop = GObject.MainLoop.new(None, False)
GLib.unix_signal_add(-100, 2, self.handle_sigint, None)
self.bus = self.gst_pipeline.get_bus()
self.bus.add_signal_watch()
self.bus.connect("message", self.bus_message_handler)
self.gst_pipeline.set_state(Gst.State.PLAYING)
self.loop.run()
The bus message handler function:
def bus_message_handler(self, bus, message: Gst.Message) -> bool:
t = message.type
logger.info(f"****************** Message received {t}")
if t == Gst.MessageType.EOS:
logger.success("End of Stream")
self.loop.quit()
elif t == Gst.MessageType.WARNING:
err, debug = message.parse_warning()
logger.warning(f"{err}: {debug}")
elif t == Gst.MessageType.ERROR:
err, debug = message.parse_error()
logger.error(f"{err}: {debug}")
self.gst_error = f"{err}: {debug}"
self.loop.quit()
return True
And finally the sigint handler function:
def handle_sigint(self, user_data=None):
logger.info("SIGINT detected. Sending EOS...")
self.gst_pipeline.send_event(Gst.Event.new_eos())
self.bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.EOS)
The expected behaviour would be:
Run -> Ctrl+C pressed -> Print "SIGINT detected. Sending EOS..." -> Print "End of Stream"
But “End of Stream” is never printed out. Why the EOS message is not being received by the bus_message_handler
? How is the proper way of implementing this Ctrl+C functionality to end properly the app? Currently the app finishes without receiving the EOS message, so the saved videos are corrupt.
Thanks.