From b8dfef1f6a6cfb607b8946ba22bfbca2ef25a56a Mon Sep 17 00:00:00 2001 From: CI Test Date: Fri, 26 Jun 2026 20:56:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DPIP=20overlay=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E3=80=81=E9=9F=B3=E9=A2=91=E7=B4=A2=E5=BC=95=E3=80=81?= =?UTF-8?q?=E5=B8=A7=E7=8E=87=E7=BB=9F=E4=B8=80=E7=AD=89=E5=85=B3=E9=94=AE?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/worker/video_processing/editing_modes.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) mode change 100755 => 100644 apps/worker/video_processing/editing_modes.py diff --git a/apps/worker/video_processing/editing_modes.py b/apps/worker/video_processing/editing_modes.py old mode 100755 new mode 100644 index 5e27a18b3..3232d0aa0 --- a/apps/worker/video_processing/editing_modes.py +++ b/apps/worker/video_processing/editing_modes.py @@ -186,9 +186,10 @@ class EditingModeProcessor: return position_offsets.get(self.config.pip_position, position_offsets[PIPPosition.TOP_RIGHT]) def _normalize_video(self, input_path: str, output_path: str) -> dict: - """标准化视频格式""" + """标准化视频格式:先统一帧率,再缩放/填充""" command = [ self._ffmpeg_bin, "-y", "-i", input_path, + "-r", str(self.config.output_fps), # 先统一帧率 "-vf", f"scale={self.config.output_width}:{self.config.output_height}:force_original_aspect_ratio=decrease,pad={self.config.output_width}:{self.config.output_height}:(ow-iw)/2:(oh-ih)/2,setsar=1", "-r", str(self.config.output_fps), "-c:v", self.config.output_codec, @@ -320,7 +321,7 @@ class EditingModeProcessor: command = [ self._ffmpeg_bin, "-y", "-i", main_normalized, "-i", pip_normalized_input, - "-filter_complex", f"[1:v][0:v]overlay={x_offset}:{y_offset}[v]", + "-filter_complex", f"[0:v][1:v]overlay={x_offset}:{y_offset}[v]", "-map", "[v]", "-c:v", self.config.output_codec, "-preset", self.config.output_preset, "-crf", str(self.config.output_crf), "-pix_fmt", "yuv420p", output_path, @@ -381,7 +382,7 @@ class EditingModeProcessor: command = [ self._ffmpeg_bin, "-y", "-i", blurred_bg, "-i", audio_path, - "-filter_complex", "[0:v]drawbox=x=0:y=0:w=iw:h=ih:color=black@0.3:enable='between(t,0,0)'[v]", + "-filter_complex", "[0:v]drawbox=x=0:y=0:w=iw:h=ih:color=black@0.3:t=fill[v]", "-map", "[v]", "-map", "1:a", "-c:v", self.config.output_codec, "-preset", self.config.output_preset, "-crf", str(self.config.output_crf), "-pix_fmt", "yuv420p", "-shortest", output_path, @@ -439,7 +440,7 @@ class EditingModeProcessor: if audio_path: command = [ self._ffmpeg_bin, "-y", "-i", bg_adjusted, "-i", voice_adjusted, "-i", audio_path, - "-filter_complex", f"[1:v][0:v]overlay={x_offset}:{y_offset}[v]", + "-filter_complex", f"[0:v][1:v]overlay={x_offset}:{y_offset}[v]", "-map", "[v]", "-map", "2:a", "-shortest", "-c:v", self.config.output_codec, "-preset", self.config.output_preset, "-crf", str(self.config.output_crf), "-pix_fmt", "yuv420p", output_path, @@ -447,7 +448,7 @@ class EditingModeProcessor: else: command = [ self._ffmpeg_bin, "-y", "-i", bg_adjusted, "-i", voice_adjusted, - "-filter_complex", f"[1:v][0:v]overlay={x_offset}:{y_offset}[v]", + "-filter_complex", f"[0:v][1:v]overlay={x_offset}:{y_offset}[v]", "-map", "[v]", "-map", "1:a", "-shortest", "-c:v", self.config.output_codec, "-preset", self.config.output_preset, "-crf", str(self.config.output_crf), "-pix_fmt", "yuv420p", output_path,