Fix SAM2 missing early watermarks: always sample first 15 seconds
Docker Build and Push / build-and-push (cuda, 12.6) (push) Has been skipped
Docker Build and Push / check-secrets (push) Failing after 3s
Docker Build and Push / build-and-push (cpu, latest) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 11.8) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.8) (push) Has been skipped
Docker Build and Push / build-and-push (directml, latest) (push) Has been skipped
Build Windows CPU / build (push) Has been cancelled
Build Windows CUDA 11.8 / build (push) Has been cancelled
Build Windows CUDA 12.6 / build (push) Has been cancelled
Build Windows CUDA 12.8 / build (push) Has been cancelled
Build Windows DirectML / build (push) Has been cancelled
Docker Build and Push / build-and-push (cuda, 12.6) (push) Has been skipped
Docker Build and Push / check-secrets (push) Failing after 3s
Docker Build and Push / build-and-push (cpu, latest) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 11.8) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.8) (push) Has been skipped
Docker Build and Push / build-and-push (directml, latest) (push) Has been skipped
Build Windows CPU / build (push) Has been cancelled
Build Windows CUDA 11.8 / build (push) Has been cancelled
Build Windows CUDA 12.6 / build (push) Has been cancelled
Build Windows CUDA 12.8 / build (push) Has been cancelled
Build Windows DirectML / build (push) Has been cancelled
For long videos (e.g. 1100s), uniform sampling started at ~23s, completely missing watermarks that appear at 1s, 2s, 4s. Fix: always include dense samples at 0.5, 1, 1.5, 2, 3, 4, 5, 7, 10, 15 seconds before the uniform distribution, then deduplicate. Watermarks in the first 15s are now caught. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
b772ab3def
commit
9094b3c888
@@ -27,8 +27,19 @@ def detect_static_regions(video_path: str, sample_frames: int = 30, threshold: f
|
||||
|
||||
duration_s = total / fps
|
||||
num_samples = max(10, min(24, int(duration_s // 8)))
|
||||
positions = [min(int((i + 0.5) * total / num_samples), total - 1)
|
||||
for i in range(num_samples)]
|
||||
uniform_positions = [min(int((i + 0.5) * total / num_samples), total - 1)
|
||||
for i in range(num_samples)]
|
||||
|
||||
# 水印常出现在视频开头几秒,强制加密采样前15秒
|
||||
early_seconds = [0.5, 1, 1.5, 2, 3, 4, 5, 7, 10, 15]
|
||||
early_positions = [min(int(s * fps), total - 1) for s in early_seconds if s * fps < total]
|
||||
# 合并去重,保持顺序
|
||||
seen = set()
|
||||
positions = []
|
||||
for p in early_positions + uniform_positions:
|
||||
if p not in seen:
|
||||
seen.add(p)
|
||||
positions.append(p)
|
||||
|
||||
bgr_frames = []
|
||||
gray_frames = []
|
||||
@@ -40,7 +51,7 @@ def detect_static_regions(video_path: str, sample_frames: int = 30, threshold: f
|
||||
gray_frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY).astype(np.float32))
|
||||
cap.release()
|
||||
|
||||
print(f"[SAM2-detect] 采样 {len(bgr_frames)} 帧 (均匀分布于{duration_s:.1f}s视频)", flush=True)
|
||||
print(f"[SAM2-detect] 采样 {len(bgr_frames)} 帧 (前15秒密采+均匀分布,共{duration_s:.1f}s)", flush=True)
|
||||
|
||||
if len(bgr_frames) < 4:
|
||||
print(f"[SAM2-detect] 帧数不足4帧,返回空", flush=True)
|
||||
|
||||
Reference in New Issue
Block a user