refactor(main.py): update video rendering to handle asynchronous rendering and improve debug logging

This commit is contained in:
2025-09-08 00:37:04 +02:00
parent d1b26fe8b4
commit 6efbfa0c11

View File

@@ -2031,7 +2031,38 @@ class VideoEditor:
print(f"DEBUG: Created temp file: {temp_path}")
print("Rendering to temporary file first...")
success = self.render_video_sync(temp_path)
# 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
if success:
print("Replacing original file...")