Compare commits

...

2 Commits

Author SHA1 Message Date
ea1a6e58f4 Enhance image and screenshot saving quality in VideoEditor
This commit updates the image and screenshot saving functionality in the VideoEditor class to use high-quality JPEG settings. The JPEG quality is set to 95, ensuring better image fidelity when saving processed frames and static images.
2025-09-19 07:17:52 +02:00
0c3e5e21bf Increase window dimensions in ProjectView and VideoEditor to accommodate 1080p videos. Adjust resizing logic to maintain original video quality by resizing the window instead of downscaling the video. Ensure frames fit within canvas bounds for better display. 2025-09-19 07:14:41 +02:00

View File

@@ -109,8 +109,8 @@ class ProjectView:
self.selected_index = 0 self.selected_index = 0
self.scroll_offset = 0 self.scroll_offset = 0
self.items_per_row = 2 # Default to 2 items per row self.items_per_row = 2 # Default to 2 items per row
self.window_width = 1200 self.window_width = 1920 # Increased to accommodate 1080p videos
self.window_height = 800 self.window_height = 1200
self._load_video_files() self._load_video_files()
self._load_progress_data() self._load_progress_data()
@@ -511,8 +511,8 @@ class VideoEditor:
# Mouse and keyboard interaction # Mouse and keyboard interaction
self.mouse_dragging = False self.mouse_dragging = False
self.timeline_rect = None self.timeline_rect = None
self.window_width = 1200 self.window_width = 1920 # Increased to accommodate 1080p videos
self.window_height = 800 self.window_height = 1200
# Auto-repeat seeking state # Auto-repeat seeking state
self.auto_repeat_active = False self.auto_repeat_active = False
@@ -791,8 +791,9 @@ class VideoEditor:
processed_frame = self.apply_crop_zoom_and_rotation(self.current_display_frame.copy()) processed_frame = self.apply_crop_zoom_and_rotation(self.current_display_frame.copy())
if processed_frame is not None: if processed_frame is not None:
# Save the processed frame # Save the processed frame with high quality settings
success = cv2.imwrite(str(screenshot_path), processed_frame) # Use JPEG quality 95 (0-100, where 100 is highest quality)
success = cv2.imwrite(str(screenshot_path), processed_frame, [cv2.IMWRITE_JPEG_QUALITY, 95])
if success: if success:
print(f"Screenshot saved: {screenshot_name}") print(f"Screenshot saved: {screenshot_name}")
self.show_feedback_message(f"Screenshot saved: {screenshot_name}") self.show_feedback_message(f"Screenshot saved: {screenshot_name}")
@@ -1872,23 +1873,39 @@ class VideoEditor:
height, width = display_frame.shape[:2] height, width = display_frame.shape[:2]
available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT) available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
# Don't downscale - keep original video quality
# If video is larger than window, we'll handle it by resizing the window
scale = min(self.window_width / width, available_height / height) scale = min(self.window_width / width, available_height / height)
if scale < 1.0: if scale < 1.0:
new_width = int(width * scale) # Resize window to fit video instead of downscaling video
new_height = int(height * scale) new_window_width = int(width * 1.1) # Add 10% padding
display_frame = cv2.resize(display_frame, (new_width, new_height)) new_window_height = int(height * 1.1) + (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
# Update window size
self.window_width = new_window_width
self.window_height = new_window_height
# Resize the OpenCV window
window_title = "Image Editor" if self.is_image_mode else "Video Editor"
cv2.resizeWindow(window_title, self.window_width, self.window_height)
# Create canvas with timeline space # Create canvas with timeline space
canvas = np.zeros((self.window_height, self.window_width, 3), dtype=np.uint8) canvas = np.zeros((self.window_height, self.window_width, 3), dtype=np.uint8)
# Center the frame on canvas # Center the frame on canvas
frame_height, frame_width = display_frame.shape[:2] frame_height, frame_width = display_frame.shape[:2]
available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
start_y = (available_height - frame_height) // 2 start_y = (available_height - frame_height) // 2
start_x = (self.window_width - frame_width) // 2 start_x = (self.window_width - frame_width) // 2
canvas[start_y : start_y + frame_height, start_x : start_x + frame_width] = ( # Ensure frame fits within canvas bounds
display_frame end_y = min(start_y + frame_height, available_height)
) end_x = min(start_x + frame_width, self.window_width)
actual_frame_height = end_y - start_y
actual_frame_width = end_x - start_x
if actual_frame_height > 0 and actual_frame_width > 0:
canvas[start_y:end_y, start_x:end_x] = display_frame[:actual_frame_height, :actual_frame_width]
# Draw crop selection preview during Shift+Click+Drag # Draw crop selection preview during Shift+Click+Drag
if self.crop_preview_rect: if self.crop_preview_rect:
@@ -2700,8 +2717,8 @@ class VideoEditor:
processed_image = self.apply_crop_zoom_and_rotation(self.static_image.copy()) processed_image = self.apply_crop_zoom_and_rotation(self.static_image.copy())
if processed_image is not None: if processed_image is not None:
# Save the image # Save the image with high quality settings
success = cv2.imwrite(output_path, processed_image) success = cv2.imwrite(output_path, processed_image, [cv2.IMWRITE_JPEG_QUALITY, 95])
if success: if success:
print(f"Image saved successfully to {output_path}") print(f"Image saved successfully to {output_path}")
return True return True