FunUI Save Video
MP4 Out, on the GPU Encoder, Without the Last Minute of Nothing
- images
- audio
You spend four minutes generating a clip and then ComfyUI spends another thirty seconds encoding it, single-threaded, while you stare at a progress bar. That's the actual problem this node solves, and the source says it out loud: core's SaveVideo goes through libx264, and FFmpeg's library default is one thread.
FunUI Save Video uses your GPU's encoder when it has one, falls back to every CPU core when it doesn't, and never loses a generation to the encoder.
What it actually does
With encoder on auto (the default) or gpu, it checks whether the PyAV build actually exposes the NVENC encoder it wants - h264_nvenc or hevc_nvenc, constant-quality mode at cq 23, preset p5. If the name isn't in av.codecs_available, or the GPU attempt throws (no NVENC on the card, driver refusal, container without the encode library), it deletes the half-written file and re-does the whole thing as libx264 at crf 23 with thread_count = 0, which means all cores. You get a saved video either way, plus one log line explaining the fallback. That "never lose a generation to the encoder" discipline is the good part.
Audio is muxed into the same file as AAC, both tracks added before the first write because the MP4 header is fixed at that point. It also does something smart with broken sound: if the waveform contains NaN or Inf, it drops the audio and tells you your precision is probably wrong (fp16 on a model that needs bf16) rather than handing you a file whose soundtrack is static. Video survives; audio is sacrificed knowingly.
The rest is polish you'd otherwise be doing in ffmpeg by hand: use_metadata_tags keeps the workflow inside the file, faststart puts the index first so preview scrubbing works, and H.265 is tagged hvc1 because the default hev1 gets refused by Safari and Chrome on a Mac.
Inputs and outputs
Required:
- images - the frames. This is an output node; it takes
IMAGE, notVIDEO, so wire your decode straight in. Core's CreateVideo step in between only bundled things up. - fps - default 24, up to 240, accepts fractions of a frame rate.
- filename_prefix - lands in
ComfyUI/output, same naming and counter as core's save nodes.
Optional:
- audio - an
AUDIO. This is how native stereo from H3 actually reaches the file. - encoder -
auto/gpu/cpu.cpuforces libx264 on every core, which is the thing to try when NVENC is present but the result looks wrong. - codec -
h264(plays everywhere) orh265(smaller files, Firefox may not play them). Only applies to the GPU encoder; the CPU fallback is always H.264.
No outputs to wire - the node reports a saved MP4 in the UI node and logs how many frames it wrote and in what time. That's your encode-speed measurement, free.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/digital-garbage/FunUI
cd FunUI && pip install -r requirements.txt
ComfyUI Manager: FunUI. Restart. (Pack page says olivv-cs/ComfyUI-FunPack; repo is digital-garbage/FunUI.)
Nothing to download for this one - PyAV is already a ComfyUI dependency, and the node checks what that build supports at runtime rather than assuming. GPU encoding needs a working NVENC, which on consumer cards means roughly Pascal or newer, and in a container means NVIDIA's video capability plus libnvidia-encode.so.1 actually present.
That last point is the one I'd flag before you file a bug: nvidia-smi looking healthy proves nothing, because FFmpeg's driver check inspects the library the process loaded, not what the tool reports. The node's own error message says as much.
Where people get burned
Wiring a video object in. It wants frames. If you've got a VIDEO, decode it first.
H.265 and a Firefox viewer. It's a smaller file and a broken preview for anyone on Firefox. If the clip is going to a browser, stay on H.264 - with NVENC the size advantage of H.265 isn't buying you speed anyway.
Silent output at the right length. That's the NaN-audio path. Check the log: it tells you it removed the audio and points at precision. Fix the VAE dtype (bf16) rather than re-encoding.
Audio the wrong length. The soundtrack is cut to len(frames) / fps seconds. If you save frames at 24 fps but your audio came from a different-timed source, you'll get drift. Match the fps to what generated the clip.
Reading too much into auto. It's "GPU if it works, otherwise CPU" - not "GPU-quality". On a card whose NVENC is fine but whose output you don't like, cpu is a legitimate choice and the difference is a few minutes, not a lost run.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| fps | FLOAT | 24.001–240 | — |
| filename_prefix | STRING | FunUI | — |
| audioopt | AUDIO | — | |
| encoderopt | COMBO | auto | auto and gpu: the GPU encoder (NVENC) when it works, otherwise H.264 on the CPU so the video is still saved. cpu: H.264 (libx264) on every core. |
| codecopt | COMBO | h264 | For the GPU encoder. H.264: plays in every browser. H.265: smaller files, but Firefox may not play it. |
Outputs (0)
No outputs