|
|
@@ -388,6 +388,9 @@ def main():
|
|
|
'生产用途请改用 --ab,本参数仅供模板比对')
|
|
|
ap.add_argument('--pair-ratio', type=float, default=0.33,
|
|
|
help='(已废弃,仅 --pair-video 模板复现使用)辅助视频占空比 1/3 或 2/3')
|
|
|
+ ap.add_argument('--audio', metavar='PATH',
|
|
|
+ help='外部音频整体替换原声(BGM/配音,循环补足时长):搬运判重的音频指纹'
|
|
|
+ '证据链直接归零,与画面变换叠加使用;设置后忽略颤音/粉噪/音调链')
|
|
|
ap.add_argument('--mirror', action='store_true',
|
|
|
help='启用镜像翻转(默认关闭:画面文字/标识不反向;开启可额外改变视觉指纹)')
|
|
|
ap.add_argument('--vibrato', action='store_true',
|
|
|
@@ -433,10 +436,14 @@ def main():
|
|
|
sys.exit('--ab(几何重排)与 --ab-phantom(幻影注入)互斥,二选一')
|
|
|
if args.ab_phantom and pv is not None:
|
|
|
sys.exit('--ab-phantom 与 --pair-video 互斥')
|
|
|
+ au = Path(args.audio) if args.audio else None
|
|
|
+ if au is not None and not au.is_file():
|
|
|
+ sys.exit(f'替换音频不存在: {au}')
|
|
|
report_path = out_dir / '处理报告.csv'
|
|
|
fields = ['文件名', '输出名', '状态', '原分辨率', '原时长(s)', '新时长(s)',
|
|
|
'镜像', '几何重排', '裁剪', '旋转', '色温', 'HSL', '动态色相', '颗粒', '边框', '调色',
|
|
|
- '变速', '音调', '音频压缩', '颤音', '粉噪', '帧率', 'AB交错', '叠加图层', '隔行', '收尾']
|
|
|
+ '变速', '音调', '音频替换', '音频压缩', '颤音', '粉噪', '帧率', 'AB交错', '叠加图层',
|
|
|
+ '隔行', '收尾']
|
|
|
rows, ok, fail = [], 0, 0
|
|
|
|
|
|
print(f'共 {len(files)} 个视频,档位 {args.preset},输出 → {out_dir.resolve()}\n')
|
|
|
@@ -488,6 +495,10 @@ def main():
|
|
|
t['帧率'] = f'→{base_fps}fps基准+幻影注入'
|
|
|
elif pair_info:
|
|
|
t['帧率'] = '跳过(AB双流统一帧率)'
|
|
|
+ if au is not None: # 外部音频替换:原声证据链归零,音频处理链全部跳过
|
|
|
+ af_parts = []
|
|
|
+ noise_amp = None
|
|
|
+ t['音频替换'] = au.name
|
|
|
row['原分辨率'] = f"{info['w']}x{info['h']}"
|
|
|
row['原时长(s)'] = f"{info['dur']:.1f}"
|
|
|
row.update(t)
|
|
|
@@ -511,6 +522,8 @@ def main():
|
|
|
use_noise = noise_amp is not None
|
|
|
use_pair = pair_info is not None
|
|
|
noise_idx = (1 if use_pair else 0) + (2 if ov is not None else 1)
|
|
|
+ audio_idx = (1 if use_pair else 0) + (1 if ov is not None else 0) + \
|
|
|
+ (1 if use_noise else 0) + 1
|
|
|
sp = misc['speed']
|
|
|
# 输出时长基准:主视频变速后时长;掐头可选(--trim-head,B2考证:原版不掐头);
|
|
|
# 实拍循环流无限,用 -t 锁长
|
|
|
@@ -527,6 +540,8 @@ def main():
|
|
|
if use_noise:
|
|
|
cmd += ['-f', 'lavfi', '-i',
|
|
|
f'anoisesrc=color=pink:amplitude={noise_amp:.5f}:sample_rate=44100']
|
|
|
+ if au is not None:
|
|
|
+ cmd += ['-stream_loop', '-1', '-i', str(au)] # 替换音频循环补足
|
|
|
fc = None
|
|
|
if use_ph or use_pair or ov is not None or use_noise:
|
|
|
parts = []
|
|
|
@@ -579,14 +594,18 @@ def main():
|
|
|
cmd += ['-filter_complex', fc, '-map', '[v]']
|
|
|
else:
|
|
|
cmd += ['-vf', ','.join(vf), '-map', '0:v:0']
|
|
|
- if use_noise:
|
|
|
+ if au is not None:
|
|
|
+ cmd += ['-map', f'{audio_idx}:a:0']
|
|
|
+ elif use_noise:
|
|
|
cmd += ['-map', '[outa]']
|
|
|
elif info['has_audio']:
|
|
|
cmd += ['-map', '0:a:0']
|
|
|
cmd += ['-map_metadata', '-1',
|
|
|
'-metadata', f'creation_time={meta_time}']
|
|
|
cmd += encode_args(hw, args.interlace, args.crf, args.enc_preset)
|
|
|
- if use_noise:
|
|
|
+ if au is not None:
|
|
|
+ cmd += ['-c:a', 'aac', '-b:a', '160k']
|
|
|
+ elif use_noise:
|
|
|
cmd += ['-c:a', 'aac', '-b:a', '160k']
|
|
|
elif info['has_audio']:
|
|
|
cmd += ['-c:a', 'aac', '-b:a', '160k']
|
|
|
@@ -595,6 +614,7 @@ def main():
|
|
|
else:
|
|
|
cmd += ['-an']
|
|
|
out_tail = (['-t', f'{out_dur:.3f}'] if use_pair else []) + \
|
|
|
+ (['-shortest'] if au is not None else []) + \
|
|
|
['-pix_fmt', 'yuv420p', '-movflags', '+faststart', str(stage)]
|
|
|
return cmd + out_tail
|
|
|
|
|
|
@@ -612,7 +632,8 @@ def main():
|
|
|
stage.replace(dst)
|
|
|
t['收尾'] = '关闭'
|
|
|
else:
|
|
|
- r2 = run(finish_args(stage, dst, info['has_audio'], rng, meta_time))
|
|
|
+ r2 = run(finish_args(stage, dst, info['has_audio'] or au is not None,
|
|
|
+ rng, meta_time))
|
|
|
if r2.returncode != 0: # 收尾失败时保底用第一阶段产物
|
|
|
print(f' [收尾工序失败,保留未洗容器版本] {r2.stderr.strip()[:120]}')
|
|
|
stage.replace(dst)
|