fix: guard against floating-point precision error in video subclip end_time MoviePy raises ValueErr

This commit is contained in:
2026-05-11 17:15:05 +00:00
parent a898d66fe7
commit b404d8b3d7

View File

@@ -2714,6 +2714,10 @@ def download_and_crop_video(video_url, output_path):
return None return None
end_time = min(VIDEO_MAX_DURATION_SECONDS, duration) end_time = min(VIDEO_MAX_DURATION_SECONDS, duration)
# Guard against floating-point precision errors where end_time == duration
# causes MoviePy to reject the subclip as out of bounds
end_time = min(end_time, duration - 0.05)
end_time = max(end_time, 0.1) # safety: never go negative or zero
video_clip = VideoFileClip(temp_input) video_clip = VideoFileClip(temp_input)
try: try: