feat: 更新 CLI 支持 dhash/dhash_threshold/iou_threshold 参数,默认 dhash 算法
This commit is contained in:
+30
-3
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user