fix: 修复PIP overlay顺序、音频索引、帧率统一等关键bug
This commit is contained in:
Executable → Regular
+6
-5
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user