Skip to content

Commit 4b78bf1

Browse files
sbryngelsonclaude
andcommitted
Fix MP4 memory usage and remove cmcrameri-dependent colormaps
Stream MP4 frames incrementally via imageio.get_writer instead of loading all frames into memory at once with mimwrite (OOM risk for long videos). Remove berlin/managua/vanimo from the interactive colormap list — these require the optional cmcrameri package and silently fail without it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 32cbd52 commit 4b78bf1

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

toolchain/mfc/viz/interactive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"Blues", "Greens", "Oranges", "Reds", "Purples", "Greys",
2929
"twilight", "twilight_shifted", "hsv",
3030
"tab10", "tab20", "terrain", "ocean", "gist_earth",
31-
"gnuplot", "gnuplot2", "CMRmap", "cubehelix",
32-
"berlin", "managua", "vanimo", "Wistia",
31+
"gnuplot", "gnuplot2", "CMRmap", "cubehelix", "Wistia",
3332
]
3433

3534
# ---------------------------------------------------------------------------

toolchain/mfc/viz/renderer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,12 @@ def render_mp4(varname, steps, output, fps=10, # pylint: disable=too-many-argum
374374

375375
success = False
376376
try:
377-
imageio.mimwrite(
378-
output,
379-
[imageio.imread(os.path.join(viz_dir, fname)) for fname in frame_files],
380-
fps=fps, codec='libx264', pixelformat='yuv420p', macro_block_size=2,
381-
ffmpeg_log_level='error',
382-
)
377+
with imageio.get_writer(
378+
output, fps=fps, codec='libx264', pixelformat='yuv420p',
379+
macro_block_size=2, ffmpeg_log_level='error',
380+
) as writer:
381+
for fname in frame_files:
382+
writer.append_data(imageio.imread(os.path.join(viz_dir, fname)))
383383
success = True
384384
except (OSError, ValueError, RuntimeError) as exc:
385385
print(f"imageio MP4 write failed: {exc}")

0 commit comments

Comments
 (0)