Technologies

How to Cut Video Without Losing Quality

A stream copy cut keeps 100% of the original quality, but it can only start at a keyframe. Here is how to cut with FFmpeg or LosslessCut, and when to re-encode.

Phil Duong

Builds Vidtrimmer

How to Cut Video Without Losing Quality

Most quality loss in a cut doesn't come from the cut. It comes from the export after it. Every time a lossy video is decoded and encoded again, it loses a little detail, an effect called generation loss (Wikipedia). The fix is to avoid the second encode, and to understand the one rule that comes with that choice: keyframes.

Key takeaways

  • A stream copy (-c copy in FFmpeg) has "no quality loss" and is "very fast" (FFmpeg documentation).
  • A stream copy can only start at a keyframe, so the start point is not exact.
  • When you need an exact frame, a crop, or a new format, re-encode once at a high quality setting.
MethodQualityStart pointSpeed
Stream copy (-c copy, LosslessCut)Identical to sourceSnaps to a keyframeSeconds
Re-encode at CRF 18Very close to sourceExact frameSlower, depends on length
Re-encode at an app's default exportCan be visibly softerExact frameSlower

Why do videos lose quality when you cut them?

Because most editors re-encode the whole clip on export. Video files like MP4 use lossy compression, and "repeated applications of lossy compression and decompression can cause generation loss" (Wikipedia). One careful re-encode is hard to see. A clip that was downloaded, trimmed, exported, uploaded, and downloaded again has been through several, and each one costs detail.

The same article states the only full fix: generation loss is avoided by "using uncompressed or losslessly compressed files", and "copying a digital file itself incurs no generation loss." A lossless cut is a copy of the frames you keep, nothing more.

What is a keyframe, and why does it decide where you can cut?

A keyframe is a frame that the player can draw on its own. Compressed video is stored in groups of pictures (GOPs), and each group starts with an I-frame: "a complete image that can be encoded and decoded independently" (Mux, 2024). The frames after it mostly store differences: a P-frame holds "the differences (motion vectors) between themselves and the previous frame."

That's why a lossless cut can't start anywhere. If the clip started on a P-frame, the player would have nothing to apply the differences to. A stream copy has to start at the I-frame before your start time.

How far apart are keyframes? It depends on the encoder, so measure instead of guessing. This command lists every keyframe time in a file:

ffprobe -v error -select_streams v:0 -skip_frame nokey \
  -show_entries frame=pts_time -of csv=p=0 input.mp4

We ran it on the 1080p trailer of Sintel, an open movie from the Blender Foundation. Its keyframes sit at 0, 9.3, 13.9, 22.3, and 23.8 seconds, and the longest gap is 10.4 seconds. YouTube asks uploaders for a "GOP of half the frame rate" (YouTube Help), but a file you download from YouTube is YouTube's own re-encode, so check its keyframes the same way.

Cut losslessly with FFmpeg

Put -ss before the input and copy the streams:

ffmpeg -ss 00:01:12 -i input.mp4 \
  -t 88 -c copy output.mp4

This keeps 88 seconds from the 1:12 mark. FFmpeg's manual explains what happens at the start: in most formats "it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position." When re-encoding, the extra part "will be decoded and discarded", but "when doing stream copy ... it will be preserved" (FFmpeg documentation).

In our test, a stream copy of the Sintel trailer from 20 seconds kept 148 extra frames, 6.1 seconds of video back to the keyframe at 13.9 seconds. How a player shows those frames varies. For a clip you will edit further, that's often fine: you keep full quality and trim the extra frames in your editor. If the start must be exact, re-encode instead.

When should you re-encode instead?

Re-encode when the cut needs to be frame-exact, or when the picture itself changes. FFmpeg notes that with stream copy, filters can't be used, so cropping to 9:16 (see the resize guide), scaling, or burning in captions all need a re-encode (FFmpeg documentation). Accurate seeking "is enabled by default, so seeking is accurate when transcoding."

