diff --git a/NotEnoughAV1Encodes-Qt/NotEnoughAV1Encodes-Qt.py b/NotEnoughAV1Encodes-Qt/NotEnoughAV1Encodes-Qt.py index d8abadb..61c1890 100755 --- a/NotEnoughAV1Encodes-Qt/NotEnoughAV1Encodes-Qt.py +++ b/NotEnoughAV1Encodes-Qt/NotEnoughAV1Encodes-Qt.py @@ -1124,7 +1124,6 @@ def get_source_framecount(self): def calc_progress(self): log_path = os.path.join(self.tempDir, self.temp_dir_file_name, "Progress") - mux_path = os.path.join(self.tempDir, self.temp_dir_file_name, "Chunks", "mux.txt") # Create a QThread object self.calc_thread = QThread() # Create a worker object @@ -1132,7 +1131,7 @@ def calc_progress(self): # Move worker to the thread self.calc_worker.moveToThread(self.calc_thread) # Connect signals and slots - self.calc_thread.started.connect(partial(self.calc_worker.run, log_path, mux_path)) + self.calc_thread.started.connect(partial(self.calc_worker.run, log_path)) self.calc_worker.finished.connect(self.calc_thread.quit) self.calc_worker.finished.connect(self.calc_worker.deleteLater) self.calc_thread.finished.connect(self.calc_thread.deleteLater) @@ -1164,6 +1163,10 @@ def main_encode(self): self.calc_progress() def worker_finished(self): + # Stops Progress Worker + self.calc_worker.stop() + self.calc_thread.quit() + self.calc_thread.wait() self.labelStatus.setText("Status: Muxing") self.main_muxing() self.labelStatus.setText("Status: Finished") diff --git a/NotEnoughAV1Encodes-Qt/worker_progress.py b/NotEnoughAV1Encodes-Qt/worker_progress.py index f725928..022efd3 100644 --- a/NotEnoughAV1Encodes-Qt/worker_progress.py +++ b/NotEnoughAV1Encodes-Qt/worker_progress.py @@ -19,17 +19,16 @@ class WorkerProgress(QObject): """ progress = pyqtSignal(int) finished = pyqtSignal() + _is_running = True @pyqtSlot() - def run(self, progress_path, mux_path): + def run(self, progress_path): """ Attributes ---------- progress_path : path to where the log files are located """ - mux_file_not_written = True - while mux_file_not_written: + while self._is_running: # Pulls the framecount every 2 seconds - time.sleep(2) total_encoded_frames = 0 try: for filename in os.listdir(progress_path): @@ -41,7 +40,13 @@ def run(self, progress_path, mux_path): total_encoded_frames += int(lines[idx[-1]][6:]) except: pass - if os.path.isfile(mux_path): - mux_file_not_written = False - self.progress.emit(total_encoded_frames) + if self._is_running: + self.progress.emit(total_encoded_frames) + time.sleep(2) self.finished.emit() + + def stop(self): + """ + Stops the while loop in run() + """ + self._is_running = False