Cuts several ranges out of one video and joins them into a single file — losslessly, snapped to
the file’s real keyframes instead of the extra footage a naive ffmpeg -ss … -c copy quietly
keeps.
Why -c copy alone gets it wrong
A stream copy moves compressed packets without decoding them, so it can only start where a keyframe already sits — not at the timestamp asked for. ffmpeg snaps backward to the nearest keyframe at or before the cut point and hides the extra frames behind an edit list, so the clip looks the right length in a player and is not: the concat demuxer that joins multiple cuts reads packets, not edit lists, and plays every hidden frame back. Cut two adjacent ranges this way and the second one opens by replaying the tail of the first; cut around a range you meant to remove and part of it can come back.
What keycut does instead
It asks ffprobe where the keyframes actually are, then only ever cuts on one — snapping
forward, never back. Ranges that overlap, or sit closer together than one GOP, are merged
first, so no join is left to replay anything. An optional exclude mask names seconds that must
never survive the cut; keycut re-encodes just the ranges that need it, using codec and colour
settings read from the master itself, and stream-copies the rest.
Command line
1keycut master.mp4 highlights.mp4 -r 0:30 1:15 -r 4:00 4:45
--dry-run prints the plan — which ranges merged, where each cut was aligned, and which ranges
will be copied versus re-encoded — without touching a byte.
Requirements
Python 3.11+, and ffmpeg/ffprobe on PATH. No Python dependencies. The Windows installer
above does not bundle ffmpeg — winget install -e --id Gyan.FFmpeg puts it on PATH (or
choco install ffmpeg).
Documentation
keycut’s documentation lives in its repository, next to the code it describes — the README is the manual.