Код: Выделить всё
full_frame_queue). Я хочу правильно остановить процесс, сначала остановив конвейер, а затем дождавшись присоединения процесса. Я могу установить для конвейера значение NULL, очередь пуста, но процесс все равно не присоединяется. Вот как я запускаю конвейерный процесс:
def start(self):
Gst.init(None)
self.capture_process = Process(target=self.capture_frame)
self.capture_process.start()
Код: Выделить всё
def capture_frame(self):
pipeline = self.__start_gstreamer_pipeline()
full_sink = pipeline.get_by_name("full_sink")
if not pipeline.set_state(Gst.State.PLAYING):
raise RuntimeError("Unable to set the pipeline to the playing state.")
try:
while self.running.is_set():
full_sample = full_sink.emit("pull-sample")
if full_sample:
self.process_frame(full_sample)
else:
time.sleep(0.1)
finally:
Gst.Element.send_event(pipeline, Gst.Event.new_eos())
print("EoS sent")
pipeline.set_state(Gst.State.NULL)
print("Switched to NULL state")
Код: Выделить всё
def stop(self):
if self.capture_process:
self.running.clear()
while not not self.full_frame_queue.empty():
self.full_frame_queue.get()
self.capture_process.join(timeout=10)
print("Capture process joined")
Подробнее здесь: https://stackoverflow.com/questions/786 ... -a-gstream