From 4a64e211f9e4bf3b5dd3b2afc186a9a968ce2263 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 10 May 2025 12:35:45 +0800 Subject: [PATCH] fix: correct condition for subclipping --- app/services/video.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/services/video.py b/app/services/video.py index e3a5abe..ea0344f 100644 --- a/app/services/video.py +++ b/app/services/video.py @@ -144,7 +144,7 @@ def combine_videos( while start_time < clip_duration: end_time = min(start_time + max_clip_duration, clip_duration) - if clip_duration - start_time > max_clip_duration: + if clip_duration - start_time >= max_clip_duration: subclipped_items.append(SubClippedVideoClip(file_path= video_path, start_time=start_time, end_time=end_time, width=clip_w, height=clip_h)) start_time = end_time if video_concat_mode.value == VideoConcatMode.sequential.value: @@ -171,7 +171,7 @@ def combine_videos( if clip_w != video_width or clip_h != video_height: clip_ratio = clip.w / clip.h video_ratio = video_width / video_height - logger.debug(f"resizing to {video_width}x{video_height}, source: {clip_w}x{clip_h}, ratio: {clip_ratio:.2f}, target ratio: {video_ratio:.2f}") + logger.debug(f"resizing clip, source: {clip_w}x{clip_h}, ratio: {clip_ratio:.2f}, target: {video_width}x{video_height}, ratio: {video_ratio:.2f}") if clip_ratio == video_ratio: clip = clip.resized(new_size=(video_width, video_height)) @@ -511,8 +511,7 @@ def preprocess_video(materials: List[MaterialInfo], clip_duration=4): # Output the video to a file. video_file = f"{material.url}.mp4" final_clip.write_videofile(video_file, fps=30, logger=None) - final_clip.close() - del final_clip + close_clip(clip) material.url = video_file logger.success(f"image processed: {video_file}") return materials \ No newline at end of file