From 8cb0cbfa25d86965ddfeaf90a8270cabff720a34 Mon Sep 17 00:00:00 2001 From: simonkoson <28867558@qq.com> Date: Fri, 12 Jun 2026 18:20:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20frames/=20=E7=9B=AE=E5=BD=95=E5=8F=AA?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=85=B3=E9=94=AE=E5=B8=A7=20PNG=20+=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20stats=20=E8=AE=A1=E6=95=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=20+=20=E4=BF=AE=E6=AD=A3=20debug=20=E9=A2=84=E6=9C=9F?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doco/src/doco/video_split.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/doco/src/doco/video_split.py b/doco/src/doco/video_split.py index 7f73b0f..ede3b3a 100644 --- a/doco/src/doco/video_split.py +++ b/doco/src/doco/video_split.py @@ -543,10 +543,11 @@ def split_video( debug_csv=debug_csv_path, ) - # 统计各 decision + # 统计各 decision(frame_analysis 已包含所有非空白帧的 decision) for frame_idx, data in frame_analysis.items(): decision_stats[data["decision"]] = decision_stats.get(data["decision"], 0) + # 从 frame_analysis 统计中取 duplicate 相关计数(blank_count 已在上方单独统计) duplicate_iou = decision_stats.get("duplicate(iou)", 0) duplicate_hash = decision_stats.get("duplicate(hash)", 0) total_duplicate = blank_count + duplicate_iou + duplicate_hash @@ -555,11 +556,25 @@ def split_video( print(f"[video_split] 检测到 {len(keyframes)} 个关键帧") print(f"[video_split] 诊断CSV写入: {debug_csv_path}") - # 确认 frames/ 目录文件数与 total_extracted 一致 + # ---- 删除非关键帧,只保留最终关键帧 PNG ---- + # 建立应保留的帧索引集合 + keyframe_indices = set(kf["frame_index"] for kf in keyframes) + all_frame_files = sorted(frames_dir.glob("frame_*.png")) + deleted_count = 0 + for frame_file in all_frame_files: + # 从文件名 frame_0001.png 提取帧索引 + frame_idx = int(frame_file.stem.split("_")[1]) + if frame_idx not in keyframe_indices: + frame_file.unlink() + deleted_count += 1 + + print(f"[video_split] 清理非关键帧完成,删除 {deleted_count} 张,保留 {len(keyframes)} 张关键帧") + + # 确认 frames/ 目录文件数与关键帧数一致 actual_frame_files = len(list(frames_dir.glob("frame_*.png"))) - print(f"[debug] frames/ 目录实际文件数: {actual_frame_files} (预期: {total_extracted})") - if actual_frame_files != total_extracted: - print(f"[WARNING] frames/ 文件数({actual_frame_files}) 与抽帧数({total_extracted})不一致!") + print(f"[debug] frames/ 目录实际文件数: {actual_frame_files} (预期: {len(keyframes)})") + if actual_frame_files != len(keyframes): + print(f"[WARNING] frames/ 文件数({actual_frame_files}) 与关键帧数({len(keyframes)})不一致!") if dry_run: print("[video_split] dry-run:跳过 OCR")