Nodes/MKRShift_Nodes/Trim Video By Time
ComfyUI Node

Trim Video By Time

Trim a video to a time range without leaving ComfyUI

By criskb·Created 7 months ago·Updated 5 months ago· 0
Trim Video By Time
  • video
  • video
  • output_path
  • summary
start_sec0.00
end_sec-1.00
output_formatauto
filename_prefixMKR_trim_video
subfolder
overwritefalse
reencodetrue
keep_audiotrue
filename_label

MKRTrimVideoByTime cuts a clip down to a time range and writes out a new file - the ComfyUI-native version of "open it in a video editor, cut the top and tail, export." If your generated video always has two useless seconds of fade-in and a tail you don't want, this is the node that strips them without you ever touching another app.

It's the rare video node here that's a direct ffmpeg passthrough rather than a frame-by-frame reprocess. It hands ffmpeg a fast input seek (-ss before -i), an optional -to, and a target path. That means it's fast - it's not decoding, processing, and re-encoding every frame like the FX nodes do. It's also the one where the reencode toggle matters: leave it true and it re-encodes with the pack's usual codecs (libx264/aac for mp4/mov, vp9/opus for webm). Flip it false and, when the output format matches the source, it does a stream copy (-c copy) - no re-encode, no quality loss, near-instant. That's the fast path for trimming an already-fine MP4.

The inputs that matter

  • video - anything with a file path behind it: a file path string, a dict payload with path, a VHS-style video dict, or an MKR_VIDEO output from a sibling node.
  • start_sec / end_sec - the range, in seconds. end_sec defaults to -1, which means "to the end of the clip." Leave it alone unless you're trimming the tail too.
  • reencode - stream copy when false. Set this false for fast lossless trims of mp4/mov.
  • keep_audio - defaults true; flip off to drop the audio track entirely.
  • output_format - auto keeps the source container, or force mp4, mov, webm, gif, webp.
  • overwrite - off by default; turn it on or the node skips when a file already exists at the target.

Outputs: video (an MKR_VIDEO payload - a dict with kind: "video", the path, and metadata like fps/dimensions), output_path, and a summary JSON that includes any warnings. Wire video into another MKR video node to chain edits.

Install

Part of MKRShift Nodes - install the pack, not the node:

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

or via ComfyUI Manager (search MKRShift_Nodes), then restart. You need system ffmpeg on your PATH - the README calls it out explicitly, and without it this node can't trim mp4/mov/webm (it only falls back to a PIL-based path for gif/webp). No pip requirements; the pack's pyproject.toml has none.

Where people get burned

Forgot to install ffmpeg and you'll get the source path back untouched, plus a warnings entry in the summary saying exactly that - check summary before assuming the trim worked. Second classic: overwrite left off and an old file at the target, so your "trim" silently didn't run. And one timing gotcha: the seek is input-side (-ss before -i), which is fast and accurate in modern ffmpeg, but if you're trimming to an exact frame boundary at a non-integer second, trim by frames instead - there's a sibling node, MKRVideoSelectRangeByFrames, for exactly that.

CategoryMKRShift Nodes/Media/Video/Edit

Inputs (10)

NameTypeDefaultDescription
video*
start_secFLOAT0.000–86400
end_secFLOAT-1.00-1–86400
output_formatCOMBOauto6 options: auto, mp4, mov, webm, gif, webp
filename_prefixSTRINGMKR_trim_video
subfolderSTRING
overwriteBOOLEANfalse
reencodeBOOLEANtrue
keep_audioBOOLEANtrue
filename_labeloptSTRING

Outputs (3)

NameTypeDescription
videoMKR_VIDEO
output_pathSTRING
summarySTRING