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 格式输出。
Python agent-skillsai-videoaigc-detectionclaude-codecodexffmpegprompt-engineeringremotionreverse-engineeringshort-videoshot-detectionsubtitlesvideo-analysisvideo-breakdownvideo-editingvideo-generationvideomdvlm
Share the test clip writer
junec97f28366457
diff --git a/tests/conftest.py b/tests/conftest.pyindex c087e65..cc41897 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -28,7 +28,7 @@ def _write(frames, path: Path, fps: int = 30) -> Path:for f in frames:p.stdin.write(f.tobytes())p.stdin.close()- p.wait()+ assert p.wait() == 0 and path.stat().st_size > 0, f"ffmpeg failed to write {path}"return pathdiff --git a/tests/test_motion.py b/tests/test_motion.pyindex bc2119c..427a0d8 100644--- a/tests/test_motion.py+++ b/tests/test_motion.py@@ -1,9 +1,8 @@"""Element motion timeline of code-rendered shots, flash cuts, counters and dark text on light grounds."""-import subprocess-import cv2import numpy as np+from conftest import _writefrom rea_video.media import video_infofrom rea_video.motion import event_line, motion_events, palettefrom rea_video.packaging import _NUMERIC, _norm, text_style@@ -14,23 +13,6 @@ def _close(a, b, tol=6):return all(abs(int(a[i:i + 2], 16) - int(b[i:i + 2], 16)) <= tol for i in (1, 3, 5))-def _write(path, frames, fps=30):- h, w = frames[0].shape[:2]- p = subprocess.Popen(- ["ffmpeg", "-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "bgr24",- "-s", f"{w}x{h}", "-r", str(fps), "-i", "-", "-c:v", "libx264",- "-pix_fmt", "yuv420p", "-crf", "16", str(path)],- stdin=subprocess.PIPE,- )- assert p.stdin is not None- for f in frames:- p.stdin.write(f.tobytes())- p.stdin.close()- assert p.wait() == 0- assert path.is_file() and path.stat().st_size > 0- return str(path)--def _staggered(n=90):"""Three cards pop in 0.5 s apart from 0.2 s, then a bar grows left to right from 1.5 s to 2.5 s."""frames = []@@ -47,7 +29,7 @@ def _staggered(n=90):def test_events_time_place_colour(tmp_path):- p = _write(tmp_path / "s.mp4", _staggered())+ p = str(_write(_staggered(), tmp_path / "s.mp4"))r = motion_events(p, video_info(p), 0.0, 3.0)ev = r["events"]cards = [e for e in ev if e["box"][1] < 0.4]@@ -79,7 +61,7 @@ def test_flash_cut_and_light_shot_not_a_fade(tmp_path):f = np.full((360, 200, 3), 255, np.uint8)cv2.putText(f, "TITLE", (40, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (40, 40, 40), 2)frames.append(f)- p = _write(tmp_path / "c.mp4", frames)+ p = str(_write(frames, tmp_path / "c.mp4"))shots = detect_shots(build_track(p, video_info(p)))assert [round(s.start, 1) for s in shots] == [0.0, 1.0, 2.0]assert shots[1].transition_in == "flash" and 0.1 <= shots[1].flash_s <= 0.4@@ -109,7 +91,7 @@ def test_element_crops_numbered_like_the_timeline(tmp_path):from rea_video.motion import element_crops- p = _write(tmp_path / "s.mp4", _staggered())+ p = str(_write(_staggered(), tmp_path / "s.mp4"))info = video_info(p)m = motion_events(p, info, 0.0, 3.0)sheet = element_crops(p, info, 0.0, 3.0, m, tmp_path / "shots", "shot_001", 360)