Skip to content

Commit e3b6817

Browse files
sbryngelsonclaude
andcommitted
Replace deprecated imageio.get_writer with imageio.mimwrite
imageio.get_writer is deprecated in imageio v3. Switch to imageio.mimwrite, which is the recommended higher-level API for writing video files and works in both imageio v2 and v3. Also removes the manual writer.close() call since mimwrite handles resource cleanup internally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3a81a0f commit e3b6817

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

toolchain/mfc/viz/renderer.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,16 @@ def render_mp4(varname, steps, output, fps=10, # pylint: disable=too-many-argum
240240
print("imageio is not installed. Install it with: pip install imageio imageio-ffmpeg")
241241
return False
242242

243-
writer = None
244243
try:
245-
writer = imageio.get_writer(output, fps=fps, codec='libx264',
246-
pixelformat='yuv420p', macro_block_size=2)
247-
for fname in frame_files:
248-
writer.append_data(imageio.imread(os.path.join(viz_dir, fname)))
244+
imageio.mimwrite(
245+
output,
246+
[imageio.imread(os.path.join(viz_dir, fname)) for fname in frame_files],
247+
fps=fps, codec='libx264', pixelformat='yuv420p', macro_block_size=2,
248+
)
249249
success = True
250250
except (OSError, ValueError, RuntimeError) as exc:
251251
print(f"imageio MP4 write failed: {exc}")
252252
finally:
253-
if writer is not None:
254-
writer.close()
255253
# Always clean up temporary frame files
256254
for fname in frame_files:
257255
try:

0 commit comments

Comments
 (0)