07 Save Image Sequence to ZMongo
Park every frame as a document
- session
- images
- json
- refresh
- total_saved_frames
- success
Save Image Sequence to ZMongo takes an incoming image batch tensor and splits it into individual frames, saving each one as its own document in a ZMongo collection with a numbered filename and binary image envelope. Instead of a pile of PNGs in a folder you have to babysit, you get a queryable sequence of image documents in one collection, tagged with a common prefix.
The use case is stamped all over its defaults: image_prefix defaults to drone_stream, which tells you this pack was built with feed-style pipelines in mind - a continuous stream of frames you want to index, not a handful of renders. If you're generating video frames, running a monitoring-style batch, or producing any ordered set of images you want to look up later by number, this is the node that makes them database records rather than orphans on disk.
How it works
The node pulls the tensor out of the images input (handling both plain tensors and list-of-tensor layouts), determines the batch size from the shape, then iterates each frame. Frame N becomes a document with the filename <image_prefix>_<start_frame_number + N>.png (zero-padded to four digits), its pixels packed into a database binary envelope, plus metadata_json if you supplied any. Everything lands in collection_name (default image_sequences) through your session.
It reports total_saved_frames so you can sanity-check that the whole batch made it, and success reflects whether the run completed. Worth knowing: the write goes through session.save_value() with an upsert keyed on sequence_identifier + frame_index, so re-running the same batch with the same prefix and start frame updates the existing documents rather than duplicating them. And because it goes through the session, it works with either backend - hosted API or the Local File Store session, which implements the same save method.
Inputs and outputs that matter
session- aZMONGO_API_SESSION. Required. Works with either the API key session or the local file store session.collection_name- where the sequence goes (defaultimage_sequences).image_prefix- filename stem (defaultdrone_stream).start_frame_number- numbering offset for the first frame (default 0).images- the IMAGE batch. Optional on paper, but there's nothing to save without it.metadata_json- arbitrary JSON attached to the sequence docs.
Outputs: json (per-run payload), refresh (dirty token - bump to re-save), total_saved_frames (INT), and success (BOOLEAN).
Installing it
Pack-level install:
cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo
Restart ComfyUI, or install "ComfyUI-ZMongo" via ComfyUI Manager. The pack's requirements.txt pulls in a lot (pymongo, langchain, sentence-transformers, transformers), even for a node that mostly does tensor slicing.
Common issues
successfalse with "No valid image batch found" - theimagesinput was empty or an unrecognized shape. Make sure you're actually feeding a batch (4D tensor[B,H,W,C]); a single image as a 3D tensor may need batching first.- Frames saved but numbering looks off -
start_frame_numberoffsets the counter. Set it to match your sequence's true start. - Re-running the queue duplicates or overwrites frames - the node upserts on
sequence_identifier+frame_index, so a re-run updates the same documents in place. If you're seeing duplicates, you changed the prefix or start frame between runs, creating a different sequence key. - Sequence never shows up locally - if you're using the hosted API session, the frames went to the hosted collection, not your disk. Use the Local File Store session for on-disk storage.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| collection_name | STRING | image_sequences | — |
| image_prefix | STRING | drone_stream | — |
| start_frame_number | INT | 00–1000000 | — |
| imagesopt | IMAGE | — | |
| metadata_jsonopt | STRING | {} | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| refresh | STRING | — |
| total_saved_frames | INT | — |
| success | BOOLEAN | — |