From 56d6e04b4894b726e5804a7cd343629936ffbf43 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 8 Sep 2025 00:38:51 +0200 Subject: [PATCH] refactor(main.py): simplify video rendering process by reusing existing method and reducing redundant code --- croppa/main.py | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/croppa/main.py b/croppa/main.py index cea6831..61eebb0 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -2032,37 +2032,15 @@ class VideoEditor: print(f"DEBUG: Created temp file: {temp_path}") print("Rendering to temporary file first...") - # Start render and wait for completion - if not self.render_video(temp_path): - success = False - else: - print("Waiting for render to complete...") - # Wait for the render thread to complete - while self.render_thread and self.render_thread.is_alive(): - # Process progress updates from the render thread - self.update_render_progress() - time.sleep(0.1) # Small delay to avoid busy waiting - - # Check if render was successful by looking at the final progress update - try: - # Get the last progress update to check if it completed successfully - while True: - update_type, text, progress, fps = self.render_progress_queue.get_nowait() - if update_type == "complete": - print(f"Render completed: {text}") - success = True - break - elif update_type == "error": - print(f"Render failed: {text}") - success = False - break - elif update_type == "cancelled": - print("Render was cancelled") - success = False - break - except queue.Empty: - # No more updates, assume it completed - success = True + # Use existing render method + success = self.render_video(temp_path) + + # Wait for render to complete using existing logic + while self.render_thread and self.render_thread.is_alive(): + self.update_render_progress() + self.display_current_frame() # Show the progress bar + cv2.waitKey(1) # Update the display + time.sleep(0.1) if success: print("Replacing original file...")