From f91efef935b7c4e25b5597d763632d4ce745cf16 Mon Sep 17 00:00:00 2001 From: simonkoson <28867558@qq.com> Date: Fri, 12 Jun 2026 18:06:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20CLI=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20dhash/dhash=5Fthreshold/iou=5Fthreshold=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0,=E9=BB=98=E8=AE=A4=20dhash=20=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doco/src/doco/cli.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/doco/src/doco/cli.py b/doco/src/doco/cli.py index e1617a8..e39f840 100644 --- a/doco/src/doco/cli.py +++ b/doco/src/doco/cli.py @@ -38,11 +38,29 @@ def main(): type=click.Path(), help="输出目录(work/ 路径)", ) +@click.option( + "--hash-algorithm", + default="dhash", + type=click.Choice(["dhash", "phash"]), + help="哈希算法:dhash(默认,对边缘敏感) 或 phash(感知哈希)", +) @click.option( "--phash-threshold", - default=8, + default=2, type=int, - help="pHash 海明距离阈值,用于检测字幕变化(默认 8)", + help="pHash 海明距离阈值(默认 2)", +) +@click.option( + "--dhash-threshold", + default=5, + type=int, + help="dHash 海明距离阈值(默认 5)", +) +@click.option( + "--iou-threshold", + default=0.95, + type=float, + help="IoU 保底阈值:二值化帧间 IoU > 此值视为同字幕(默认 0.95)", ) @click.option( "--dry-run", @@ -54,13 +72,16 @@ def split( episode_id: str, input_video: str, output_dir: str, + hash_algorithm: str, phash_threshold: int, + dhash_threshold: int, + iou_threshold: float, dry_run: bool, ): """ P1: 视频双路拆分 - A 路:抽帧 + pHash 变化检测 + OCR → B 稿 txt + A 路:抽帧 + 空白帧过滤 + 哈希变化检测 + OCR → B 稿 txt B 路:提取音频(16kHz/单声道/16bit WAV) 使用 --dry-run 可跳过 OCR 调用,先验证裁切框位置: @@ -74,7 +95,10 @@ def split( click.echo(f"[doco split] episode_id={episode_id}") click.echo(f"[doco split] input_video={video_path}") click.echo(f"[doco split] output_dir={out_dir}") + click.echo(f"[doco split] hash_algorithm={hash_algorithm}") click.echo(f"[doco split] phash_threshold={phash_threshold}") + click.echo(f"[doco split] dhash_threshold={dhash_threshold}") + click.echo(f"[doco split] iou_threshold={iou_threshold}") click.echo(f"[doco split] dry_run={dry_run}") try: @@ -82,7 +106,10 @@ def split( video_path=video_path, output_dir=out_dir, episode_id=episode_id, + hash_algorithm=hash_algorithm, phash_threshold=phash_threshold, + dhash_threshold=dhash_threshold, + iou_threshold=iou_threshold, dry_run=dry_run, ) if dry_run: