From 7812dda9a0b8d950f7b511f4a8d3e00c73f22299 Mon Sep 17 00:00:00 2001 From: xiaoxia-bot Date: Tue, 14 Jul 2026 10:39:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20black=20+=20isort=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/worker/video_processing/render_audio.py | 3 +- apps/worker/video_processing/trim_engine.py | 8 ++---- .../unified_render_service.py | 28 +++++++++++++------ .../video_processing/watermark_engine.py | 20 +++++++++---- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/apps/worker/video_processing/render_audio.py b/apps/worker/video_processing/render_audio.py index 107076841..1c3082232 100755 --- a/apps/worker/video_processing/render_audio.py +++ b/apps/worker/video_processing/render_audio.py @@ -181,8 +181,7 @@ def concat_main_audio( trim_start = getattr(clip, "start_time", 0) or 0 if effective_duration > 0: filter_parts.append( - f"[{i}:a]atrim=start={trim_start:.3f}:duration={effective_duration:.3f}," - f"asetpts=PTS-STARTPTS[a{i}]" + f"[{i}:a]atrim=start={trim_start:.3f}:duration={effective_duration:.3f}," f"asetpts=PTS-STARTPTS[a{i}]" ) else: filter_parts.append(f"[{i}:a]asetpts=PTS-STARTPTS[a{i}]") diff --git a/apps/worker/video_processing/trim_engine.py b/apps/worker/video_processing/trim_engine.py index c17133d45..ada3f373a 100755 --- a/apps/worker/video_processing/trim_engine.py +++ b/apps/worker/video_processing/trim_engine.py @@ -293,9 +293,7 @@ class TrimEngine: return segments # 单段裁剪兼容:从 trim_start/trim_end/trim_duration 构造 - has_single = any( - k in config for k in ("trim_start", "trim_end", "trim_duration") - ) + has_single = any(k in config for k in ("trim_start", "trim_end", "trim_duration")) if has_single: seg = TrimSegment( segment_id="main", @@ -329,9 +327,7 @@ def extract_trim_from_clip_config(config: dict[str, Any] | None) -> TrimConfig | return TrimConfig.from_dict(config["trim"]) # 扁平字段 - has_any = any( - k in config for k in ("trim_start", "trim_end", "trim_duration") - ) + has_any = any(k in config for k in ("trim_start", "trim_end", "trim_duration")) if not has_any: return None diff --git a/apps/worker/video_processing/unified_render_service.py b/apps/worker/video_processing/unified_render_service.py index 0b2da607f..9b8b4b483 100755 --- a/apps/worker/video_processing/unified_render_service.py +++ b/apps/worker/video_processing/unified_render_service.py @@ -339,8 +339,11 @@ class UnifiedRenderService: logger.warning("片头视频不存在,跳过片头: %s", src) elif intro_outro_config.intro_type == "text": intro_ok = IntroOutroEngine.generate_text_intro( - intro_path, intro_outro_config, - self.output_width, self.output_height, self.output_fps, + intro_path, + intro_outro_config, + self.output_width, + self.output_height, + self.output_fps, ) if not intro_ok: @@ -361,8 +364,11 @@ class UnifiedRenderService: logger.warning("片尾视频不存在,跳过片尾: %s", src) elif intro_outro_config.outro_type in ("text", "follow"): outro_ok = IntroOutroEngine.generate_text_outro( - outro_path, intro_outro_config, - self.output_width, self.output_height, self.output_fps, + outro_path, + intro_outro_config, + self.output_width, + self.output_height, + self.output_fps, ) if not outro_ok: @@ -371,7 +377,10 @@ class UnifiedRenderService: # 拼接 if intro_path or outro_path: concat_ok = IntroOutroEngine.concat_with_intro_outro( - output_path, intro_path, outro_path, final_with_io, + output_path, + intro_path, + outro_path, + final_with_io, transition_duration=intro_outro_config.transition_duration, transition_effect=intro_outro_config.transition_effect, ) @@ -1301,9 +1310,12 @@ class UnifiedRenderService: wm_h = wm_scale # 近似(正方形假设) x, y = WatermarkEngine.calc_position( watermark_config.position, - self.output_width, self.output_height, - wm_scale, wm_h, - watermark_config.margin_x, watermark_config.margin_y, + self.output_width, + self.output_height, + wm_scale, + wm_h, + watermark_config.margin_x, + watermark_config.margin_y, ) # 滚动水印 diff --git a/apps/worker/video_processing/watermark_engine.py b/apps/worker/video_processing/watermark_engine.py index ffc3f1cc4..cc9c802d3 100755 --- a/apps/worker/video_processing/watermark_engine.py +++ b/apps/worker/video_processing/watermark_engine.py @@ -222,9 +222,13 @@ class WatermarkEngine: # 计算位置 x, y = WatermarkEngine.calc_position( - config.position, output_width, output_height, - wm_width, wm_width, # 高度未知,先用宽度估算 - config.margin_x, config.margin_y, + config.position, + output_width, + output_height, + wm_width, + wm_width, # 高度未知,先用宽度估算 + config.margin_x, + config.margin_y, ) # 滚动水印 @@ -288,9 +292,13 @@ class WatermarkEngine: # 位置计算 x, y = WatermarkEngine.calc_position( - config.position, output_width, output_height, - approx_w, approx_h, - config.margin_x, config.margin_y, + config.position, + output_width, + output_height, + approx_w, + approx_h, + config.margin_x, + config.margin_y, ) # 滚动水印