Add UTF-8 image loading support in VideoEditor and update dependencies

This commit is contained in:
2025-09-26 11:05:14 +02:00
parent bae760837c
commit 5c66935157
2 changed files with 16 additions and 5 deletions

View File

@@ -12,6 +12,18 @@ import json
import subprocess
import queue
import ctypes
from PIL import Image
def load_image_utf8(image_path):
"""Load image with UTF-8 path support using PIL, then convert to OpenCV format"""
try:
# Use PIL to load image with UTF-8 support
pil_image = Image.open(image_path)
# Convert PIL image to OpenCV format (BGR)
cv_image = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
return cv_image
except Exception as e:
raise ValueError(f"Could not load image file: {image_path} - {e}")
class Cv2BufferedCap:
"""Buffered wrapper around cv2.VideoCapture that handles frame loading, seeking, and caching correctly"""
@@ -849,10 +861,8 @@ class VideoEditor:
self.is_image_mode = self._is_image_file(media_path)
if self.is_image_mode:
# Load static image
self.static_image = cv2.imread(str(media_path))
if self.static_image is None:
raise ValueError(f"Could not load image file: {media_path}")
# Load static image with UTF-8 support
self.static_image = load_image_utf8(media_path)
# Set up image properties to mimic video interface
self.frame_height, self.frame_width = self.static_image.shape[:2]