Skip to content

Reverse-engineer any video, shot by shot: filmed, AI-generated or coded, and how to remake it. Breakdowns in the open VIDEO.md format. 逆向一切视频,逐个镜头看是拍的、AI 生成的还是代码做的,再告诉你怎么复刻;拆解结果按 VIDEO.md 格式输出。

Keep face_area median at MIN_AREA and use linear projection for SFX subtraction

june99033f7ec8e2
diff --git a/rea_video/pipeline.py b/rea_video/pipeline.py
index 3dd2a9f..3f56917 100644
--- a/rea_video/pipeline.py
+++ b/rea_video/pipeline.py
@@ -22,7 +22,7 @@ from .motion import element_crops, motion_events, palette, strip_frames
from .shots import build_track, detect_shots
from .util import LOG, fmt_time, read_image, read_json, round_floats, write_json
from . import aspects
-from .faces import shot_faces
+from .faces import MIN_AREA, shot_faces
from .visual import LABEL_SHORT, shot_sheet, storyboard
from .i18n import T, join, semi, set_lang
from .vlm import SHOT_PROMPT, SILENT_NOTE, SOUND_NOTE, TAKE_NOTE, WHOLE_PROMPT, VLMClient, VLMConfig, normalize_shot_result, normalize_whole, prompt_lang_note, shot_hints, take_results, vlm_note
@@ -267,7 +267,7 @@ def decompose(video: str | Path, out_dir: str | Path, *, use_vlm: bool = False,
pic = [crop_box(f, lbox["box"]) for f in smp.frames] if lbox else smp.frames
fd = shot_faces(pic)
faces = fd["presence"]
- areas = [p["face"]["area"] for p in fd["frames"] if p.get("face")]
+ areas = [p["face"]["area"] for p in fd["frames"] if p.get("face") and p["face"]["area"] >= MIN_AREA]
feats["face_presence"] = faces
feats["face_area"] = float(np.median(areas)) if areas else 0.0
asp = aspects.measure_shot(pic, fd, feats, s.duration)
diff --git a/rea_video/stems.py b/rea_video/stems.py
index 7ee82c7..7cf8a84 100644
--- a/rea_video/stems.py
+++ b/rea_video/stems.py
@@ -170,21 +170,29 @@ def _without_effect_hits(inst: np.ndarray, effects_wav: str | Path) -> np.ndarra
from .effects import detect
hits = detect(effects_wav)
- r = subprocess.run(["ffmpeg", "-v", "error", "-i", str(effects_wav), "-ac", "2", "-ar", str(SR), "-f", "f32le", "-"], capture_output=True)
+ r = subprocess.run(["ffmpeg", "-v", "error", "-i", str(effects_wav), "-ac", "1", "-ar", str(SR), "-f", "f32le", "-"], capture_output=True)
if not hits or r.returncode != 0 or not r.stdout:
return inst
- fx = np.frombuffer(r.stdout, np.float32).reshape(-1, 2).T
+ fx = np.frombuffer(r.stdout, np.float32)
n = inst.shape[1]
- if fx.shape[1] < n:
- fx = np.pad(fx, ((0, 0), (0, n - fx.shape[1])))
- fx = fx[:, :n]
- gate = np.zeros(n, np.float32)
+ fx = np.pad(fx, (0, max(0, n - len(fx))))[:n]
+ sub = np.zeros_like(inst)
+ w = np.hanning(441).astype(np.float32)
+ w /= w.sum()
for e in hits:
- gate[max(0, int((e["t"] - 0.03) * SR)):min(n, int((e["t"] + e["dur"] + 0.08) * SR))] = 1
- w = np.hanning(441)
- gate = np.convolve(gate, w / w.sum(), "same").astype(np.float32) # 10 ms edges, no clicks
- sub = np.clip(gate * fx, -np.abs(inst), np.abs(inst))
- return np.where(np.abs(inst) > 1e-4, inst - sub, inst)
+ a, z = max(0, int((e["t"] - 0.03) * SR)), min(n, int((e["t"] + e["dur"] + 0.08) * SR))
+ if z <= a:
+ continue
+ seg = fx[a:z]
+ denom = float(np.dot(seg, seg)) + 1e-8
+ gate = np.zeros(z - a, np.float32)
+ gate[:] = 1.0
+ if len(gate) > len(w):
+ gate = np.convolve(gate, w, "same").astype(np.float32)
+ for c in range(inst.shape[0]):
+ gain = float(np.clip(np.dot(inst[c, a:z], seg) / denom, 0.0, 1.5))
+ sub[c, a:z] = np.where(gate > 0, gain * gate * seg, sub[c, a:z])
+ return inst - sub
SFX_DIR = "sfx"