ComfyUI Node

VideoCombineThenPath

Turn a frame batch into the mp4 the motion extractor will actually read

By chaojie·Created 3 years ago·Updated 2 years ago· 1
VideoCombineThenPath
  • images
  • path
frame_rate14

This node exists for one reason: Motion Vector Extractor can only read motion vectors from an actual H.264/MPEG-4 file, but everything in ComfyUI is a tensor. Something has to bridge the gap, and VideoCombineThenPath is that bridge. You feed it an IMAGE batch, it encodes those frames into an mp4 with ffmpeg, and returns the file path as a string - ready to plug straight into the extractor's video_url.

So in the pack's own example workflow it sits right in the middle: VHS_LoadVideoImage ResizeVideoCombineThenPathMotion Vector Extractor → the motionbrush JSON out to ShowText. Load a video, shrink it, re-encode it, read its motion.

How it works

The node is a tiny ffmpeg wrapper, about forty lines. It takes the IMAGE tensor (values 0–1), converts to 0–255 uint8 numpy, then shells out to ffmpeg to encode raw RGB frames to H.264:

ffmpeg -f rawvideo -pix_fmt rgb24 -s WxH -r <frame_rate> -i - \
       -crf 20 -c:v libx264 -pix_fmt yuv420p <comfy>/output/mvexrator.mp4

Then it returns that filename. The settings are hardcoded - constant crf 20, libx264, yuv420p. No knobs, no choices. It's an output node (OUTPUT_NODE = True), so it runs as a terminal step and doesn't need anything downstream.

The inputs

Just two, and honestly only one of them you'll touch:

  • images - the IMAGE batch to encode. Any sequence of frames: a loaded video, an AnimateDiff output, whatever.
  • frame_rate - the fps stamped onto the output clip, default 14, min 1. Keep it matched to your source footage; in the sample workflow 14 lines up with frame_length on the extractor and the frame cap on the video loader.

The output is a single path string: the absolute location of the written file. Wire that into Motion Vector Extractor's video_url and you're done.

Installing it

Same pack as the extractor - one install, both nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/chaojie/ComfyUI-Motion-Vector-Extractor
pip install motion-vector-extractor

Search "ComfyUI-Motion-Vector-Extractor" in ComfyUI Manager for the GUI route. The pip install step is what brings in the extractor's dependencies; this node itself only needs ffmpeg on your system.

The traps

ffmpeg must be on your PATH. The code resolves it with shutil.which("ffmpeg") at import time. If it's not found, the node just prints "no ffmpeg path" and then crashes the moment it tries to run the encoder. On Linux: sudo apt install ffmpeg. If you run the Windows portable you're already out of luck for the extractor half of this pack anyway.

The output filename is hardcoded to mvexrator.mp4. Every run overwrites the last one. That's convenient for feeding the extractor, but if you're using this as a general frames-to-video node it will clobber your work every time. Don't expect to collect clips.

It's deliberately dumb. No audio, no format options, no quality control beyond that fixed crf 20. If you just want to export a video from your image batch - not feed a motion-vector pipeline - you're better off with Video Helper Suite's proper encode nodes, which give you a tenth of the code's feature set but a hundred times the options. Reach for this node only when you're on the motion-brush workflow; that's the one job it does without fuss.

CategoryMotion Brush

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
frame_rateINT14

Outputs (1)

NameTypeDescription
pathSTRING