""" Decode selected frame ranges of the test video, downscale to the detector's analysis resolution, and write raw RGBA frames + timing so the ACTUAL detector.js can be run in Node against real data. Binary format: header: =15 lead-in frames before each window for the rolling background. WINDOWS = [ (2580, 2660), # the real flash at 2612 (must still be detected) (2330, 2380), # the reported false positive at 2353-2358 / peak 2355 (2510, 2560), # prior false-positive cluster ~2535 (2080, 2160), # prior false-positive cluster ~2105 ] cap = cv2.VideoCapture(PATH) fps = cap.get(cv2.CAP_PROP_FPS) or 30.0 W = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)); H = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) scale = W/ANALYSIS_W if W > ANALYSIS_W else 1.0 aw = max(1, round(W/scale)); ah = max(1, round(H/scale)) want, seen = [], set() for a, b in WINDOWS: for i in range(a, b+1): if i not in seen: seen.add(i); want.append(i) want.sort() records = [] for idx in want: cap.set(cv2.CAP_PROP_POS_FRAMES, idx) ok, f = cap.read() if not ok: continue s = cv2.resize(f, (aw, ah), interpolation=cv2.INTER_AREA) rgba = cv2.cvtColor(s, cv2.COLOR_BGR2RGBA) records.append((idx, rgba.tobytes())) cap.release() with open(OUT, "wb") as fo: fo.write(struct.pack("