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.

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.mp4Why 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?
-ttakes a length and-toa position. They are mutually exclusive, and-thas priority.- Before
-i,-tostops reading the input at that position, soffmpeg -ss 65 -to 95 -i input.mp4 output.mp4keeps 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. -sstakes 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).-anas 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_zeroin current code. The cut may start a GOP early, and the result reports the real in-point asactual_start_seconds.
| FFmpeg | Sume video trim |
|---|---|
-ss 65 before -i | start: 65 |
-t 30 | duration: 30 (0.2–900 s) |
-to 95 before -i | end: 95; past the source it clamps |
No -c copy (re-encode) | precision: "exact" (default) |
-c copy | precision: "keyframe" |
-an | audio: "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,heightfrom 256 to 2160,fpsof 24, 25, 30 or 60) changes the size or frame rate on the way out, withexactonly.- Each trim is one job at $0.02 per job, plus a 5.5% agent fee by default.
Sources
Related posts
More in Developers
- Higgsfield API key: how to get one and send it
A Higgsfield API key is a key ID plus a secret made in Higgsfield Console, sent together in one Authorization: Key header from server code only.
- HMAC vs digital signature: what each proves for webhooks
An HMAC proves the sender holds a shared secret. A digital signature is made with a private key and checked with a public one, adding non-repudiation.
- How long does it take to generate an AI image?
On Sume, most AI images finish inside the 30 seconds the API holds a request open. What makes one take longer, and how to tell slow from stuck.
- How to build your own AI video generator (no training)
Build your own AI video generator from a front end, a small backend and a video model API. You don't train a model; your backend holds the key.
Written by Sume