Nodes/DJZ-Nodes/Djz Datamosh V3
ComfyUI Node

Djz Datamosh V3

I-Frame Removal and Delta Repeats, the Authentic Way

By MushroomFleet·Created 2 years ago·Updated 5 months ago· 78
Djz Datamosh V3
  • images
  • IMAGE
mode
start_frame0
end_frame-1
delta_frames5

Djz Datamosh V3 is where this pack stops faking it with tensors and starts doing actual datamoshing - the codec-level technique that made the whole aesthetic famous. It encodes your frames into a video, surgically edits the compressed stream, and re-decodes it. The result is the authentic frozen-block, melting-texture glitch you see in music videos. It's not an approximation; it's the real thing happening in your ComfyUI graph.

The technique it implements is the classic one-two punch. iframe_removal strips I-frames (the full reference frames) out of the stream, which makes every subsequent delta frame decode against the wrong reference - producing that blocky smearing. delta_repeat keeps a window of P-frame deltas and replays them over and over, which locks frames and freezes motion into trails. Both are the canonical moves from the original datamoshing scripts.

How it works

The pipeline is gloriously old-school. Frames are written as PNGs, encoded to an AVI with ffmpeg, and then the file bytes are split on the 0x30306463 frame marker. Each frame's header byte tells it apart - 0x0001B0 is an I-frame, 0x0001B6 is a P-frame - and the node rewrites the stream according to your mode, dropping or repeating frames at the byte level. The edited AVI is then re-encoded to MP4 with ffmpeg and extracted back to frames. That's mosh.py's logic, faithfully reproduced.

Because it depends on ffmpeg on your PATH, this node is where DJZ-Nodes starts needing external binaries. torch and numpy are involved, but the actual work is done by ffmpeg.

The inputs that matter

  • mode - iframe_removal or delta_repeat. Start with iframe_removal; it's the more dramatic and the better intro.
  • start_frame / end_frame - the range of frames to mosh (end_frame -1 means "to the end"). Use these to keep your clean intro and outro.
  • delta_frames - for delta_repeat: how many delta frames to hold in the repeat window. 5 is a good starting point; higher locks longer.

Output is an IMAGE batch - note that the frame count may differ from your input, because frames get dropped and repeated.

Installing it

Djz Datamosh V3 ships in DJZ-Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/DJZ-Nodes
cd DJZ-Nodes
pip install -r requirements.txt

Restart ComfyUI, or install via Manager ("DJZ-Nodes"). Crucially, you need an ffmpeg binary on your system PATH - pip packages won't provide it. On Windows portable installs, the pack's install-portable.bat helps set things up.

Common issues

Two failure classes dominate. First, no ffmpeg on PATH → the node silently does nothing useful or errors out; verify ffmpeg -version works in the same environment ComfyUI runs in. Second, delta_repeat refuses to run if delta_frames is larger than your selected frame range (it prints "Not enough frames to repeat" and stops) - so keep the repeat window smaller than the range. And remember the frame count changes on output, so downstream nodes that expect the original batch length will need to handle the difference.

Categoryimage/effects

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
modeCOMBO2 options: iframe_removal, delta_repeat
start_frameINT00–999
end_frameINT-1-1–999
delta_framesINT51–30

Outputs (1)

NameTypeDescription
IMAGEIMAGE