Use -ss before -i for fast seek
When you only need a clip from the middle of a long file, the position of `-ss` on the command line changes the cost by orders of magnitude. `-ss` before `-i` triggers a fast keyframe-aligned seek; `-ss` after `-i` triggers an accurate but slow frame-by-frame seek.
The command
ffmpeg -ss 600 -i long.mp4 -t 30 -c copy clip.mp4What it does
The command seeks to the 10-minute mark in the input, captures the next 30 seconds, and writes the result to a new file. The seek is fast because FFmpeg uses the keyframe index to jump to the nearest keyframe before the 10-minute mark, and stream copy does not re-decode the frames. The clip starts at a keyframe, so it may be a few seconds off from the exact 10-minute mark. The output plays in any player that supports the container.
Requirements
Any container FFmpeg can read. The command uses stream copy, so no encoder is loaded. The seek is fast (typically milliseconds), regardless of the input file's length.
Things to avoid
- Expecting frame-accurate cuts. A fast seek snaps to a keyframe, so the cut may be a few frames off. For an exact cut, use `-ss` after `-i` or chain both: `-ss 595 -i long.mp4 -ss 5 -c copy clip.mp4` (the first seek is fast, the second is accurate).
- Using `-ss` before `-i` on a file with no keyframe index. Some containers (MPEG-TS, raw streams) do not have a seek table; the fast seek falls back to a slow seek. Use `-ss` after `-i` for those.
- Combining `-ss` before `-i` with a re-encode. The fast seek is wasted if you re-decode the video; for a re-encode, use `-ss` after `-i` to get an accurate cut.
- Forgetting that the seek is in seconds, not frames. `-ss 100` is 100 seconds, not 100 frames.