Trim with re-encoding for frame accuracy

trimming

// what it does

Here -ss/-to come after -i, making them output-side seeks: ffmpeg decodes from the start and discards frames until 00:01:00, so the cut lands exactly on the requested timestamp. -c:v libx264 and -c:a aac re-encode the streams, which lets the output begin with a fresh keyframe at the exact cut point. Use this when you need clean, precise cut boundaries — for stitching clips together or matching an edit list — rather than the keyframe-snapped result of stream copy.

// shell

$ ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c:v libx264 -c:a aac output.mp4

// gotcha

Output seeking decodes and throws away everything before the cut, so it's markedly slower the later the start point is on a large file, and the libx264/aac re-encode adds a generation of quality loss on top of the CPU cost. (Input seeking with -ss before -i plus re-encoding would be frame-accurate too, and faster.)