From 0da1f03feaa9ba3212b90cca06ac1a57d3b7e2ff Mon Sep 17 00:00:00 2001 From: Billy Bjork Date: Sun, 18 Jan 2026 13:42:39 -0800 Subject: [PATCH] fix(VideoWriter): close depth_writer in close() method The VideoWriter class was not closing the depth video writer, causing corrupted/unplayable depth map video files. The imageio writer requires close() to be called to finalize the video file. Changes: - Initialize self.depth_writer = None before conditional assignment (fixes potential AttributeError when render_depth=False) - Add depth_writer.close() call in close() method --- src/sharp/utils/io.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sharp/utils/io.py b/src/sharp/utils/io.py index 07a98be..bee5d97 100644 --- a/src/sharp/utils/io.py +++ b/src/sharp/utils/io.py @@ -189,6 +189,7 @@ def __init__(self, output_path: Path, fps: float = 30.0, render_depth: bool = Tr self.image_writer = iio.get_writer(output_path, fps=fps) self.max_depth_estimate = None + self.depth_writer = None if render_depth: self.depth_writer = iio.get_writer(output_path.with_suffix(".depth.mp4"), fps=fps) @@ -211,3 +212,5 @@ def add_frame(self, image: torch.Tensor, depth: torch.Tensor) -> None: def close(self): """Finish writing.""" self.image_writer.close() + if self.depth_writer is not None: + self.depth_writer.close()