From 77be2ab6aa3009c936a096f1be78ae485000c23d Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 10 Apr 2026 08:53:04 -0400 Subject: [PATCH] fix aspect ratio matching --- ...lan_generate_video_fal_seedance_1p5_pro.rs | 18 +++++++++++- .../video/tests/test_seedance_1p5_pro.rs | 28 ++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/fal/plan_generate_video_fal_seedance_1p5_pro.rs b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/fal/plan_generate_video_fal_seedance_1p5_pro.rs index 2fc876b50e..41690fd945 100644 --- a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/fal/plan_generate_video_fal_seedance_1p5_pro.rs +++ b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/fal/plan_generate_video_fal_seedance_1p5_pro.rs @@ -118,11 +118,27 @@ fn plan_aspect_ratio( value: format!("{:?}", unsupported), })) } - _ => Ok(Some(Ar::Auto)), + _ => Ok(Some(nearest_aspect_ratio(unsupported))), }, } } +/// Pick the nearest supported aspect ratio for unsupported inputs. +fn nearest_aspect_ratio(aspect_ratio: CommonAspectRatio) -> FalSeedance1p5ProAspectRatio { + use FalSeedance1p5ProAspectRatio as Ar; + match aspect_ratio { + // Wide unsupported → nearest wide + CommonAspectRatio::WideFiveByFour => Ar::FourByThree, // 1.25 → 1.33 + CommonAspectRatio::WideThreeByTwo => Ar::FourByThree, // 1.50 → 1.33 + // Tall unsupported → nearest tall + CommonAspectRatio::TallFourByFive => Ar::ThreeByFour, // 0.80 → 0.75 + CommonAspectRatio::TallTwoByThree => Ar::ThreeByFour, // 0.67 → 0.75 + CommonAspectRatio::TallNineByTwentyOne => Ar::NineBySixteen, // 0.43 → 0.56 + // Anything else → Square + _ => Ar::Square, + } +} + fn plan_resolution( resolution: Option, strategy: RequestMismatchMitigationStrategy, diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/generate/video/tests/test_seedance_1p5_pro.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/generate/video/tests/test_seedance_1p5_pro.rs index 5dfb5d9018..486ac4d27d 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/generate/video/tests/test_seedance_1p5_pro.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/generate/video/tests/test_seedance_1p5_pro.rs @@ -359,26 +359,40 @@ mod tests { }); } - // ── Unsupported aspect ratios fall back under PayMoreUpgrade ────────── + // ── Unsupported aspect ratios fall back to nearest under PayMoreUpgrade #[test] - fn wide_5x4_falls_back_to_auto() { + fn wide_5x4_falls_back_to_four_by_three() { with_text_plan(&make_request(Some("p"), Some(CommonAspectRatio::WideFiveByFour), None, None, None, None, None), |plan| { - assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::Auto))); + assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::FourByThree))); }); } #[test] - fn wide_3x2_falls_back_to_auto() { + fn wide_3x2_falls_back_to_four_by_three() { with_text_plan(&make_request(Some("p"), Some(CommonAspectRatio::WideThreeByTwo), None, None, None, None, None), |plan| { - assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::Auto))); + assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::FourByThree))); }); } #[test] - fn tall_4x5_falls_back_to_auto() { + fn tall_4x5_falls_back_to_three_by_four() { with_text_plan(&make_request(Some("p"), Some(CommonAspectRatio::TallFourByFive), None, None, None, None, None), |plan| { - assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::Auto))); + assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::ThreeByFour))); + }); + } + + #[test] + fn tall_2x3_falls_back_to_three_by_four() { + with_text_plan(&make_request(Some("p"), Some(CommonAspectRatio::TallTwoByThree), None, None, None, None, None), |plan| { + assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::ThreeByFour))); + }); + } + + #[test] + fn tall_9x21_falls_back_to_nine_by_sixteen() { + with_text_plan(&make_request(Some("p"), Some(CommonAspectRatio::TallNineByTwentyOne), None, None, None, None, None), |plan| { + assert!(matches!(plan.aspect_ratio, Some(FalSeedance1p5ProAspectRatio::NineBySixteen))); }); }