|
@@ -272,9 +272,13 @@ def main():
|
|
|
ap.add_argument('--overlay', help='叠加一张半透明图片覆盖全画面(可配合 --overlay-alpha)')
|
|
ap.add_argument('--overlay', help='叠加一张半透明图片覆盖全画面(可配合 --overlay-alpha)')
|
|
|
ap.add_argument('--overlay-alpha', type=float, default=0.05,
|
|
ap.add_argument('--overlay-alpha', type=float, default=0.05,
|
|
|
help='叠加图层不透明度 0~1,默认 0.05(即 5%% 混合,肉眼近无感)')
|
|
help='叠加图层不透明度 0~1,默认 0.05(即 5%% 混合,肉眼近无感)')
|
|
|
|
|
+ ap.add_argument('--ab', action='store_true',
|
|
|
|
|
+ help='无感自AB模式(推荐):辅助流=主视频微变体(4px内缩重缩放+微量调色),'
|
|
|
|
|
+ '按 8.18 90模板交错——观看与快手转码后均呈现为原视频,但逐帧像素指纹被扰动')
|
|
|
ap.add_argument('--pair-video', metavar='PATH',
|
|
ap.add_argument('--pair-video', metavar='PATH',
|
|
|
- help='AB双视频模式:辅助视频与主视频帧级交错(8.18 AB视频模式同源)。'
|
|
|
|
|
- '辅助视频缩放到主视频尺寸,时间轴与主视频同步(含变速),音频取主视频')
|
|
|
|
|
|
|
+ help='AB双视频模式:外部辅助视频与主视频帧级交错(8.18 AB视频模式同源)。'
|
|
|
|
|
+ '**不同视频整帧替换,观感为画面周期闪切,仅用于有意混画的场景**;'
|
|
|
|
|
+ '要"看起来还是原视频"请用 --ab。辅助视频缩放到主视频尺寸,时间轴同步,音频取主视频')
|
|
|
ap.add_argument('--pair-ratio', type=float, default=0.33,
|
|
ap.add_argument('--pair-ratio', type=float, default=0.33,
|
|
|
help='AB交错中辅助视频的占空比,按 8.18 模板取 1/3(默认)或 2/3;'
|
|
help='AB交错中辅助视频的占空比,按 8.18 模板取 1/3(默认)或 2/3;'
|
|
|
'≤0.4 视为 1/3,>0.4 视为 2/3。输出帧率为基准的 3 倍,两流动作全速')
|
|
'≤0.4 视为 1/3,>0.4 视为 2/3。输出帧率为基准的 3 倍,两流动作全速')
|
|
@@ -313,6 +317,8 @@ def main():
|
|
|
sys.exit(f'辅助视频不存在: {pv}')
|
|
sys.exit(f'辅助视频不存在: {pv}')
|
|
|
if not (0.05 <= args.pair_ratio <= 0.95):
|
|
if not (0.05 <= args.pair_ratio <= 0.95):
|
|
|
sys.exit('--pair-ratio 取值范围 0.05~0.95(≤0.4=1/3占空,>0.4=2/3占空)')
|
|
sys.exit('--pair-ratio 取值范围 0.05~0.95(≤0.4=1/3占空,>0.4=2/3占空)')
|
|
|
|
|
+ if args.ab and pv is not None:
|
|
|
|
|
+ sys.exit('--ab(无感自AB)与 --pair-video(外部辅助视频)互斥')
|
|
|
report_path = out_dir / '处理报告.csv'
|
|
report_path = out_dir / '处理报告.csv'
|
|
|
fields = ['文件名', '输出名', '状态', '原分辨率', '原时长(s)', '新时长(s)',
|
|
fields = ['文件名', '输出名', '状态', '原分辨率', '原时长(s)', '新时长(s)',
|
|
|
'镜像', '裁剪', '旋转', '色温', 'HSL', '动态色相', '颗粒', '边框', '调色',
|
|
'镜像', '裁剪', '旋转', '色温', 'HSL', '动态色相', '颗粒', '边框', '调色',
|
|
@@ -330,9 +336,11 @@ def main():
|
|
|
fps_bad = (info['fps'] and info['real_fps'] and
|
|
fps_bad = (info['fps'] and info['real_fps'] and
|
|
|
abs(info['real_fps'] - info['fps']) / info['fps'] > 0.10)
|
|
abs(info['real_fps'] - info['fps']) / info['fps'] > 0.10)
|
|
|
pair_info = probe(pv) if pv is not None else None
|
|
pair_info = probe(pv) if pv is not None else None
|
|
|
|
|
+ use_ab = args.ab and pair_info is None
|
|
|
# AB 模式双流须统一到同一基准帧率:病源用实测帧率取整,正常源用标称
|
|
# AB 模式双流须统一到同一基准帧率:病源用实测帧率取整,正常源用标称
|
|
|
- base_nf = round(info['real_fps']) if (pair_info and fps_bad and info['real_fps']) else info['fps']
|
|
|
|
|
- if pair_info:
|
|
|
|
|
|
|
+ base_nf = (round(info['real_fps'])
|
|
|
|
|
+ if ((pair_info or use_ab) and fps_bad and info['real_fps']) else info['fps'])
|
|
|
|
|
+ if pair_info or use_ab:
|
|
|
cfg_file = dict(cfg, p_fps=0.0)
|
|
cfg_file = dict(cfg, p_fps=0.0)
|
|
|
elif fps_bad:
|
|
elif fps_bad:
|
|
|
cfg_file = dict(cfg, p_fps=0.0)
|
|
cfg_file = dict(cfg, p_fps=0.0)
|
|
@@ -343,8 +351,13 @@ def main():
|
|
|
if fps_bad:
|
|
if fps_bad:
|
|
|
t['帧率'] = (f"跳过(标称{info['fps']:.2f}/实测{info['real_fps']:.2f}fps,"
|
|
t['帧率'] = (f"跳过(标称{info['fps']:.2f}/实测{info['real_fps']:.2f}fps,"
|
|
|
"时间戳异常,重采样会损动作)")
|
|
"时间戳异常,重采样会损动作)")
|
|
|
- elif pair_info:
|
|
|
|
|
|
|
+ elif pair_info or use_ab:
|
|
|
t['帧率'] = f'跳过(AB模式统一基准{base_nf:g}fps)'
|
|
t['帧率'] = f'跳过(AB模式统一基准{base_nf:g}fps)'
|
|
|
|
|
+ # 自AB微变体参数:亚感知幅度(亮度±0.02/对比±2%/饱和±3%/色相±2°)+4px内缩重缩放
|
|
|
|
|
+ ab_b = rng.uniform(-0.02, 0.02)
|
|
|
|
|
+ ab_c = rng.uniform(0.98, 1.02)
|
|
|
|
|
+ ab_s = rng.uniform(0.97, 1.03)
|
|
|
|
|
+ ab_h = rng.uniform(-2.0, 2.0)
|
|
|
row['原分辨率'] = f"{info['w']}x{info['h']}"
|
|
row['原分辨率'] = f"{info['w']}x{info['h']}"
|
|
|
row['原时长(s)'] = f"{info['dur']:.1f}"
|
|
row['原时长(s)'] = f"{info['dur']:.1f}"
|
|
|
row.update(t)
|
|
row.update(t)
|
|
@@ -367,7 +380,6 @@ def main():
|
|
|
raise RuntimeError(f'叠加图层不存在: {ov}')
|
|
raise RuntimeError(f'叠加图层不存在: {ov}')
|
|
|
use_noise = noise_amp is not None
|
|
use_noise = noise_amp is not None
|
|
|
use_pair = pair_info is not None
|
|
use_pair = pair_info is not None
|
|
|
- # 输入序:0=主视频 [1=辅助视频] [2|1=蒙版图] [末=lavfi粉噪]
|
|
|
|
|
noise_idx = (1 if use_pair else 0) + (2 if ov is not None else 1)
|
|
noise_idx = (1 if use_pair else 0) + (2 if ov is not None else 1)
|
|
|
sp = misc['speed']
|
|
sp = misc['speed']
|
|
|
# 输出时长基准:主视频变速后时长;辅助视频同步变速,短了按帧数补、混合后 trim 锁长
|
|
# 输出时长基准:主视频变速后时长;辅助视频同步变速,短了按帧数补、混合后 trim 锁长
|
|
@@ -389,11 +401,11 @@ def main():
|
|
|
cmd += ['-f', 'lavfi', '-i',
|
|
cmd += ['-f', 'lavfi', '-i',
|
|
|
f'anoisesrc=color=pink:amplitude={noise_amp:.5f}:sample_rate=44100']
|
|
f'anoisesrc=color=pink:amplitude={noise_amp:.5f}:sample_rate=44100']
|
|
|
fc = None
|
|
fc = None
|
|
|
- if use_pair or ov is not None or use_noise:
|
|
|
|
|
|
|
+ if use_ab or use_pair or ov is not None or use_noise:
|
|
|
parts = []
|
|
parts = []
|
|
|
vchain = ','.join(vf)
|
|
vchain = ','.join(vf)
|
|
|
- if use_pair:
|
|
|
|
|
- # 8.18 AB视频模式模板原文(0x535b00 段,红蓝实测输出 BRR 循环@3×帧率):
|
|
|
|
|
|
|
+ if use_ab or use_pair:
|
|
|
|
|
+ # 8.18 AB模板(0x535b00 段,红蓝实测输出 BRR 循环@3×帧率):
|
|
|
# [0:v]setsar=1/1,fps=fps=90,select='if(gt(mod(n,3),0)+gt(t,T),1,0)':n=1[even];
|
|
# [0:v]setsar=1/1,fps=fps=90,select='if(gt(mod(n,3),0)+gt(t,T),1,0)':n=1[even];
|
|
|
# [1:v]setsar=1/1,fps=fps=90,select='if(lte(mod(n,3),0),1,0)':n=1[odd];
|
|
# [1:v]setsar=1/1,fps=fps=90,select='if(lte(mod(n,3),0),1,0)':n=1[odd];
|
|
|
# [even][odd]interleave[v_out] -map [v_out] -map 0:a? -r 90
|
|
# [even][odd]interleave[v_out] -map [v_out] -map 0:a? -r 90
|
|
@@ -403,20 +415,35 @@ def main():
|
|
|
a_fix = f',setpts=N/({info["real_fps"]:.4f}*{sp:.4f})/TB'
|
|
a_fix = f',setpts=N/({info["real_fps"]:.4f}*{sp:.4f})/TB'
|
|
|
else:
|
|
else:
|
|
|
a_fix = ''
|
|
a_fix = ''
|
|
|
- parts.append(f'[0:v]{vchain}{a_fix},setsar=1/1,fps=fps={3 * base_nf:g},'
|
|
|
|
|
- f"select='if(gt(mod(n\\,3)\\,0)+gt(t\\,99999)\\,1\\,0)':n=1[even];")
|
|
|
|
|
- bch = f'[1:v]scale={w}:{h}:flags=lanczos,setsar=1/1'
|
|
|
|
|
- if sp != 1.0:
|
|
|
|
|
- bch += f',setpts=PTS/{sp:.4f}'
|
|
|
|
|
- bch += f',fps=fps={3 * base_nf:g}'
|
|
|
|
|
- if pair_shorter:
|
|
|
|
|
- bch += f',tpad=stop={pad_frames}:stop_mode=clone'
|
|
|
|
|
y_thr = '0' if aux_third else '1'
|
|
y_thr = '0' if aux_third else '1'
|
|
|
- parts.append(bch + f','
|
|
|
|
|
- f"select='if(lte(mod(n\\,3)\\,{y_thr})\\,1\\,0)':n=1[odd];")
|
|
|
|
|
|
|
+ if use_ab:
|
|
|
|
|
+ # 无感自AB:主流变换链后 split,辅流为同内容微变体
|
|
|
|
|
+ # (亚感知调色+色相+轻颗粒,纯像素域扰动无空间位移——
|
|
|
|
|
+ # 实测4px内缩重缩放会有~2px位移,12ms周期闪现下可感为微抖)
|
|
|
|
|
+ parts.append(f'[0:v]{vchain}{a_fix},split=2[va][vb0];')
|
|
|
|
|
+ parts.append(f'[va]setsar=1/1,fps=fps={3 * base_nf:g},'
|
|
|
|
|
+ f"select='if(gt(mod(n\\,3)\\,0)+gt(t\\,99999)\\,1\\,0)':n=1[even];")
|
|
|
|
|
+ parts.append(f'[vb0]eq=brightness={ab_b:+.3f}:contrast={ab_c:.3f}:'
|
|
|
|
|
+ f'saturation={ab_s:.3f},hue=h={ab_h:+.1f},'
|
|
|
|
|
+ f'noise=alls=3:allf=t,'
|
|
|
|
|
+ f'setsar=1/1,fps=fps={3 * base_nf:g},'
|
|
|
|
|
+ f"select='if(lte(mod(n\\,3)\\,{y_thr})\\,1\\,0)':n=1[odd];")
|
|
|
|
|
+ t['AB交错'] = (f'自AB无感@{3 * base_nf:g}fps '
|
|
|
|
|
+ f'微变体{"1/3" if aux_third else "2/3"}')
|
|
|
|
|
+ else:
|
|
|
|
|
+ parts.append(f'[0:v]{vchain}{a_fix},setsar=1/1,fps=fps={3 * base_nf:g},'
|
|
|
|
|
+ f"select='if(gt(mod(n\\,3)\\,0)+gt(t\\,99999)\\,1\\,0)':n=1[even];")
|
|
|
|
|
+ bch = f'[1:v]scale={w}:{h}:flags=lanczos,setsar=1/1'
|
|
|
|
|
+ if sp != 1.0:
|
|
|
|
|
+ bch += f',setpts=PTS/{sp:.4f}'
|
|
|
|
|
+ bch += f',fps=fps={3 * base_nf:g}'
|
|
|
|
|
+ if pair_shorter:
|
|
|
|
|
+ bch += f',tpad=stop={pad_frames}:stop_mode=clone'
|
|
|
|
|
+ parts.append(bch + f','
|
|
|
|
|
+ f"select='if(lte(mod(n\\,3)\\,{y_thr})\\,1\\,0)':n=1[odd];")
|
|
|
|
|
+ t['AB交错'] = (f'90模板@{3 * base_nf:g}fps '
|
|
|
|
|
+ f'主{"2/3" if aux_third else "1/3"}/辅{"1/3" if aux_third else "2/3"}')
|
|
|
parts.append(f'[even][odd]interleave,trim=end_frame={n_out * 3}[v_mix];')
|
|
parts.append(f'[even][odd]interleave,trim=end_frame={n_out * 3}[v_mix];')
|
|
|
- t['AB交错'] = (f'90模板@{3 * base_nf:g}fps '
|
|
|
|
|
- f'主{"2/3" if aux_third else "1/3"}/辅{"1/3" if aux_third else "2/3"}')
|
|
|
|
|
if ov is not None:
|
|
if ov is not None:
|
|
|
ov_src = 2 if use_pair else 1
|
|
ov_src = 2 if use_pair else 1
|
|
|
parts.append(f'[{ov_src}:v]scale={w}:{h},format=rgba,'
|
|
parts.append(f'[{ov_src}:v]scale={w}:{h},format=rgba,'
|
|
@@ -463,7 +490,7 @@ def main():
|
|
|
cmd += ['-af', ','.join(af_parts)]
|
|
cmd += ['-af', ','.join(af_parts)]
|
|
|
else:
|
|
else:
|
|
|
cmd += ['-an']
|
|
cmd += ['-an']
|
|
|
- out_tail = (['-r', f'{3 * base_nf:g}'] if use_pair else []) + \
|
|
|
|
|
|
|
+ out_tail = (['-r', f'{3 * base_nf:g}'] if (use_pair or use_ab) else []) + \
|
|
|
['-pix_fmt', 'yuv420p', '-movflags', '+faststart', str(stage)]
|
|
['-pix_fmt', 'yuv420p', '-movflags', '+faststart', str(stage)]
|
|
|
return cmd + out_tail
|
|
return cmd + out_tail
|
|
|
|
|
|