> trimming

Trimming covers cutting a shorter clip out of a longer file: extracting a range by start/end timestamps or by duration, and splitting one file into evenly-sized pieces. The recurring decision here is stream-copy versus re-encode — copying packets is near-instant but can only cut on keyframe boundaries, while re-encoding gives you frame-exact cut points at the cost of CPU time and a quality generation loss.

// trimming

4 commands

// faq

How do I trim a video without re-encoding it?

Use -c copy with your -ss/-to (or -t) range, e.g. ffmpeg -ss 00:01:00 -to 00:02:00 -i in.mp4 -c copy out.mp4. It copies the compressed packets straight through, so it finishes almost instantly, but the cut snaps to the nearest keyframe rather than the exact timestamp you asked for.

Why does my trimmed clip start at the wrong time or open with a frozen frame?

Both come from -c copy: ffmpeg can't create a new keyframe, so the cut has to land on an existing one. Input-side seeking (-ss before -i) snaps the start back to the nearest keyframe, so the clip begins a bit earlier than the timestamp you asked for. Output-side seeking with -c copy instead lets the clip start on a non-keyframe, which players show as a frozen or garbled image until the next keyframe arrives. Re-encode (e.g. -c:v libx264) when you need the cut to land exactly on the timestamp and start cleanly.

Should -ss go before or after -i?

Before -i is input seeking: ffmpeg uses the file index to jump straight to a keyframe, so it's fast regardless of file size. With -c copy the cut stays keyframe-bound (imprecise start), but when you re-encode, -accurate_seek (on by default) decodes from that keyframe up to the exact frame, giving a cut that's both fast and frame-exact. After -i is output seeking: ffmpeg decodes and discards every frame from the start of the file up to the cut point, which is frame-accurate on any format but gets slower the deeper the cut. In short, input seeking wins on speed (and, when re-encoding, on accuracy too); output seeking trades speed for guaranteed frame accuracy everywhere.