From 0244ba5204c2d441b0ef54dcf84995c77ec6be49 Mon Sep 17 00:00:00 2001 From: Scott Register Date: Sat, 26 Jul 2025 09:24:30 -0700 Subject: [PATCH] fix some stuff --- vr180_matting/vr180_processor.py | 33 +++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/vr180_matting/vr180_processor.py b/vr180_matting/vr180_processor.py index 61e5aff..a32ed33 100644 --- a/vr180_matting/vr180_processor.py +++ b/vr180_matting/vr180_processor.py @@ -113,8 +113,23 @@ class VR180Processor(VideoProcessor): left_eye_frames = [] right_eye_frames = [] - for frame in frames: + for i, frame in enumerate(frames): left, right = self.split_sbs_frame(frame) + + # Debug: Check if frames are valid + if i == 0: # Only debug first frame + print(f"Original frame shape: {frame.shape}") + print(f"Left eye shape: {left.shape}") + print(f"Right eye shape: {right.shape}") + print(f"Left eye min/max: {left.min()}/{left.max()}") + print(f"Right eye min/max: {right.min()}/{right.max()}") + + # Validate frames + if left.size == 0: + raise RuntimeError(f"Left eye frame {i} is empty") + if right.size == 0: + raise RuntimeError(f"Right eye frame {i} is empty") + left_eye_frames.append(left) right_eye_frames.append(right) @@ -170,13 +185,22 @@ class VR180Processor(VideoProcessor): # Save frames as individual images print("Saving frames as images...") for i, frame in enumerate(eye_frames): + # Check if frame is empty + if frame.size == 0: + raise RuntimeError(f"Frame {i} is empty (size=0)") + # Ensure frame is uint8 if frame.dtype != np.uint8: frame = frame.astype(np.uint8) + # Debug first frame + if i == 0: + print(f"First frame to save: shape={frame.shape}, dtype={frame.dtype}, empty={frame.size == 0}") + frame_path = temp_frames_dir / f"frame_{i:06d}.png" success = cv2.imwrite(str(frame_path), frame) if not success: + print(f"Frame {i} details: shape={frame.shape}, dtype={frame.dtype}, size={frame.size}") raise RuntimeError(f"Failed to save frame {i} as image") if i % 50 == 0: @@ -184,13 +208,16 @@ class VR180Processor(VideoProcessor): # Use ffmpeg to create video from images import subprocess + # Use the original video's framerate + original_fps = getattr(self, 'fps', 30.0) ffmpeg_cmd = [ 'ffmpeg', '-y', # -y to overwrite output file - '-framerate', '30', + '-framerate', str(original_fps), '-i', str(temp_frames_dir / 'frame_%06d.png'), '-c:v', 'libx264', '-pix_fmt', 'yuv420p', - '-crf', '23', + '-crf', '18', # Higher quality (lower CRF) + '-preset', 'slow', # Better compression str(temp_video_path) ]