利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(video): finish slideout within short scene duration
Rudy Celekli3f14dd2d7837
diff --git a/app/services/utils/video_effects.py b/app/services/utils/video_effects.pyindex 7576fa2e..1dff6a0e 100644--- a/app/services/utils/video_effects.py+++ b/app/services/utils/video_effects.py@@ -45,7 +45,8 @@ def slidein_transition(clip: Clip, t: float, side: str) -> Clip:# SlideOutdef slideout_transition(clip: Clip, t: float, side: str) -> Clip:width, height = clip.size- transition_start = max(clip.duration - t, 0)+ transition_duration = min(t, clip.duration)+ transition_start = max(clip.duration - transition_duration, 0)# SlideOut 同样改成显式位移,保证片段末尾能稳定滑出画面。def position(current_time: float):@@ -53,7 +54,7 @@ def slideout_transition(clip: Clip, t: float, side: str) -> Clip:return (0, 0)progress = min(- max((current_time - transition_start) / max(t, 0.001), 0), 1+ max((current_time - transition_start) / max(transition_duration, 0.001), 0), 1)if side == "left":diff --git a/test/services/test_video_effects.py b/test/services/test_video_effects.pyindex 69d18434..a63bcb05 100644--- a/test/services/test_video_effects.py+++ b/test/services/test_video_effects.py@@ -193,3 +193,17 @@ class TestZoomTransitions(unittest.TestCase):if __name__ == "__main__":unittest.main()+++def test_slideout_short_scene_completes_requested_direction():+ """A one-second transition must finish inside a 0.2-second scene."""+ for side in ("left", "right", "top", "bottom"):+ clip = ImageClip(np.full((64, 64, 3), 255, dtype=np.uint8)).with_duration(0.2)+ outgoing = video_effects.slideout_transition(clip, 1.0, side)+ try:+ assert np.mean(outgoing.get_frame(0.0)) == 255+ assert np.mean(outgoing.get_frame(0.199)) < 10+ assert outgoing.duration == 0.2+ finally:+ outgoing.close()+ clip.close()