FFmpeg trim video: cut by time, with or without re-encoding

Trim a video with FFmpeg: -ss before -i to seek, -t for the length, and -c copy to skip re-encoding, which starts the cut at the keyframe before.

5 min readSume
All posts

To trim a video with FFmpeg, put -ss (where to start) before -i and -t (how long to keep) after it. ffmpeg -ss 65 -i input.mp4 -t 30 output.mp4 re-encodes a frame-accurate 30-second clip from 1:05. Add -c copy to cut without re-encoding: no quality is lost, but the clip then starts at the keyframe before 1:05.

The FFmpeg behavior below is quoted from the ffmpeg documentation and its time duration syntax, and the Sume facts come from the Video trim docs, all read on 2026-09-28. Sume's encoder settings, and anything else described as current behavior, are read from its code.

How do I trim a video without re-encoding?

Add -c copy. FFmpeg then copies the compressed packets; its docs describe stream copy as working "with no decoding or encoding", so "there is no quality loss". Leave it out and "ffmpeg will transcode all audio, video, and subtitle streams", which decodes and re-encodes the part you keep.

# Lossless: no re-encode; starts at the keyframe before 65 s
ffmpeg -ss 65 -i input.mp4 -t 30 -c copy output.mp4

# Frame-accurate: decodes and re-encodes the 30 s you keep
ffmpeg -ss 65 -i input.mp4 -t 30 output.mp4

Why does -c copy start the clip early?

Because -ss before -i seeks in the input file, and FFmpeg's docs say that "in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position". When transcoding, with -accurate_seek on by default, the frames between that point and your start "will be decoded and discarded". With stream copy they "will be preserved", so the clip opens on the earlier keyframe, before your start time.

A stream copy starts on a keyframe: FFmpeg leaves out the non-key frames at the beginning unless you add -copyinkf. So a cut that is both lossless and frame-exact works only when your start time falls on a keyframe. Otherwise, pick one of the two. How early a copy can start depends on the keyframe interval, which keyframe interval explained covers.

How do I cut by start and end time, or by frame?

  • -t takes a length and -to a position. They are mutually exclusive, and -t has priority.
  • Before -i, -to stops reading the input at that position, so ffmpeg -ss 65 -to 95 -i input.mp4 output.mp4 keeps 1:05 to 1:35.
  • Times are plain seconds (65, 23.189) or [HH:]MM:SS[.m] (00:01:05), per FFmpeg's time duration syntax.
  • -ss takes a time, not a frame number. For frame N at F frames per second, use N ÷ F: frame 1,950 at 30 fps is 65 seconds (converting frames to seconds covers other rates).
  • -an as an output option leaves the audio out.

Can I run the same trim without FFmpeg?

For a file already in your workspace on media.sume.com, such as an earlier Sume job's output, Sume's video trim runs both cuts on its servers. You send JSON, not a command: fields such as vf, codec or crf are refused with ffmpeg_fields_rejected. Trim, filter, or detach audio with the Sume API covers the call itself.

  • precision: "exact", the default, is a frame-accurate re-encode. In current code it runs -ss <start> -i <input> -t <length> with libx264 (-preset veryfast -crf 18, yuv420p), AAC at 192 kbps and +faststart.
  • precision: "keyframe" is a stream copy: the same seek with -c copy -avoid_negative_ts make_zero in current code. The cut may start a GOP early, and the result reports the real in-point as actual_start_seconds.
From the ffmpeg documentation and Video trim, read 2026-09-28.
FFmpegSume video trim
-ss 65 before -istart: 65
-t 30duration: 30 (0.2–900 s)
-to 95 before -iend: 95; past the source it clamps
No -c copy (re-encode)precision: "exact" (default)
-c copyprecision: "keyframe"
-anaudio: "drop"
curl -X POST https://api.sume.com/v1/video-trim \
  -H "Authorization: Bearer $SUME_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: clip-trim-001" \
  -d '{
    "video_url": "https://media.sume.com/artifacts/artf_demo/talk.mp4",
    "start": 65,
    "duration": 30,
    "precision": "keyframe"
  }'

What are the limits of Sume's trim?

  • The source can be up to 1,800 seconds long, and each cut 0.2 to 900 seconds. In current code, a source file over 300 MiB is refused with source_too_large.
  • output (width, height from 256 to 2160, fps of 24, 25, 30 or 60) changes the size or frame rate on the way out, with exact only.
  • Each trim is one job at $0.02 per job, plus a 5.5% agent fee by default.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume