Seek fast by placing -ss before -i
Put -ss before -i so FFmpeg 7.1 jumps straight to the nearest keyframe instead of decoding and discarding every frame up to the start time.
The position of -ss on the command line changes how it works, not just where it sits. Before -i it is an input option: FFmpeg seeks in the container and starts reading near the requested time. After -i it is an output option: FFmpeg decodes from the very beginning and throws frames away until it reaches the time. On an hour-long file the second form can take minutes to reach a point near the end.
ffmpeg -ss 00:45:00 -i long.mp4 -t 10 -c:v libx264 -crf 23 -c:a aac out.mp4Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))An input seek is also frame accurate when the video is being re-encoded, because FFmpeg decodes from the preceding keyframe and drops frames up to the target. That is why the example re-encodes. With -c copy the cut snaps to a keyframe instead, as covered in the trim row.
Seeking by byte offset into the index is a feature of the container, so a few formats such as raw .h264 streams without an index cannot seek quickly at all. The FFmpeg seeking guide lists the exceptions. For short files the difference is not worth thinking about.