Trim Video By Time
Trim a video to a time range without leaving ComfyUI
- video
- video
- output_path
- summary
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 withpath, a VHS-style video dict, or anMKR_VIDEOoutput from a sibling node.start_sec/end_sec- the range, in seconds.end_secdefaults 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 thisfalsefor fast lossless trims of mp4/mov.keep_audio- defaults true; flip off to drop the audio track entirely.output_format-autokeeps the source container, or forcemp4,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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| video | * | — | |
| start_sec | FLOAT | 0.000–86400 | — |
| end_sec | FLOAT | -1.00-1–86400 | — |
| output_format | COMBO | auto | 6 options: auto, mp4, mov, webm, gif, webp |
| filename_prefix | STRING | MKR_trim_video | — |
| subfolder | STRING | — | |
| overwrite | BOOLEAN | false | — |
| reencode | BOOLEAN | true | — |
| keep_audio | BOOLEAN | true | — |
| filename_labelopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| video | MKR_VIDEO | — |
| output_path | STRING | — |
| summary | STRING | — |