vidgod/patches/matanyone-cv2-reader.patch
type-two 7911a59186 VIDGOD: local AI video production toolkit
Five CLIs around DaVinci Resolve music-video editing, all inference local
on Apple Silicon (MPS/MLX):
- vg-roto: SAM 2.1 + MatAnyone click-to-cutout -> ProRes 4444 alpha
- vg-index / vg-find: PySceneDetect + mlx-whisper searchable clip library
- vg-beats: librosa beat grid -> Resolve marker EDL
- vg-transcode: legacy codecs -> ProRes LT, deinterlaced, resumable

setup/setup_venvs.sh rebuilds venvs, tool clones, checkpoints and applies
patches/matanyone-cv2-reader.patch (torchvision >= 0.23 removed read_video).
Verified end-to-end on ultra 2026-08-24; setup/smoke_test.sh covers the lanes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 14:17:50 +10:00

25 lines
1.1 KiB
Diff

diff --git a/matanyone/utils/inference_utils.py b/matanyone/utils/inference_utils.py
index c5bb6a0..41c4c40 100644
--- a/matanyone/utils/inference_utils.py
+++ b/matanyone/utils/inference_utils.py
@@ -12,8 +12,17 @@ VIDEO_EXTENSIONS = ('.mp4', '.mov', '.avi', '.MP4', '.MOV', '.AVI')
def read_frame_from_videos(frame_root):
if frame_root.endswith(VIDEO_EXTENSIONS): # Video file path
video_name = os.path.basename(frame_root)[:-4]
- frames, _, info = torchvision.io.read_video(filename=frame_root, pts_unit='sec', output_format='TCHW') # RGB
- fps = info['video_fps']
+ # torchvision.io.read_video was removed in torchvision >= 0.23 — read via cv2
+ cap = cv2.VideoCapture(frame_root)
+ fps = cap.get(cv2.CAP_PROP_FPS) or 24
+ frames = []
+ while True:
+ ok, frame = cap.read()
+ if not ok:
+ break
+ frames.append(frame[..., [2, 1, 0]]) # BGR -> RGB
+ cap.release()
+ frames = torch.from_numpy(np.array(frames)).permute(0, 3, 1, 2).contiguous() # TCHW
else:
video_name = os.path.basename(frame_root)
frames = []