Use -ss after -i for accurate seek
When the cut point must be exact, place `-ss` after the input. FFmpeg will decode from the start of the file (or from the nearest keyframe), then seek to the exact time. The cost is a full decode up to the cut point, but the precision is frame-accurate.
The command
ffmpeg -i long.mp4 -ss 600 -t 30 -c:v libx264 -crf 20 clip.mp4What it does
The command decodes the input, seeks to the 10-minute mark, captures the next 30 seconds, and re-encodes with libx264. The seek is accurate because FFmpeg decodes frame by frame from the start. For a very long file, the cost can be significant — seeking to 1 hour into a 4-hour file requires decoding 1 hour of video. To speed it up, chain a fast seek before the input: `-ss 595 -i long.mp4 -ss 5 -c copy clip.mp4`.
Requirements
Any container FFmpeg can read. The seek is accurate but slow. The encoder is loaded, so the encode takes the same time as a normal conversion. For stream copy, use `-ss` before `-i` instead.
Things to avoid
- Using `-ss` after `-i` on a multi-hour file. The cost is proportional to the seek time, so a 4-hour file with a 1-hour seek is a 1-hour decode. Use the chained form for fast-then-accurate.
- Forgetting that the seek is in seconds, not frames. `-ss 100` is 100 seconds, not 100 frames.
- Re-encoding unnecessarily. If the source is already the right codec and the cut is on a keyframe, use stream copy for a much faster result.
- Confusing the two `-ss` positions. The first is fast but keyframe-aligned; the second is slow but accurate. Choose by the precision you need.