diff --git a/anime_audio_encoder.py b/anime_audio_encoder.py index 4087203..c9174ff 100644 --- a/anime_audio_encoder.py +++ b/anime_audio_encoder.py @@ -270,17 +270,21 @@ def _snap_to_known_ar_cropdetect(w, h, x, y, video_w, video_h, tolerance=0.03): new_h = round(video_w / best_match['ratio']) if new_h % 8 != 0: new_h = new_h + (8 - (new_h % 8)) + new_h = min(new_h, video_h) new_y = round((video_h - new_h) / 2) if new_y % 2 != 0: new_y -= 1 + new_y = max(0, new_y) return f"crop={video_w}:{new_h}:0:{new_y}", best_match['name'] if abs(h - video_h) < 16: new_w = round(video_h * best_match['ratio']) if new_w % 8 != 0: new_w = new_w + (8 - (new_w % 8)) + new_w = min(new_w, video_w) new_x = round((video_w - new_w) / 2) if new_x % 2 != 0: 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={w}:{h}:{x}:{y}", None