From b404d8b3d71301c76f15d24106fb47d249f224d2 Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Mon, 11 May 2026 17:15:05 +0000 Subject: [PATCH] fix: guard against floating-point precision error in video subclip end_time MoviePy raises ValueErr --- twitter2bsky.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/twitter2bsky.py b/twitter2bsky.py index b6be625..a4c57be 100644 --- a/twitter2bsky.py +++ b/twitter2bsky.py @@ -2714,6 +2714,10 @@ def download_and_crop_video(video_url, output_path): return None 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) try: