π Loop Video
Pad a short clip to any length β and hide the seam while you're at it
- frames
- audio
- final_video_path
MF_LoopVideo repeats a clip until it hits a target duration, and it's the node behind every "this is 5 seconds but I need it to be 60" moment: social-media squares that need 15/30/60-second versions of one clip, intro loops, ambient B-roll. It's also a speed node and a reverse node if you need those - speed and reverse are right there in the widget list.
The design question it answers well is how to join the repeats. A hard repeat-and-cut is deterministic and instant but shows a seam every cycle. That's strict mode. ping_pong plays the clip forward, then backward, forward, backward - seam-free back-and-forth that doubles the effective length. crossfade chains FFmpeg xfade transitions between repeats for genuinely smooth loops, capped at 50 loops. If you've ever watched a video loop where the end visibly jumps back to the start, ping_pong or crossfade is the fix.
How it works
strict repeats via FFmpeg's loop filter and cuts to the exact duration. ping_pong uses reverse-chained segments. crossfade builds an xfade chain (and auto-falls back to strict if your crossfade duration is longer than the clip itself - you can't crossfade into a loop that's shorter than the fade). The speed setting uses setpts for video plus an auto-chained atempo for audio, so pitch stays correct when you speed up or slow down.
The inputs that matter
target_duration_sec- the output length. The whole point of the node.loop_mode-strict/ping_pong/crossfade. Defaultstrict; reach forcrossfadewhen the seam matters.crossfade_sec- fade length, only used incrossfademode.speed-0.25β4.0. Slow-mo or time-lapse in the same encode.reverse- pre-reverse the source before looping.keep_audio/audio_volume- keep the track, and how loud.0.0mutes.codec/crf/preset- the usual encode set, smart NVENC default.
Dual-input supported: wire frames + tensor_fps + audio to loop a tensor pipeline's output instead of a file. Output: final_video_path.
Install
Part of MediaForge:
cd ComfyUI/custom_nodes
git clone https://github.com/leon80148/comfyui_MediaForge.git
# restart ComfyUI
Or ComfyUI Manager β "MediaForge".
Common issues
The documented limit is the one that bites: FFmpeg's loop filter buffers up to MAX_LOOP_FRAMES = 32767 frames (INT16). A long source at high fps hits this and errors - the fix is crossfade mode (its xfade chain has no single buffer) or a lower fps. And reverse loads the entire stream into RAM, so reversing a long clip can OOM; cut to a sub-clip first. One more: with strict, the seam is real and visible - if your loop is for anything people will watch for more than a few seconds, ping_pong or crossfade is worth the extra encode time.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | input/sample.mp4 | β |
| filename_prefix | STRING | MediaForge/looped | β |
| target_duration_sec | FLOAT | 30.00.1β36000 | β |
| loop_mode | COMBO | strict | 3 options: strict, ping_pong, crossfade |
| crossfade_sec | FLOAT | 1.00.1β10 | β |
| speed | FLOAT | 1.000.25β4 | β |
| reverse | BOOLEAN | false | β |
| keep_audio | BOOLEAN | true | β |
| audio_volume | FLOAT | 1.000β1 | β |
| codec | COMBO | h264 NVIDIA GPU (h264_nvenc) | 7 options: h264 (libx264), hevc (libx265), av1 (libsvtav1), prores (prores_ks), h264 NVIDIA GPU (h264_nvenc), hevc NVIDIA GPU (hevc_nvenc), +1 |
| crf | INT | 180β51 | β |
| preset | COMBO | medium | 9 options: ultrafast, superfast, veryfast, faster, fast, medium, +3 |
| framesopt | IMAGE | β | |
| tensor_fpsopt | FLOAT | 30.01β240 | β |
| audioopt | AUDIO | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| final_video_path | STRING | β |