AI video skill for Claude Code & Codex — cinematic, editable product promos with Remotion: 124 shot recipe cards, 150 motion previews, beat sync, sound design, Motion Workbench & JianYing (CapCut CN) export.
TypeScript agent-skillsai-agentsai-videoclaude-codeclaude-code-skillsclaude-skillscodexmotion-designmotion-graphicsproduct-videopromo-videoremotionvideo-generationvideo-production
fix(qa): sample distinct frames from short clips (#113)
Andrew Barnesbd02e26d539f
diff --git a/shot-polish/sheet.py b/shot-polish/sheet.pyindex 87b661e..50cce5d 100644--- a/shot-polish/sheet.py+++ b/shot-polish/sheet.py@@ -1,11 +1,12 @@#!/usr/bin/env python3-"""sheet.py <video.mp4> <out.jpg> [n=8] — 均匀取 n 帧拼 4 列联系表,并打印所取帧号。"""+"""sheet.py <video.mp4> <out.jpg> [n=8] — 最多均匀取 n 帧拼 4 列联系表,并打印所取帧号。"""import subprocess, syssrc, dst = sys.argv[1], sys.argv[2]n = int(sys.argv[3]) if len(sys.argv) > 3 else 8tot = int(subprocess.check_output(['ffprobe', '-v', 'error', '-count_frames', '-select_streams', 'v:0','-show_entries', 'stream=nb_read_frames', '-of', 'csv=p=0', src]).decode().strip().strip(','))-picks = [round((k + .5) * tot / n) for k in range(n)]+n = min(n, tot)+picks = [(2 * k + 1) * tot // (2 * n) for k in range(n)]sel = '+'.join(f'eq(n\\,{p})' for p in picks)subprocess.check_call(['ffmpeg', '-v', 'error', '-y', '-i', src, '-vf',f"select='{sel}',scale=480:-1,tile=4x{(n + 3) // 4}", '-frames:v', '1', '-vsync', '0', dst])diff --git a/shot-polish/test_sheet.py b/shot-polish/test_sheet.pynew file mode 100644index 0000000..3f1ca09--- /dev/null+++ b/shot-polish/test_sheet.py@@ -0,0 +1,57 @@+"""Contact-sheet CLI regressions. Requires ffmpeg and ffprobe on PATH.++ python3 -m unittest discover -s shot-polish -p 'test_sheet.py' -v+"""+import re+import shutil+import subprocess+import sys+import tempfile+import unittest+from pathlib import Path++[email protected](shutil.which('ffmpeg') and shutil.which('ffprobe'),+ 'ffmpeg and ffprobe are required')+class SheetTest(unittest.TestCase):+ def test_short_clips_use_distinct_existing_frames(self):+ for frames, requested in [(1, 8), (2, 8), (8, 8), (30, 8), (8, 1), (8, 5)]:+ with self.subTest(frames=frames, requested=requested), \+ tempfile.TemporaryDirectory() as tmp:+ src = Path(tmp) / 'short clip.mkv'+ dst = Path(tmp) / 'contact sheet.png'+ subprocess.run([+ 'ffmpeg', '-v', 'error', '-f', 'lavfi', '-i',+ 'color=red:size=16x16:rate=30', '-frames:v', str(frames),+ '-c:v', 'ffv1', str(src),+ ], check=True, capture_output=True)+ result = subprocess.run([+ sys.executable, str(Path(__file__).with_name('sheet.py')),+ str(src), str(dst), str(requested),+ ], capture_output=True, text=True, encoding='utf-8')+ self.assertEqual(result.returncode, 0, result.stderr)+ match = re.search(r'sheet frames ([\d,]+)', result.stdout)+ self.assertIsNotNone(match, result.stdout)+ picks = list(map(int, match.group(1).split(',')))+ count = min(frames, requested)+ self.assertEqual(len(picks), count)+ self.assertEqual(picks, sorted(set(picks)))+ self.assertTrue(all(0 <= p < frames for p in picks), picks)+ self.assertTrue(dst.is_file(), result.stderr)+ pixels = subprocess.check_output([+ 'ffmpeg', '-v', 'error', '-i', str(dst),+ '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-',+ ])+ width = 4 * 480+ self.assertEqual(len(pixels), width * ((count + 3) // 4) * 480 * 3)+ for tile in range(count):+ x, y = (tile % 4) * 480 + 240, (tile // 4) * 480 + 240+ offset = (y * width + x) * 3+ red, green, blue = pixels[offset:offset + 3]+ self.assertGreater(red, 200, f'tile {tile} is blank')+ self.assertLess(green, 40)+ self.assertLess(blue, 40)+++if __name__ == '__main__':+ unittest.main()