fix with negative crop value

This commit is contained in:
2025-08-05 18:42:22 +02:00
parent 557a595a8f
commit 4ea3907108

View File

@@ -301,6 +301,7 @@ def _snap_to_known_ar_cropdetect(w, h, x, y, video_w, video_h, tolerance=0.03):
new_y = round((video_h - new_h) / 2) new_y = round((video_h - new_h) / 2)
if new_y % 2 != 0: if new_y % 2 != 0:
new_y -= 1 new_y -= 1
new_y = max(0, new_y)
return f"crop={video_w}:{new_h}:0:{new_y}", best_match['name'] return f"crop={video_w}:{new_h}:0:{new_y}", best_match['name']
if abs(h - video_h) < 16: if abs(h - video_h) < 16:
new_w = round(video_h * best_match['ratio']) new_w = round(video_h * best_match['ratio'])
@@ -309,6 +310,7 @@ def _snap_to_known_ar_cropdetect(w, h, x, y, video_w, video_h, tolerance=0.03):
new_x = round((video_w - new_w) / 2) new_x = round((video_w - new_w) / 2)
if new_x % 2 != 0: if new_x % 2 != 0:
new_x -= 1 new_x -= 1
new_x = max(0, new_x)
return f"crop={new_w}:{video_h}:{new_x}:0", best_match['name'] return f"crop={new_w}:{video_h}:{new_x}:0", best_match['name']
return f"crop={w}:{h}:{x}:{y}", None return f"crop={w}:{h}:{x}:{y}", None