ffmpeg -ss 00:01:12 -i input.mp4 -t 88 \
  -c:v libx264 -crf 18 -preset medium -c:a aac output.mp4

The setting that matters is -crf. Lower values mean higher quality and bigger files, and libx264 uses 23 when you don't set it. We measured the difference on 10 seconds of the 1080p Sintel trailer (source bitrate about 2.2 Mbps), comparing each encode with the source frame by frame:

SettingFile sizePSNRSSIM
CRF 23 (libx264 default)3.8 MB48.1 dB0.9931
CRF 18 (what Vidtrimmer uses)6.1 MB50.9 dB0.9956

CRF 18 costs about 60% more space and gets measurably closer to the source. Both encodes are larger than the original, which is normal: a re-encode can't recover detail, it can only try not to lose more. Keep a re-encode clean with these habits:

  • Encode once, from the best source. Don't trim a file you already exported. Go back to the original.
  • Keep the frame rate. YouTube's guidance is that content "should be encoded and uploaded in the same frame rate it was recorded."

Cut losslessly without the command line

Use LosslessCut. It calls itself "the swiss army knife of lossless video/audio editing", and FFmpeg "does all the grunt work" (LosslessCut on GitHub). It is open source under GPL-2.0 and runs on Windows, macOS (Intel and Apple Silicon), and Linux. Manual downloads from GitHub "will of course always be free", and the README also points to app store versions for people who want automatic updates.

The keyframe rule still applies. Its docs say each segment's start "will normally (but not always) be 'rounded' to the nearest previous keyframe", and that most files need Keyframe cut mode turned on (LosslessCut docs). It also has an experimental Smart cut mode "to allow cutting between keyframes."

What about a video that's still on YouTube?

You don't have the file yet, so you have two steps: download, then cut. Vidtrimmer does both on the server. It downloads the video at the quality you pick, from 360p to 4K, cuts on the exact start and end frames you enter, and re-encodes the clip once with H.264 at CRF 18.

To be precise about the trade-off: that is one high-quality encode, not a stream copy. We chose exact frames over keyframe snapping, because many people who clip a YouTube video need the quote to start on the first word. The trim guide compares this with YouTube's own Clips and Studio editor.

A quick checklist for clean cuts

  1. Keep the original file, and cut from it every time.
  2. If an approximate start is fine, stream copy: -c copy or LosslessCut's keyframe mode.
  3. If you need an exact frame, a crop, or a new size, re-encode once at CRF 18 or lower.
  4. Keep the source frame rate and export to MP4 with H.264, the container and codec YouTube recommends.
  5. Watch the first and last second of the result before you publish it.

Questions

Can you cut a video with zero quality loss?

Yes, with a stream copy. FFmpeg's -c copy option copies the encoded frames without decoding them, so there is no quality loss and it runs very fast. The trade-off is that the cut can only start at a keyframe, so the start point may be slightly early.

Why does my cut start a second or two early?

Because you used a stream copy. A copied clip has to begin on a keyframe, the only kind of frame that decodes on its own. FFmpeg's manual says that with stream copy the extra part between the keyframe and your start time is kept.

What CRF should I use when I have to re-encode?

Lower CRF means higher quality and larger files. libx264 uses 23 when you set nothing. In our test on a 1080p clip, CRF 18 scored 50.9 dB PSNR against the source, against 48.1 dB at 23, for a file about 60% larger. Re-encode once, from the best source you have.

Is LosslessCut free?

The GitHub downloads are. LosslessCut is open source under the GPL-2.0 license and runs on Windows, macOS, and Linux. Its README says manual downloads will always be free, and it also points to app store versions for people who want to support the developer.

Can I cut a YouTube video without losing quality?

Not with a plain stream copy if you need an exact start, because the cut has to snap to a keyframe. Vidtrimmer cuts on the exact frame and re-encodes the clip once at CRF 18, which keeps the result close to the source.

Need a clip from YouTube? Paste the link, set a start and end time, and download the MP4.

Trim a YouTube video