From 58a9c8ce3be430eebebae3dda9be655f876f936d Mon Sep 17 00:00:00 2001 From: pat-e Date: Sun, 20 Jul 2025 10:09:11 +0200 Subject: [PATCH] updated scene_cutter.py --- scene_cutter.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scene_cutter.py b/scene_cutter.py index 28cc8cd..e5604d7 100644 --- a/scene_cutter.py +++ b/scene_cutter.py @@ -91,13 +91,18 @@ def detect_crop(video_path, hwaccel=None): process.wait() if last_crop_line: - # Extract the crop filter part, e.g., "crop=1920:800:0:140" - crop_filter = last_crop_line.split('] ')[-1] - print(f"Crop detection finished. Recommended filter: {crop_filter}") - return crop_filter - else: - print("Could not determine crop. No black bars detected or an error occurred.") - return None + # Find the 'crop=' part in the line and extract it + crop_part_index = last_crop_line.find('crop=') + if crop_part_index != -1: + # Extract the substring starting from 'crop=' + crop_filter = last_crop_line[crop_part_index:] + # In case there's other info on the line, split by space and take the first part + crop_filter = crop_filter.split(' ')[0] + print(f"Crop detection finished. Recommended filter: {crop_filter}") + return crop_filter + + print("Could not determine crop. No black bars detected or an error occurred.") + return None except (FileNotFoundError, Exception) as e: print(f"\nAn error occurred during crop detection: {e}")