Nodes/CMK Flow/CMK Merge and Save Video
ComfyUI Node

CMK Merge and Save Video

CMK Merge and Save Video

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK Merge and Save Video
  • SEGMENTS
  • LOG
  • VIDEO
  • FULLPATH
  • LOG
  • diagnostic
◄SAVE ENABLEDfalse►
◄FILENAME PREFIXvideo►
◄OUTPUT FOLDERvideo/final►
◄VIDEO CODEClibx264►
◄VIDEO BITRATE8000k►
◄PRESETfast►

If you've ever processed a video node-by-node in ComfyUI, you know the ending: a folder of processed clips with gaps where the segment boundaries were, and a lot of manual ffmpeg. CMK Split Video into Segments gets you the segments. This node puts them back.

CMK Merge and Save Video takes the persistent CMK_VIDEO_SEGMENTS context, removes the overlaps the split introduced, concatenates everything into one file with ffmpeg, shows it in the player, and - optionally, and this is the bit people miss - republishes it without re-encoding the parts that didn't change.

What it's actually doing

The segment payload carries a manifest: per-segment start and end timestamps, plus the video codec, bitrate and preset that were used to produce them. From those timestamps the node computes a trim per segment - previous_end - current_start, floored at zero - and builds an ffmpeg filter graph that trims and concatenates in one pass:

[0:v:0]trim=start=0.000000,setpts=PTS-STARTPTS[v0]; ... concat=n=N:v=1:a=1[vout][aout]

Audio gets the same treatment if every segment has an audio stream, which is checked per file. Output is yuv420p with +faststart, which is the combination that actually plays in browsers and on phones.

The inputs

  • SEGMENTS - required, CMK_VIDEO_SEGMENTS. Comes from the split node.
  • LOG - required, and it must be a real CMK_LOG_PIPE. Passing None raises a type error, which is a small taste of how strict this pack is.
  • SAVE ENABLED - default false. Yes, really. You can run the whole merge and get a video in the player plus a FULLPATH output without anything being written to your output folder unless you flip this on.
  • FILENAME PREFIX - default video. Note it's not the final name; the merged file is named <source_stem>_merged.mp4 in a folder named after the source video.
  • OUTPUT FOLDER - default video/final.
  • VIDEO CODEC - libx264 or hevc.
  • VIDEO BITRATE - default 8000k. Nothing overrides this for the merged output; the source segments' settings only inform the fingerprint.
  • PRESET - ultrafast through veryslow, default fast. Faster presets are genuinely a good idea here: this is a concatenation, and spending veryslow on already-encoded frames buys you almost nothing.

Outputs: VIDEO (CMK_VIDEO), FULLPATH (STRING), LOG and diagnostic.

The reuse behaviour worth knowing

Before doing any work, the node fingerprints the segment list plus the encoding settings and compares against a manifest written next to the previous output. If the fingerprint matches and the output file still exists, it returns the cached result with status REUSED. If the manifest exists but the fingerprint changed, status is INVALIDATED and it re-merges.

This is the persistent-cache contract the README flags as the only thing in the pack that survives a ComfyUI restart - the image boundary caches under ComfyUI/temp/cmk/ don't. In practice it means re-queueing a workflow where you changed a setting downstream of the split doesn't cost you a re-encode of the merge.

Install

The pack's usual route: ComfyUI Manager → search CMK Flow → install from CMKFlow → restart. Manual, with ComfyUI closed:

git clone https://github.com/CMKFlow/cmk_nodes.git custom_nodes/cmk_nodes
python3 custom_nodes/cmk_nodes/scripts/install_cmk_requirements.py

You want CMK dependency check: OK. On dependencies, the README mentions imageio-ffmpeg and that's in requirements.txt, but this node resolves an ffmpeg executable at runtime. If you're on a system where ffmpeg isn't on PATH, that's the failure you'll hit - and it'll be a subprocess error, not a missing-node error.

Common issues

"merged output was not created." ffmpeg ran but wrote nothing. Usually a codec availability problem - hevc needs an encoder your ffmpeg build actually ships (libx265 or a hardware one). Drop back to libx264 to confirm that's the cause.

Audio went missing. Audio is only concatenated if all segments have it. One silent segment and the merge is video-only, silently.

Output isn't where you looked. The OUTPUT FOLDER widget is a base; the file lands in a per-source subfolder under output/video/merged/<source_name>/. Check FULLPATH rather than guessing.

CategoryCMK/Toolbox/Video

Inputs (8)

NameTypeDefaultDescription
SEGMENTSCMK_VIDEO_SEGMENTS—
LOGCMK_LOG_PIPE—
SAVE ENABLEDBOOLEANfalse—
FILENAME PREFIXSTRINGvideo—
OUTPUT FOLDERSTRINGvideo/final—
VIDEO CODECCOMBOlibx2642 options: libx264, hevc
VIDEO BITRATESTRING8000k—
PRESETCOMBOfast9 options: ultrafast, superfast, veryfast, faster, fast, medium, +3

Outputs (4)

NameTypeDescription
VIDEOCMK_VIDEO—
FULLPATHSTRING—
LOGCMK_LOG_PIPE—
diagnosticCMK_DIAGNOSTIC—