refactor(main.py): optimize video processing by seeking once and reading sequentially to improve performance

This commit is contained in:
2025-09-08 16:23:37 +02:00
parent 87ead9189f
commit 4d60526952

View File

@@ -1587,10 +1587,13 @@ class VideoEditor:
self.render_progress_queue.put(("error", "Could not open video writer!", 1.0, 0.0))
return False
# Simple sequential processing - the I/O is the bottleneck anyway
# Optimized sequential processing - seek once, then read sequentially
total_output_frames = end_frame - start_frame + 1
last_progress_update = 0
# Seek once to the start frame
render_cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
for frame_idx in range(start_frame, end_frame + 1):
# Check for cancellation
if self.render_cancelled:
@@ -1598,8 +1601,7 @@ class VideoEditor:
self.render_progress_queue.put(("cancelled", "Render cancelled", 0.0, 0.0))
return False
# Read frame using the separate VideoCapture
render_cap.set(cv2.CAP_PROP_POS_FRAMES, frame_idx)
# Read frame sequentially
ret, frame = render_cap.read()
if not ret: