|
|
@@ -413,9 +413,11 @@ def compose(cfg: dict, video_path, image_path, title: str) -> Path:
|
|
|
# 5. 视频去重:复用 ../../video_dedup.py(README:集成自研去重工具)
|
|
|
# --------------------------------------------------------------------------
|
|
|
def dedup(cfg: dict, video_path) -> Path:
|
|
|
- """调用 video_dedup.py(-p strong)做指纹级去重,产出移入 临存视频/。
|
|
|
+ """调用 video_dedup.py 做指纹级去重,产出移入 临存视频/。
|
|
|
|
|
|
- - 命令:python video_dedup.py -i 视频 -o 临时目录 -p strong;
|
|
|
+ - 命令:python video_dedup.py -i 视频 -o 临时目录 -p <档位>;
|
|
|
+ - cfg['dedup']:preset(默认 strong)、mirror(默认 False=不镜像,
|
|
|
+ 画面文字/标识不反向;True=允许随机左右翻转,更强的指纹改变);
|
|
|
- 成功后取产物 mp4 移入 临存视频/,并去掉随机 token 还原为 videoId 原名;
|
|
|
- 脚本缺失/调用失败/无产物时【原样返回输入路径】并记日志(不中断流水线)。
|
|
|
"""
|
|
|
@@ -426,6 +428,7 @@ def dedup(cfg: dict, video_path) -> Path:
|
|
|
if not DEDUP_SCRIPT.exists():
|
|
|
_logger().warning('去重脚本不存在(%s),原样返回: %s', DEDUP_SCRIPT, video_path)
|
|
|
return video_path
|
|
|
+ ded = cfg.get('dedup') or {}
|
|
|
out_dir = config.dir_of(cfg, '临存视频')
|
|
|
out_dir.mkdir(parents=True, exist_ok=True)
|
|
|
dst = out_dir / f'{video_path.stem}.mp4' # 去掉 video_dedup 的随机 token,还原原名
|
|
|
@@ -437,7 +440,10 @@ def dedup(cfg: dict, video_path) -> Path:
|
|
|
try:
|
|
|
with tempfile.TemporaryDirectory(prefix='m3_dedup_') as td:
|
|
|
cmd = [sys.executable, str(DEDUP_SCRIPT),
|
|
|
- '-i', str(video_path), '-o', td, '-p', 'strong']
|
|
|
+ '-i', str(video_path), '-o', td,
|
|
|
+ '-p', str(ded.get('preset') or 'strong')]
|
|
|
+ if not ded.get('mirror', False):
|
|
|
+ cmd.append('--no-mirror')
|
|
|
r = subprocess.run(cmd, capture_output=True, text=True,
|
|
|
encoding='utf-8', errors='replace',
|
|
|
env=env, timeout=cfg.get('dedup_timeout', 1800))
|
|
|
@@ -497,5 +503,6 @@ def process_full(cfg: dict, video_id: str):
|
|
|
except Exception:
|
|
|
_logger().exception('process_full 处理失败: videoId=%r', video_id)
|
|
|
return None
|
|
|
+ db.exe('UPDATE biaoti SET chengpianPath=? WHERE biaoti1=?', (str(out), video_id))
|
|
|
_logger().info('process_full 成片完成: %r → %s', video_id, out)
|
|
|
return out
|