Nodes/ComfyUI-WepeNerd/Exact Video Frames/FPS (WepeNerd)
ComfyUI Node

Exact Video Frames/FPS (WepeNerd)

Videos that are exactly N frames at exactly M fps

By WepeNerd·Created 5 months ago·Updated about 17 hours ago· 0
Exact Video Frames/FPS (WepeNerd)
  • video
  • video
  • output_path
  • info
video_file
target_frame_count81
target_fps24.000
quality_modelossless exact (FFV1/MKV)
extension_modehold_last_frame
audio_modedrop_audio
filename_prefixwepenerd/exact_video

Exact Video Frames/FPS (WepeNerd) is the node for a specific, maddening problem: ComfyUI video models often want an exact frame count and frame rate, and almost nothing in your video folder actually has them. A model wants 81 frames at 24 fps and your source is 137 frames at 29.97. This node fixes that - it writes a new video with precisely the frame count and FPS you ask for, then verifies it before handing it back.

Inputs, the three that matter:

  • target_frame_count (default 81) and target_fps (default 24) - your destination. 81 frames at 24 fps is the classic latent-matching default because that's what a lot of video pipelines generate internally.
  • quality_mode - this is the interesting one, three quality paths:
    • lossless exact (FFV1/MKV) - the default. Decodes and rewrites losslessly to MKV, giving exact frame count and exact FPS metadata without adding generational loss. This is the "I need it right, and container format doesn't matter" choice.
    • lossless exact (H.264 RGB/MP4) - same exactness, but as a lossless H.264 MP4, for workflows that need MP4. Slower to encode (CRF 0, veryslow) but the file is MP4.
    • stream copy best effort (no re-encode) - copies compressed packets without re-encoding, so it's fast and lossless in the packet sense, but the README is upfront: FPS metadata is best-effort because many containers preserve the source packet timing. Frame count is still verified; exact FPS is not guaranteed.

When your target is longer than the source at the requested FPS, extension_mode decides: hold_last_frame pads with a clone of the final frame (the default - good for still-endings), or loop_source repeats the source. audio_mode defaults to drop_audio, or copy_trim_audio copies the source audio packets and trims them to the new duration without re-encoding, when the container allows.

Outputs: a video socket (a real ComfyUI VIDEO, so you can wire it straight into downstream video nodes), output_path (the absolute file path, saved under your ComfyUI output folder with a wepenerd/exact_video prefix you can change), and info - a STRING with source and output probe details plus a mode note. That info string is worth a look: it's your confirmation the output actually verified.

Mechanically it's FFmpeg under the hood, and it's honest about it: it requires ffmpeg and ffprobe on PATH, and errors at runtime if they're missing. The pipeline probes the source with ffprobe, builds an fps filter plus a tpad clone for extension and a trim to the exact frame count, then re-probes the output and raises an error if the frame count doesn't match - no silent wrong-video handoffs. One catch: the video input socket only accepts file-backed VIDEO sources (e.g. from ComfyUI's Load Video node), because exact FFmpeg processing needs a real file; an in-memory video stream will error with a clear message.

Where it fits: before a video model that demands exact lengths, after generation when you need to normalize your own outputs to a strict spec, or in dataset prep where every clip must be N frames. It's a utility node with a narrow job, and it does that job with verification built in.

Install: ComfyUI Manager (search WepeNerd) or git clone https://github.com/WepeNerd/ComfyUI-WepeNerd.git into custom_nodes, pip install -r requirements.txt, restart.

CategoryWepeNerd/Video

Inputs (8)

NameTypeDefaultDescription
video_fileCOMBO1 options:
target_frame_countINT811–1000000
target_fpsFLOAT24.0000.001–1000
quality_modeCOMBOlossless exact (FFV1/MKV)3 options: lossless exact (FFV1/MKV), lossless exact (H.264 RGB/MP4), stream copy best effort (no re-encode)
extension_modeCOMBOhold_last_frame2 options: hold_last_frame, loop_source
audio_modeCOMBOdrop_audio2 options: drop_audio, copy_trim_audio
filename_prefixSTRINGwepenerd/exact_video
videooptVIDEO

Outputs (3)

NameTypeDescription
videoVIDEO
output_pathSTRING
infoSTRING