stitch_slab_pngs.py User Guide
Use scripts/stitch_slab_pngs.py to build an MP4 by stitching one PNG type across slab folders (slab_z*) for each crop.
What it does
- Scans each crop folder for slab directories (e.g.,
slab_z0,slab_z10, …). - Picks a single PNG per slab (by suffix or glob).
- Orders frames by the numeric
zvalue in the slab folder name. - Writes an MP4 using
ffmpeg.
Requirements
ffmpegon PATH.- Slab PNGs created by
batch_clip.py(or equivalent).
CLI
python scripts/stitch_slab_pngs.py \
--root <CROP_ROOT> \
--png-suffix <PNG_SUFFIX> \
[--output-dir <OUT_DIR>] \
[--fps N] \
[--frame-hold N] \
[--combine-all] \
[--overwrite]Key options
--root– Root directory containingcrop_*folders.--crop-dir– Process a single crop directory instead of all crops.--slab-glob– Slab folder glob (defaultslab_z*).--png-suffix– PNG filename suffix to match (e.g.,composite_density_walls_filaments.png).--png-glob– Full glob pattern for PNGs inside each slab (use this or--png-suffix).--output– Output MP4 path (single crop only).--output-dir– Output directory for per-crop MP4 files.--fps– Frames per second (default 30).--frame-hold– Hold each frame for N×(1/--fps) seconds (default 1).--combine-all– Build one MP4 across all crops, ordered by slab z.--overwrite– Overwrite existing MP4s.--dry-run– Print actions without runningffmpeg.
Example: all crops, composite PNGs
python scripts/stitch_slab_pngs.py \
--root outputs/quijote_batches_000_test_2fil \
--png-suffix composite_density_walls_filaments_filament_manifolds.png \
--output-dir outputs/quijote_batches_000_test_2fil/moviesExample: single crop, density PNGs
python scripts/stitch_slab_pngs.py \
--crop-dir outputs/quijote_batches_000_test_2fil/crop_x500-1000_y500-1000_z900-1000 \
--png-suffix density.png \
--output outputs/quijote_batches_000_test_2fil/crop_x500-1000_y500-1000_z900-1000/density.mp4Example: one MP4 across all crops (ordered by z)
python scripts/stitch_slab_pngs.py \
--root outputs/quijote_batches_000_test_2fil \
--png-suffix walls_3d.png \
--combine-all \
--output-dir outputs/quijote_batches_000_test_2fil/movies \
--frame-hold 2Notes
- If multiple PNGs match in a slab, the first one is used and a warning is printed.
- The script uses a concat list so non-sequential slab indices are fine.
- Use
--dry-runif you want to verify the frame list before encoding.