From d94d827220c7a9720360ae0bee986abea690c544 Mon Sep 17 00:00:00 2001 From: Paillat Date: Fri, 1 Mar 2024 12:50:23 +0100 Subject: [PATCH] Fix VideoBackgroundEngine.py not working --- src/engines/BackgroundEngine/VideoBackgroundEngine.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/engines/BackgroundEngine/VideoBackgroundEngine.py b/src/engines/BackgroundEngine/VideoBackgroundEngine.py index 3669e3b..4531343 100644 --- a/src/engines/BackgroundEngine/VideoBackgroundEngine.py +++ b/src/engines/BackgroundEngine/VideoBackgroundEngine.py @@ -6,6 +6,7 @@ import time import gradio as gr import moviepy.editor as mp from moviepy.video.fx.crop import crop +from moviepy.video.fx.resize import resize from . import BaseBackgroundEngine @@ -47,15 +48,12 @@ class VideoBackgroundEngine(BaseBackgroundEngine): ) start = random.uniform(0, background_max_start) clip = background.subclip(start, start + self.ctx.duration) - w, h = clip.size self.ctx.credits += f"\n{self.background_video.data['credits']}" - if w == h: - clip = clip.resize(width=self.ctx.width) if w > h else clip.resize(height=self.ctx.height) - elif w > h: - clip = clip.resize(width=self.ctx.width) + clip = resize(clip, width=self.ctx.width, height=self.ctx.height) + w, h = clip.size + if w > h: clip = crop(clip, width=self.ctx.width, height=self.ctx.height, x_center=w / 2, y_center=h / 2) else: - clip = clip.resize(height=self.ctx.height) clip = crop(clip, width=self.ctx.width, height=self.ctx.height, x_center=w / 2, y_center=h / 2) self.ctx.index_0.append(clip)